- add missed module
This commit is contained in:
parent
60a24a5177
commit
90c88c2aa4
|
|
@ -0,0 +1,128 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
from pathlib import Path
|
||||
import argparse
|
||||
import sys
|
||||
import yaml
|
||||
|
||||
class AgentConfig:
|
||||
Name: str
|
||||
Backend: str
|
||||
|
||||
# Name of intermediary file with audio recorded from the GSM phone
|
||||
RecordFile = Path('/dev/shm/qualtest_recorded.wav')
|
||||
|
||||
# Prepared reference audio to play
|
||||
PreparedReferenceAudio = Path('/dev/shm/reference_ready.wav')
|
||||
|
||||
# Reference audio to play
|
||||
ReferenceAudio = Path('/dev/shm/reference_original.wav')
|
||||
|
||||
# Loaded reference audio (from backend)
|
||||
LoadedAudio = Path('/dev/shm/loaded_audio.wav')
|
||||
|
||||
# Script to exec after mobile call answering
|
||||
ExecScript : Path = None
|
||||
|
||||
# Backup directory (to run without internet)
|
||||
CacheDir : Path = None
|
||||
|
||||
# PID file name
|
||||
QualtestPID = Path('/dev/shm/qualtest.pid')
|
||||
|
||||
# Check (or not) PID file presence on the start
|
||||
CheckPIDFile: bool = False
|
||||
|
||||
# Should the first task run immediately ?
|
||||
ForceRun = False
|
||||
|
||||
# Use silence eraser or not (speech detector is used in this case)
|
||||
UseSilenceEraser = True
|
||||
|
||||
# Path to log file
|
||||
LogPath : Path = None
|
||||
|
||||
# Phone's BT MAC address
|
||||
BT_MAC : str = None
|
||||
|
||||
# Verbose logging or not
|
||||
Verbose: bool = False
|
||||
|
||||
# Task limit per single run
|
||||
TaskLimit: int = 10000000
|
||||
|
||||
# Task name (used for answering only)
|
||||
TaskName: str = None
|
||||
|
||||
def parser(self) -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--config", help="Path to config file, see config.in.yaml.")
|
||||
parser.add_argument("--check-pid-file", action="store_true", help="Check if .pid file exists and exit if yes. Useful for using with .service files")
|
||||
parser.add_argument("--test", action="store_true", help="Run the first task immediately. Useful for testing.")
|
||||
|
||||
return parser
|
||||
|
||||
|
||||
def __init__(self) -> None:
|
||||
p = self.parser()
|
||||
|
||||
# Parse arguments
|
||||
args = p.parse_args()
|
||||
|
||||
if args.test:
|
||||
self.ForceRun = True
|
||||
|
||||
if args.check_pid_file:
|
||||
self.CheckPIDFile = True
|
||||
|
||||
if args.config:
|
||||
config_path = args.config
|
||||
|
||||
with open(config_path, 'r') as stream:
|
||||
config = yaml.safe_load(stream)
|
||||
|
||||
if config['force_task']:
|
||||
self.ForceRun = True
|
||||
|
||||
if 'speech_detector' in config:
|
||||
if config['speech_detector']:
|
||||
self.UseSilenceEraser = False
|
||||
|
||||
if 'bluetooth_mac' in config['audio']:
|
||||
self.BT_MAC = config['audio']['bluetooth_mac']
|
||||
|
||||
|
||||
# Logging settings
|
||||
if 'log' in config:
|
||||
if 'verbose' in config['log']:
|
||||
self.Verbose = config['log']['verbose']
|
||||
|
||||
if 'path' in config['log']:
|
||||
path = config['log']['path']
|
||||
if len(path) > 0:
|
||||
path = Path(path)
|
||||
if not path.is_absolute():
|
||||
path = Path(__file__).parent.parent / path
|
||||
|
||||
self.LogPath = path
|
||||
|
||||
|
||||
# Audio directories
|
||||
if 'cache_dir' in config:
|
||||
self.CacheDir = Path(config['cache_dir'])
|
||||
if not self.CacheDir.is_absolute():
|
||||
self.CacheDir = Path(__file__).parent.parent / config['cache_dir']
|
||||
|
||||
if 'task_limit' in config:
|
||||
self.TaskLimit = int(config['task_limit'])
|
||||
|
||||
if 'name' in config:
|
||||
self.Name = config['name']
|
||||
|
||||
if 'backend' in config:
|
||||
self.Backend = config['backend']
|
||||
|
||||
if 'task' in config:
|
||||
self.TaskName = config['task']
|
||||
|
||||
|
||||
Loading…
Reference in New Issue