Skip to content

Commit

Permalink
Fix CLI worker deletion
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvai committed Jun 20, 2018
1 parent 4947aee commit 9a47386
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dexbot/basestrategy.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,8 +496,8 @@ def calculate_order_data(self, order, amount, price):
def purge(self):
""" Clear all the worker data from the database and cancel all orders
"""
self.cancel_all()
self.clear_orders()
self.cancel_all()
self.clear()

@staticmethod
Expand Down
5 changes: 4 additions & 1 deletion dexbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ def run(ctx):

@main.command()
@click.pass_context
@configfile
@chain
@unlock
def configure(ctx):
""" Interactively configure dexbot
"""
Expand All @@ -117,7 +120,7 @@ def configure(ctx):
os.system('systemctl --user stop dexbot')

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

click.echo("New configuration saved")
Expand Down
8 changes: 5 additions & 3 deletions dexbot/cli_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def configure_worker(d, worker):
return worker


def configure_dexbot(config):
def configure_dexbot(config, ctx):
d = get_whiptail()
workers = config.get('workers', {})
if not workers:
Expand All @@ -190,21 +190,23 @@ def configure_dexbot(config):
break
setup_systemd(d, config)
else:
bitshares_instance = ctx.bitshares
action = d.menu("You have an existing configuration.\nSelect an action:",
[('NEW', 'Create a new worker'),
('DEL', 'Delete a worker'),
('EDIT', 'Edit a worker'),
('CONF', 'Redo general config')])

if action == 'EDIT':
worker_name = d.menu("Select worker to edit", [(i, i) for i in workers])
config['workers'][worker_name] = configure_worker(d, config['workers'][worker_name])
bitshares_instance = BitShares(config['node'])

strategy = BaseStrategy(worker_name, bitshares_instance=bitshares_instance)
strategy.purge()
elif action == 'DEL':
worker_name = d.menu("Select worker to delete", [(i, i) for i in workers])
del config['workers'][worker_name]
bitshares_instance = BitShares(config['node'])

strategy = BaseStrategy(worker_name, bitshares_instance=bitshares_instance)
strategy.purge()
elif action == 'NEW':
Expand Down

0 comments on commit 9a47386

Please sign in to comment.