def admin_cmd_callback(update: Update, context: CallbackContext): query = update.callback_query if query.from_user.id in config.CONFIG['Admin']: msg = "" if query.data == "admin:config": config.set_default() cfg = config.CONFIG.copy() cfg['Token'] = "***" cfg['OWM_key'] = "***" query.answer("获取配置") msg = dumps(cfg, indent=4, ensure_ascii=False) elif query.data == "admin:status": shell = config.CONFIG['Admin_path'] + '/status.sh > /tmp/status.txt' os.system(shell) msg = "反回信息:\n" + open("/tmp/status.txt").read() query.answer("获取状态") elif query.data == "admin:restart": shell = config.CONFIG[ 'Admin_path'] + '/restart.sh > /tmp/restart.txt' os.system(shell) msg = "反回信息:\n" + open("/tmp/restart.txt").read() query.answer("重启服务") elif query.data == "admin:update": shell = config.CONFIG[ 'Admin_path'] + '/update.sh > /tmp/gitpull.txt' os.system(shell) msg = "反回信息:\n" + open("/tmp/gitpull.txt").read() query.answer("更新代码") elif query.data == "admin:help": msg = help() if msg != query.message.text: query.edit_message_text(text=msg, reply_markup=init_replay_markup()) else: query.answer("兄弟,这个按钮你不能按哟", show_alert=True)
def action_ok(self, event): if confirm_dialog(self): selected = [] for element in self.selected_list_model.elements(): selected.append(element) c.set_default('PLUGIN_LIST', selected) c.save() self.dispose()
def set_rotation(self, rotation): platform = self.bookshelf.platform if platform.hasProperty('DISABLE_ROTATION') and platform.getProperty('DISABLE_ROTATION') == 'true': self.menu_item_rotation_0.selected = 1 else: c.set_default('SCREEN_ROTATION', rotation) c.save() self.reconfigure()
def build_widget_configs(widgets, config): for widget in widgets: if _name(widget) not in config: if hasattr(widget, 'default'): set_default(_name(widget), widget.default) config[_name(widget)] = load_text(widget.default)[_name( widget)] # TODO maybe make this better else: set_default(_name(widget), '# No defaults given')
def action_ok(self, event): make_folder = self.make_folder.selected if confirm_dialog(self): c.set_default('MAKE_FOLDER', make_folder) c.set_default('DEFAULT_OPEN_DIRECTORY', self.open_file_dir) c.set_default('DEFAULT_SAVE_DIRECTORY', self.save_file_dir) c.set_default('LOCALE', self.language.get_selection()) c.set_default('MIDLET_LOCALE', self.midlet_language.get_selection()) c.save() self.dispose()
def reconfigure(self): self.bookshelf.configure() if self.bookshelf.platform.hasProperty('DISABLE_ROTATION') and self.bookshelf.platform.getProperty('DISABLE_ROTATION') == 'true': c.set_default('SCREEN_ROTATION', 0) c.save() self.bookshelf.configure() self.set_title() for i in range(self.tabbed_pane.tabCount): bookView = self.tabbed_pane.getComponentAt(i) # re-render every loaded book bookView.action_preview(None)
def set_quit(self): '''退出播放''' self.q = True self.player.quit() subprocess.call('echo -e "\033[?25h";clear', shell=True) logger.debug('Terminal reset.') # store the history of playlist config.set_history(self.history) logger.info('History saved.') # store the token and the default info config.set_default(self._volume, self._channel) logger.info('Settings saved.') sys.exit(0)
def set_quit(self): '''退出播放''' self.q = True self.player.quit() subprocess.call('echo -e "\033[?25h";clear', shell=True) logger.debug('Terminal reset.') try: if self.cover_file is not None: self.cover_file.close() os.rmdir(self._tempdir) logger.debug('Temporary files removed.') except OSError: pass # store the history of playlist config.set_history(self.history) logger.debug('History saved.') # stroe the token and the default info config.set_default(self._volume, self._channel) logger.debug('Settings saved.') sys.exit(0)
def action_ok(self, event): language = self.language.get_selection() encoding = self.encoding.get_selection() para_start = self.para_start.get_selection() if confirm_dialog_no_restart(self): c.set_default('DEFAULT_TEXT_LANGUAGE', language) c.set_default('DEFAULT_TEXT_ENCODING', encoding) c.set_default('DEFAULT_PARAGRAPH_START', para_start) c.save() self.dispose()
def action_ok(self, event): brand = self.brand_list.selectedValue model = self.model_list.selectedValue platform = self.platform_list.selectedValue if confirm_dialog_no_restart(self): c.set_default('PLATFORM_BRAND', brand) c.set_default('PLATFORM_MODEL', model) c.set_default('PLATFORM_JAR', platform) c.save() self.parent.reconfigure() self.dispose()
def action_ok(self, event): font = self.font_name.get_selection() interline = self.interline.get_selection() para_indent = self.para_indent.get_selection() hyphenate = self.hyphenate.selected justify = self.justify.selected screen_border = self.screen_border.selected color_foreground = self.color_foreground.RGB color_background = self.color_background.RGB if confirm_dialog_no_restart(self): c.set_default('DEFAULT_FONT_NAME', font) c.set_default('DEFAULT_INTERLINE_SPACING', interline) c.set_default('DEFAULT_PARAGRAPH_INDENT', para_indent) c.set_default('DEFAULT_HYPHENATE_TEXT', hyphenate) c.set_default('DEFAULT_JUSTIFY_TEXT', justify) c.set_default('DEFAULT_SCREEN_BORDER', screen_border) c.set_default('DEFAULT_COLOR', color_foreground) c.set_default('DEFAULT_BACKGROUND_COLOR', color_background) c.save() self.dispose()
saved_model_file = trainer.model_file del trainer tester = FB15K237Tester(args) tester.set_model(saved_model_file) tester.prepareData() tester.run_link_prediction() sumWriter.close() if __name__ == '__main__': # Parse cmdline args and setup environment parser = argparse.ArgumentParser( 'TransKG framework for training embeddings.', formatter_class=argparse.ArgumentDefaultsHelpFormatter ) add_args(parser) args = parser.parse_args() set_default(args) check_args(args) check_paths(args) # Set cuda args.use_gpu = args.cuda and torch.cuda.is_available() if args.cuda: torch.cuda.set_device(args.gpu) # Set random state np.random.seed(args.random_seed) torch.manual_seed(args.random_seed) if args.cuda: torch.cuda.manual_seed(args.random_seed) # Set logging logger.setLevel(logging.INFO)
try: opts, args = getopt.getopt(sys.argv[1:],"hc:w",["config="]) except getopt.GetoptError: print(help()) sys.exit(2) for opt, arg in opts: if opt == '-h': print(help()) sys.exit() elif opt in ("-c","--config"): PATH = arg config.config_file = os.path.join(PATH,"config.json") try: CONFIG = config.load_config() except FileNotFoundError: print(f"config.json not found.Generate a new configuration file in {config.config_file}" ) config.set_default() sys.exit(2) config.set_default() bot = telegram.Bot(token=config.CONFIG['Token']) for opt, arg in opts: if opt in ("-w"): # 发送天气预报 from mesg import weather weather.sendmsg(bot)
def build_config(config): if 'rss' not in config: set_default('rss', rss.default) config['rss'] = load_text(rss.default)['rss']
def main(): print(config.get_default("connection_pool")) config.set_default(connection_pool=20) print(config.get_default("connection_pool"))