def main(argv=sys.argv): parser = argparse.ArgumentParser( description=DOC, formatter_class=RawTextHelpFormatter) parser.add_argument('action', help='Action to perform.') parser.add_argument('-p', '--path', help='Path where Cozy files will be mounted') parser.add_argument('-u', '--url', help='URL of remote Cozy to sync') parser.add_argument('-n', '--name', help='Name of the device on which action occurs') args = parser.parse_args() if args.action is None: parser.print_help() print('\nYou must specify an action argument\n') sys.exit(2) elif args.action == 'configure': password = retrieve_user_password() try: actions.configure_new_device(args.name, args.url, args.path, password) except Exception, e: print e
def main(argv=sys.argv): parser = argparse.ArgumentParser( description=DOC, formatter_class=RawTextHelpFormatter) parser.add_argument('action', help='Action to perform.') parser.add_argument('-p', '--path', help='Path where Cozy files will be mounted') parser.add_argument('-u', '--url', help='URL of remote Cozy to sync') parser.add_argument('-n', '--name', help='Name of the device on which action occurs') args = parser.parse_args() if args.action is None: parser.print_help() print('\nYou must specify an action argument\n') sys.exit(2) elif args.action == 'configure': actions.configure_new_device(args.name, args.url, args.path) elif args.action == 'remove_configuration': actions.remove_device(args.name) elif args.action == 'sync': actions.sync(args.name) elif args.action == 'mount': actions.mount_folder(args.name) elif args.action == 'unmount': actions.unmount_folder(args.name, args.path) elif args.action == 'reset': actions.reset() elif args.action == 'display_config': actions.display_config() elif args.action == 'kill_running_replications': actions.kill_running_replications() else: parser.print_help() print('\nYou must specify an action argument\n')
def configure(self, name, url, path, password): """ Configure cozy-files name {string}: device name url {string}: cozy url path {string}: local folder to mount password {string}: cozy password """ try: actions.configure_new_device(name, url, path, password) except WrongPassword, e: self._display_error( """The URL and the Cozy's password don't match""" ) return