def settings(): if request.method == 'POST': rpc_settings = dict(request.form) if test_rpc(rpc_settings): update_settings(rpc_settings) flash_success('Settings updated') return redirect(url_for('wallet')) else: flash_error('Invalid settings') return redirect(url_for('settings')) else: settings = get_settings() return render_template("settings.html", settings=settings)
def __init__(self, parent, settings): self.ship_id = None self.parent = parent if settings is not None: self.settings = settings else: self.settings = utils.update_settings(self._render_config_dialog, self.settings) self.frame = tk.Frame(parent) self.frame.pack(expand=True, fill=tk.BOTH) self.message = tk.StringVar() self.message.set("Click Update to update!") message_label = tk.Label(self.frame, textvariable=self.message) message_label.pack(fill=tk.X) self.info = InfoFrame(self.frame) self.info.pack(fill=tk.X, expand=True, pady=10) button_row = tk.Frame(self.frame) button_row.pack() self.update_button = tk.Button(button_row, text="Update", command=self._update_inara) self.update_button.pack(side=tk.LEFT, expand=True) self.ship_button = tk.Button(button_row, text="Name Ship", command=self._update_ship_dialog) self.ship_button.pack(side=tk.LEFT) self.ship_button['state'] = tk.DISABLED config_button = tk.Button(button_row, text="Config", command=self._update_settings) config_button.pack(side=tk.LEFT) self._try_login()
def settings(): if request.method == 'POST': rpc_settings = request.form.to_dict() try: test_rpc(rpc_settings) update_settings(rpc_settings) flash_success('Settings updated') return redirect(url_for('wallet')) except JunctionWarning as jw: update_settings(rpc_settings) flash_success('Settings Updated but: {}'.format(jw)) return redirect(url_for('settings')) except JunctionError as je: flash_error('Error: {}'.format(je)) return redirect(url_for('settings')) else: settings = get_settings() return render_template("settings.html", settings=settings)
def main(): global logging parser = argparse.ArgumentParser() parser.add_argument("-c", default="dopey.yaml", help="yaml config file") parser.add_argument("--eshost", default="", help="eshost here will overwrite that in config file") parser.add_argument( "--base-day", default="0", help= "number 0(today), 1(tommorow), -1(yestoday), or string line 2011-11-11" ) parser.add_argument( "--action-filters", default="", help= "comma splited. d:delete, c:close, u:update settings, f:forcemerge, fr:freeze. \ leaving blank means do all the actions configuared in config file") parser.add_argument("-l", default="-", help="log file") parser.add_argument("--level", default="info") args = parser.parse_args() global config config = yaml.load(open(args.c)) if args.eshost: config['eshost'] = args.eshost initlog(level=args.level, log=config["l"] if "log" in config else args.l) all_indices = utils.get_indices(config['eshost']) logging.debug(u"all_indices: {}".format(all_indices)) for action in config.get("setup", []): settings = action.values()[0] eval(action.keys()[0])(settings) base_day = _get_base_day(args.base_day) logging.info("base day is %s" % base_day) action_filters = _get_action_filters(args.action_filters) if 'delete_indices' in action_filters: to_delete_indices = utils.get_to_delete_indices( config, all_indices, base_day) logging.info('try to delete `{}`'.format(' '.join( e[0] for e in to_delete_indices))) utils.delete_indices(config, to_delete_indices) if 'close_indices' in action_filters: to_close_indices = utils.get_to_close_indices(config, all_indices, base_day) logging.info('try to close `{}`'.format(' '.join( e[0] for e in to_close_indices))) utils.close_indices(config, to_close_indices) if 'freeze_indices' in action_filters: to_freeze_indices = utils.get_to_freeze_indices( config, all_indices, base_day) logging.info('try to freeze `{}`'.format(' '.join( e[0] for e in to_freeze_indices))) utils.freeze_indices(config, to_freeze_indices) if 'update_settings' in action_filters: to_update_indices = utils.get_to_update_indices( config, all_indices, base_day) logging.info('(before settings diff filter)try to update `{}`'.format( ' '.join(e[0] for e in to_update_indices))) utils.update_settings(config, to_update_indices) if 'optimize_indices' in action_filters: to_optimize_indices = utils.get_to_optimize_indices( config, all_indices, base_day) logging.info('try to forcemerge `{}`'.format(' '.join( e[0] for e in to_optimize_indices))) utils.optimize_indices(config, to_optimize_indices) # dopey_summary.add( # u"未处理:\n{}\n删除:\n{}\n关闭:\n{}\n优化:{}\n更新索配置:{}".format( # "\n".join(sorted(not_dealt)), # "\n".join(sorted(_delete)), # "\n".join(sorted(_close)), # "\n".join(sorted(_optimize)), # "\n".join(sorted(_update_settings)))) for action in config.get("teardown", []): settings = action.values()[0] eval(action.keys()[0])(settings) sumary_config = config.get("sumary") for action, kargs in sumary_config.items(): if kargs: getattr(dopey_summary, action)(**kargs) else: getattr(dopey_summary, action)()
def _update_settings(self): self.settings = utils.update_settings(self._render_config_dialog, self.settings) self._try_login()