mirror of
https://github.com/WorldObservationLog/AppleMusicDecrypt.git
synced 2026-01-15 14:22:54 -03:00
feat: exit when qemu crashes
This commit is contained in:
@@ -37,7 +37,7 @@ class InteractiveShell:
|
||||
if it(Config).localInstance.enable:
|
||||
loop.run_until_complete(self.localInstance.launch_instance(loop))
|
||||
it(GlobalLogger).logger.info("Waiting for wrapper-manager to start...")
|
||||
loop.run_until_complete(countdown(it(Config).localInstance.timeout))
|
||||
loop.run_until_complete(countdown(it(Config).localInstance.timeout, self.localInstance))
|
||||
it(Config).instance.url = "127.0.0.1:32767"
|
||||
it(Config).instance.secure = False
|
||||
loop.run_until_complete(it(WrapperManager).init(it(Config).instance.url, it(Config).instance.secure))
|
||||
|
||||
@@ -31,6 +31,12 @@ class QemuInstance:
|
||||
def terminate(self):
|
||||
self.proc.result().kill()
|
||||
|
||||
def running(self):
|
||||
if self.proc.done():
|
||||
return not bool(self.proc.result().returncode)
|
||||
else:
|
||||
return True
|
||||
|
||||
async def get_instance_image(self):
|
||||
it(GlobalLogger).logger.warning("The wrapper-manager image does not exist. Downloading...")
|
||||
async with httpx.AsyncClient(follow_redirects=True) as client:
|
||||
|
||||
@@ -2,6 +2,7 @@ import asyncio
|
||||
import concurrent.futures
|
||||
import json
|
||||
import subprocess
|
||||
import sys
|
||||
import time
|
||||
from asyncio import AbstractEventLoop
|
||||
from copy import deepcopy
|
||||
@@ -21,6 +22,7 @@ from src.exceptions import NotTimeSyncedLyricsException
|
||||
from src.logger import GlobalLogger
|
||||
from src.models import PlaylistInfo
|
||||
from src.models.album_meta import Tracks
|
||||
from src.qemu import QemuInstance
|
||||
from src.types import *
|
||||
|
||||
executor_pool = concurrent.futures.ThreadPoolExecutor()
|
||||
@@ -319,8 +321,11 @@ def config_outdated():
|
||||
return LooseVersion(it(Config).version) < LooseVersion(CONFIG_VERSION)
|
||||
|
||||
|
||||
async def countdown(seconds: int):
|
||||
async def countdown(seconds: int, qemuInstance: QemuInstance):
|
||||
while seconds > 0:
|
||||
if not qemuInstance.running():
|
||||
it(GlobalLogger).logger.error("Failed to start qemu")
|
||||
sys.exit()
|
||||
mins, secs = divmod(seconds, 60) # Convert seconds to minutes and remaining seconds
|
||||
timeformat = '{:02d}:{:02d}'.format(mins, secs) # Format for MM:SS display
|
||||
print(timeformat, end='\r') # Print on the same line, overwriting previous output
|
||||
|
||||
Reference in New Issue
Block a user