- fixes
This commit is contained in:
parent
017537edf7
commit
61cecc52dd
|
|
@ -470,7 +470,7 @@ if config['log']['adb']:
|
||||||
if 'cache_dir' in config:
|
if 'cache_dir' in config:
|
||||||
DIR_CACHE = Path(config['cache_dir'])
|
DIR_CACHE = Path(config['cache_dir'])
|
||||||
if not DIR_CACHE.is_absolute():
|
if not DIR_CACHE.is_absolute():
|
||||||
DIR_CACHE = DIR_CACHE / config['cache_dir']
|
DIR_CACHE = DIR_THIS / config['cache_dir']
|
||||||
|
|
||||||
CACHE = utils_cache.InfoCache(dir=DIR_CACHE)
|
CACHE = utils_cache.InfoCache(dir=DIR_CACHE)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -67,14 +67,17 @@ class Phone(Observable):
|
||||||
|
|
||||||
|
|
||||||
# Wait for online modem and return this
|
# Wait for online modem and return this
|
||||||
def wait_for_online_modem(self):
|
def wait_for_online_modem(self, timeout_seconds: int = 1000000):
|
||||||
while True:
|
timestamp = time.time()
|
||||||
|
while True and timestamp + timeout_seconds > time.time():
|
||||||
modem = self.get_online_modem()
|
modem = self.get_online_modem()
|
||||||
if modem != None:
|
if modem != None:
|
||||||
return modem
|
return modem
|
||||||
|
|
||||||
# Sleep another 10 seconds and check again
|
# Sleep another 10 seconds and check again
|
||||||
time.sleep(10.0)
|
time.sleep(1.0)
|
||||||
|
|
||||||
|
return None
|
||||||
|
|
||||||
|
|
||||||
def get_incoming_call(self):
|
def get_incoming_call(self):
|
||||||
|
|
@ -108,8 +111,12 @@ class Phone(Observable):
|
||||||
|
|
||||||
# Wait for online modem
|
# Wait for online modem
|
||||||
utils.log('Waiting for BT modem (phone must be paired and connected before)...')
|
utils.log('Waiting for BT modem (phone must be paired and connected before)...')
|
||||||
self.modem = self.wait_for_online_modem()
|
self.modem = self.wait_for_online_modem(timeout_seconds=10) # 10 seconds timeout
|
||||||
|
|
||||||
|
if self.modem is None:
|
||||||
|
utils.log_error(f'No BT modem found. Please reconnect the phone.')
|
||||||
|
raise RuntimeError('No BT modem found.')
|
||||||
|
|
||||||
# Log about found modem
|
# Log about found modem
|
||||||
utils.log(f'BT modem found. Modem: {self.modem}')
|
utils.log(f'BT modem found. Modem: {self.modem}')
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import os
|
||||||
import shutil
|
import shutil
|
||||||
import json
|
import json
|
||||||
import uuid
|
import uuid
|
||||||
|
import utils
|
||||||
|
|
||||||
class InfoCache:
|
class InfoCache:
|
||||||
dir: Path
|
dir: Path
|
||||||
|
|
@ -12,7 +13,12 @@ class InfoCache:
|
||||||
def __init__(self, dir: Path) -> None:
|
def __init__(self, dir: Path) -> None:
|
||||||
self.dir = dir
|
self.dir = dir
|
||||||
if dir is not None and not dir.exists():
|
if dir is not None and not dir.exists():
|
||||||
os.mkdir(dir)
|
try:
|
||||||
|
os.mkdir(dir)
|
||||||
|
except Exception as e:
|
||||||
|
utils.log_error(str(e))
|
||||||
|
self.dir = None
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def is_active(self) -> bool:
|
def is_active(self) -> bool:
|
||||||
|
|
@ -66,10 +72,13 @@ class InfoCache:
|
||||||
f.write(phone.dump())
|
f.write(phone.dump())
|
||||||
|
|
||||||
def get_phone(self, name: str) -> Phone:
|
def get_phone(self, name: str) -> Phone:
|
||||||
p = self.dir / f'phone_{name}.json', 'wt'
|
p = self.dir / f'phone_{name}.json'
|
||||||
if p.exists():
|
if not p.exists():
|
||||||
with open(p, 'rt') as f:
|
utils.log(f'Phone definition at path {p} not found.')
|
||||||
return Phone.make(f.read())
|
return None
|
||||||
|
|
||||||
|
with open(p, 'rt') as f:
|
||||||
|
return Phone.make(f.read())
|
||||||
|
|
||||||
def put_tasks(self, name: str, tasks: TaskList):
|
def put_tasks(self, name: str, tasks: TaskList):
|
||||||
p = self.dir / f'tasks_{name}.json'
|
p = self.dir / f'tasks_{name}.json'
|
||||||
|
|
@ -79,6 +88,7 @@ class InfoCache:
|
||||||
|
|
||||||
def get_tasks(self, name: str) -> TaskList:
|
def get_tasks(self, name: str) -> TaskList:
|
||||||
p = self.dir / f'tasks_{name}.json'
|
p = self.dir / f'tasks_{name}.json'
|
||||||
|
# ToDo
|
||||||
|
|
||||||
|
|
||||||
def add_report(self, report: dict) -> str:
|
def add_report(self, report: dict) -> str:
|
||||||
|
|
|
||||||
|
|
@ -154,11 +154,13 @@ class QualtestBackend:
|
||||||
try:
|
try:
|
||||||
response = urllib.request.urlopen(url, timeout=utils.NETWORK_TIMEOUT)
|
response = urllib.request.urlopen(url, timeout=utils.NETWORK_TIMEOUT)
|
||||||
if response.getcode() != 200:
|
if response.getcode() != 200:
|
||||||
utils.log_error("Failed to get task list. Error code: %s" % response.getcode())
|
raise RuntimeError(f'Failed to load phone definition. Error code: {response.getcode()}')
|
||||||
return None
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
utils.log_error(f'Problem when loading the phone definition.')
|
utils.log_error(f'Problem when loading the phone definition from backend. Error: {str(e)}')
|
||||||
return cache.get_phone(self.instance)
|
r = cache.get_phone(self.instance)
|
||||||
|
if r is None:
|
||||||
|
raise RuntimeError(f'No cached phone definition.')
|
||||||
|
return r
|
||||||
|
|
||||||
# Get possible list of phones
|
# Get possible list of phones
|
||||||
phones = json.loads(response.read().decode())
|
phones = json.loads(response.read().decode())
|
||||||
|
|
@ -199,8 +201,8 @@ class QualtestBackend:
|
||||||
return result
|
return result
|
||||||
|
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
utils.log_error("Exception when fetching task list: {0}".format(err))
|
utils.log_error(f"Exception when fetching task list: {str(err)}")
|
||||||
return dict()
|
return None
|
||||||
|
|
||||||
|
|
||||||
def load_audio(self, audio_id: int, output_path: Path):
|
def load_audio(self, audio_id: int, output_path: Path):
|
||||||
|
|
|
||||||
|
|
@ -95,7 +95,7 @@ def find_binaries(bin_directory: Path, license_server: str = None):
|
||||||
SILER_PATH = bin_directory / platform_prefix / SILER_PATH
|
SILER_PATH = bin_directory / platform_prefix / SILER_PATH
|
||||||
SPEECH_DETECTOR_PATH = bin_directory / platform_prefix / SPEECH_DETECTOR_PATH
|
SPEECH_DETECTOR_PATH = bin_directory / platform_prefix / SPEECH_DETECTOR_PATH
|
||||||
|
|
||||||
print(f'Looking for binaries/licenses/configs at {directory}...', end=' ')
|
print(f'Looking for binaries/licenses/configs at {bin_directory}...', end=' ')
|
||||||
|
|
||||||
# Check if binaries exist
|
# Check if binaries exist
|
||||||
if not PVQA_PATH.exists():
|
if not PVQA_PATH.exists():
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue