def initialize_app(): # check for config dir if os.path.exists(pcgl.get_config_root()): cfg_success, cfg = load_cfg(pcgl.get_config_root()) else: os.makedirs(os.path.join(pcgl.get_config_root(), 'etc'), exist_ok=True) cfg_success = False cfg = None # if config not read, need to seed config dir with initial config files if not cfg_success: # get ird of any existing config dir and re-init from app bundle if os.path.exists(pcgl.get_config_root()): shutil.rmtree(pcgl.get_config_root()) # copy from internal config shutil.copytree(pcgl.get_initial_config_root(), pcgl.get_config_root()) cfg_success, cfg = load_cfg(pcgl.get_config_root()) # make sure there exists a results dir os.makedirs(os.path.join(pcgl.get_root(), 'Results'), exist_ok=True) # make sure the UserGuide is in ~/PyCal if os.path.exists(os.path.join(pcgl.get_root(), 'PyCal_User_Guide.pdf')): logging.debug('User Guide in place') else: logging.debug('Copying User Guide to user area') shutil.copy2(os.path.join(pcgl.get_data_root(), pcgl.user_guide_filename()), os.path.join(pcgl.get_root(), pcgl.user_guide_filename())) return cfg_success, cfg
def exec(self): self.qVerifyThread = QVerifyThread(self.cfg.data[WrapperCfg.WRAPPER_KEY_IP], self.cfg.data[WrapperCfg.WRAPPER_KEY_DATAPORT], pcgl.get_bin_root(), pcgl.get_config_root()) self.qVerifyThread.qVerifyQueryResult.connect(self.qVerify_query_result_slot) self.qVerifyThread.start() self.dlgUI.connMsgsEdit.setStyleSheet("QLabel{color:rgb(200, 120, 20);}") self.dlgUI.connMsgsEdit.setPlainText('Connecting to Q330 at {}...'.format(self.cfg.data[WrapperCfg.WRAPPER_KEY_IP])) QTimer.singleShot(30000, self.timeout) return self.qtDlg.exec()