def _main(ctx, username, key, working_dir): client = NutStoreClient(username=username, password=key, working_dir=to_str(working_dir), check_conn=False) output.debug('Try to initial a client by given args') try: client.check_conn() except Exception as e: import traceback output.error('Login failed, detail: {0}\n'.format( save_text(traceback.format_exc()))) import sys sys.exit(-1) else: ctx.obj['client'] = client
def visit_download(self, node, children): cloud_path = children[2].text store_path = children[4].text if len(node.children) == 5 else None dest = self.context.client.download(to_str(cloud_path), to_str(store_path)) output.echo(dest)
def visit_cd(self, node, children): path = children[3].text self.context.client.cd(to_str(path))
def visit_rm(self, node, children): cloud_path = to_str(children[2].text) if click.confirm('rm {}?'.format(cloud_path)): self.context.client.rm(cloud_path)
def visit_upload(self, node, children): local_path = to_str(children[2].text) remote_path = self.context.client.upload(local_path) output.echo(remote_path)
def download(ctx, remote_path, local_path): output.echo(ctx.obj['client'].download(to_str(remote_path), to_str(local_path)))
def upload(ctx, local_path, remote_dir): output.echo(ctx.obj['client'].upload(to_str(local_path), to_str(remote_dir)))