def attribute_init(self): self.device_choice_ui = None self.create_scene_view = None self.a2dp_mac = None default_config = read_config(constant.CONFIG_FILE) self.channel_switch_interval = default_config['scene_tv']['channel_switch_interval']['val']*3600 self.performance_interval = default_config['scene_tv']['performance_interval']['val']*3600 self.performance_str = '' self.check_interval = default_config['scene_tv']['check_interval']['val']*3600
def remove_scene(index: int) -> bool: """ 通过索引移除场景 :param index: :return: """ scenes = config_utils.read_config(constant.SCENE_FILE) if 0 <= index < len(scenes): scenes.pop(index) config_utils.write_config(constant.SCENE_FILE, scenes) return True return False
def run(config, epochs, n_workers=1, resume=False, updates=None, verbose=1): """Main runner that dynamically imports and executes other modules """ device = torch.device("cuda" if torch.cuda.is_available() else "cpu") cfg = config_utils.read_config(config) if updates is not None: cfg = config_utils.update_config(cfg, updates) log_utils.print_experiment_info(cfg['experiment'], cfg['out_dir']) tensorboard_logdir, checkpoints_logdir = \ log_utils.prepare_dirs(cfg['experiment'], cfg['out_dir'], resume) train_loaders, test_loaders = import_data_loaders(cfg, n_workers, verbose) model, model_manager = import_models(cfg, checkpoints_logdir, device, verbose) losses, metrics = import_losses_and_metrics(cfg) tensorboard_writer = SummaryWriter(tensorboard_logdir) trainer_def = trainers.load_trainer(cfg['trainer']['name']) trainer = trainer_def(device=device, model=model, losses=losses, metrics=metrics, train_loaders=train_loaders, test_loaders=test_loaders, model_manager=model_manager, tensorboard_writer=tensorboard_writer, **cfg['trainer']['kwargs']) starting_epoch = model_manager.last_epoch + 1 last_epoch = starting_epoch for epoch in range(starting_epoch, starting_epoch + epochs): eval_losses, eval_metrics = trainer.run_epoch(epoch) last_epoch += 1 if 'saving_freq' in cfg: if (epoch + 1) % cfg['saving_freq'] == 0: model_manager.save_model(model, eval_losses, epoch) if trainer.early_stop(): log_utils.print_early_stopping() break unzip(hydra=model, losses=losses, metrics=metrics, loaders=train_loaders, device=device, from_epoch=last_epoch) tensorboard_writer.close()
def _parse_profile(self) -> dict: """ 解析默认逻辑monkey的配置文件 :return: """ ret = {} settings = config_utils.read_config(self.profile) packages = self.device.tv.send_cmd_get_result( 'pm list packages | busybox awk -F ":" \'{print $2}\'') packages = packages.split('\r\n') for key, value in settings.items(): if key in packages: ret[key] = value return ret
def __init__(self, brand_list: list, interval: int, device: dv.Device, local_video: dict, profile: str, mpf: pf.Performance): super(MediaBrandSwitchThread, self).__init__() self.brand_list = brand_list self.interval = interval self.device = device self.cur_brand = '' self.local_video = local_video self.pf = mpf self.settings = config_utils.read_config(profile) logging.debug(f'brand_list {self.brand_list}\n' f'interval {self.interval}\n' f'local_video {self.local_video}\n' f'settings {self.settings}') if len(brand_list) < 1: raise ValueError('brand list must not null')
def __init__(self): super(Ui_MainWindow, self).__init__() self.setupUi(self) self.setWindowFlags(Qt.WindowCloseButtonHint) self.setFixedSize(self.width(), self.height()) self.default_config = read_config(constant.CONFIG_FILE) self.videomode = None self.attribute_init() self.online_list = [ self.checkBox, self.checkBox_2, self.checkBox_3, self.checkBox_4, self.checkBox_8, self.checkBox_9, self.checkBox_10, self.checkBox_11, self.checkBox_12, self.checkBox_14, self.checkBox_17, self.checkBox_15, self.checkBox_20, self.checkBox_18 ] self.online_dict = { "腾讯视频": False, "爱奇艺": False, "酷喵": False, "QQ音乐MV": False, "QQ音乐": False, "HDP": False, "电视家": False, "本地视频_大码率": False, "信源": False, "本地视频_混合编解码": False, "遥控器是否回连成功": False, "近场唤醒是否成功": False, "蓝牙音箱是否回连成功": False, "远场唤醒是否成功": False } self.to_screen_list = [ self.checkBox_19, self.checkBox_22, self.checkBox_23, self.checkBox_21, self.checkBox_16, self.checkBox_31, self.checkBox_32 ] self.to_screen_dict = { "乐播投屏": False, "dlna投屏": False, "miracast(无线投屏)": False, "遥控器是否回连成功 ": False, "近场唤醒是否成功": False, "蓝牙音箱是否回连成功": False, "远场唤醒是否成功": False } self.buttton_init()
def create_kk_record_scene(): """ 创建脚本录制场景 :return: """ try: directory, exe = _init() except BaseException as e: logging.exception(e) return False, str(e) scene_file = os.path.join(directory, 'src', 'scene') file_utils.rm(scene_file) cmd = exe + ' -c' _run_cmd(cmd) if not os.path.isfile(scene_file): return False, f'录制脚本场景创建失败, 未发现文件:{scene_file}' return True, config_utils.read_config(scene_file)
def __init__(self, name: str, exec_time: int, checker: ck.Checker, scripts: (list, str), by: int = sc.BY_COUNT): sc.Scene.__init__(self, name=name, exec_time=exec_time, by=by, checker=checker) if isinstance(scripts, list): self.scripts = scripts elif isinstance(scripts, str): if not os.path.isfile(scripts): raise AssertionError(f'illegal scripts : {scripts}') self.scripts = config_utils.read_config(scripts) else: raise AssertionError(f'illegal scripts : {scripts}')
def __init__(self): super(Ui_MainWindow, self).__init__() self.setupUi(self) self.setWindowFlags(Qt.WindowCloseButtonHint) self.setFixedSize(self.width(), self.height()) self.default_config = read_config(constant.CONFIG_FILE) self.mode = 0 self.attribute_init() self.monkeyGlobal_list = [ self.checkBox_23, self.checkBox_18, self.checkBox_15, self.checkBox_24, self.checkBox_16, self.checkBox_21, self.checkBox_20 ] self.monkeyGlobal_dict = { "远场唤醒是否成功": False, "网络连接是否正常": False, "近场唤醒是否成功": False, "蓝牙音箱是否回连成功": False, "USB挂载正常,U盘个数:": False, "摄像头是否正常": False, "遥控器是否回连成功": False } self.monkeyLogic_list = [ self.checkBox_19, self.checkBox_17, self.checkBox_22, self.checkBox_35, self.checkBox_36, self.checkBox_37, self.checkBox_38 ] self.monkeyLogic_dict = { "近场语音是否唤醒正常": False, "网络连接是否正常": False, "远场语音是否唤醒正常": False, "摄像头是否正常": False, "蓝牙遥控器是否回连成功": False, "蓝牙音箱是否回连成功": False, "USB挂载正常,U盘个数:": False } self.buttton_init()
from pathlib import Path import pandas as pd from utils import config_utils config_path = "./config.yaml" config = config_utils.read_config(config_path) def merge_date_data(): train_path = Path(config["datas"]["train_path"]) for date_path in train_path.glob("*"): df_non_ts = pd.read_csv(date_path / "non_ts.csv", index_col="id") df_y = pd.read_csv(date_path / "y.csv") merge_df = pd.merge(df_non_ts, df_y, on="id") for ts_path in date_path.glob("ts_*.csv"): ts_name = ts_path.name.split(".csv")[0] df_ts = pd.read_csv(ts_path, index_col="id") df_ts_std = get_std(df_ts, ts_name) merge_df = pd.merge(merge_df, df_ts_std, on="id") df_ts_mean_0_5 = get_mean_0_5(df_ts, ts_name) merge_df = pd.merge(merge_df, df_ts_mean_0_5, on="id") df_ts_mean_0_20 = get_mean_0_20(df_ts, ts_name) merge_df = pd.merge(merge_df, df_ts_mean_0_20, on="id") print(merge_df.head())
def scene_list(): """ 获取场景列表 :return: """ return config_utils.read_config(constant.SCENE_FILE)
def setUp(self): self.config = config_utils.read_config("./config.yaml") self.test_df = pd.read_csv(self.config["datas"]["origin_train_path"] + "/20130201/non_ts.csv", index_col="id") self.du = data_utils.DataUtils(self.config)
from utils import log from model.main_test_1 import Entrance_View import sys from PyQt5 import QtWidgets from utils.config_utils import read_config import constant if __name__ == '__main__': log_dir = read_config(constant.CONFIG_FILE)['tool_config']['log_dir'] output = True if read_config( constant.CONFIG_FILE)['tool_config']['output'] == 'True' else False log.init_logging_dir(log_dir, output=output) app = QtWidgets.QApplication(sys.argv) # 外部参数列表 ui = Entrance_View() ui.show() sys.exit(app.exec_())