示例#1
0
文件: ui.py 项目: tryiou/DEXBot
 def new_func(ctx, *args, **kwargs):
     if not os.path.isfile(ctx.obj["configfile"]):
         Config(path=ctx.obj['configfile'])
     ctx.config = yaml.safe_load(open(ctx.obj["configfile"]))
     # reset to default
     ctx.config["node"] = Config().node_list
     if ctx.obj.get("sortnodes"):
         nodelist = sort_nodes(ctx)
         # sort nodes if option is given
         ctx.config["node"] = nodelist
     with open(ctx.obj["configfile"], 'w') as file:
         yaml.dump(ctx.config, file, default_flow_style=False)
     return ctx.invoke(f, *args, **kwargs)
示例#2
0
    def validate_account_not_in_use(account):
        """ Check whether account is already used for another worker or not

            :param str account: bitshares account name
        """
        workers = Config().workers_data
        for worker_name, worker in workers.items():
            if worker['account'] == account:
                return False
        return True
示例#3
0
    def validate_worker_name(worker_name, old_worker_name=None):
        """ Check whether worker name is unique or not

            :param str worker_name: name of the new worker
            :param str old_worker_name: old name of the worker
        """
        if old_worker_name != worker_name:
            worker_names = Config().workers_data.keys()
            # Check that the name is unique
            if worker_name in worker_names:
                return False
            return True
        return True
示例#4
0
def configure(ctx):
    """Interactively configure dexbot."""
    # Make sure the dexbot service isn't running while we do the config edits
    if dexbot_service_running():
        click.echo("Stopping dexbot daemon")
        os.system('systemctl --user stop dexbot')

    config = Config(path=ctx.obj['configfile'])
    configure_dexbot(config, ctx)
    config.save_config()

    click.echo("New configuration saved")
    if config.get('systemd_status', 'disabled') == 'enabled':
        click.echo("Starting dexbot daemon")
        os.system("systemctl --user start dexbot")
示例#5
0
文件: cli.py 项目: lafona/DEXBot
def configure(ctx):
    """ Interactively configure dexbot
    """
    config = Config(path=ctx.obj['configfile'])
    if configure_dexbot(config):
        if config['systemd_status'] == 'installed':
            # we are already installed
            config.save_config()
            os.system("systemctl --user restart dexbot")
        if config['systemd_status'] == 'install':
            config['systemd_status'] = 'installed'
            config.save_config()
            os.system("systemctl --user enable dexbot")
            os.system("systemctl --user start dexbot")
        click.echo("New configuration saved")
示例#6
0
文件: cli.py 项目: lafona/DEXBot
def shell():
    """ Run dexbot as a shell
    """
    config = Config()
    while True:
        if configure_dexbot(config, True):
            if config['systemd_status'] == 'installed':
                config.save_config()
                # we are already installed
                os.system("systemctl --user restart dexbot")
            if config['systemd_status'] == 'install':
                config['systemd_status'] = 'installed'
                config.save_config()
                os.system("systemctl --user enable dexbot")
                os.system("systemctl --user start dexbot")