# Required definition.add_required("local_path", "string", "path or name of the file or directory to send") definition.add_required("remote", "string", "the remote host to send to", choices=find_host_ids()) # Remote path definition.add_positional_optional("remote_path", "string", "path of the remote directory to send to") # Create configuration config = parse_arguments("send", definition, "Send a file or directory to a remote host") # ----------------------------------------------------------------- # Create remote remote = Remote(host_id=config.remote) # ----------------------------------------------------------------- # Set full path of origin origin = fs.absolute_or_in_cwd(config.local_path) name = fs.name(origin) # Set full path to the destination if config.remote_path is None: destination = fs.join(remote.home_directory, name) else: destination = remote.absolute_path(config.remote_path) # Upload remote.upload(origin, destination) # -----------------------------------------------------------------
definition = ConfigurationDefinition() definition.add_required("remote_path", "string", "remote path of the file or directory to retrieve") definition.add_required("remote", "string", "remote host to retrieve from", choices=find_host_ids()) definition.add_optional("local_path", "string", "path of the local directory to store the file/directory") config = parse_arguments("retrieve", definition) # ----------------------------------------------------------------- # Create remote remote = Remote(host_id=config.remote) # ----------------------------------------------------------------- # Set full path of origin origin = remote.absolute_path(config.remote_path) # Set full path to the destination if config.local_path is not None: destination = fs.absolute_or_in_cwd(config.local_path) else: destination = fs.cwd() # ----------------------------------------------------------------- # Debugging log.debug("Origin: " + origin) log.debug("Destination: " + destination) # Upload remote.download(origin, destination) # -----------------------------------------------------------------
# Create the configuration definition definition = ConfigurationDefinition() definition.add_required("remote", "string", "remote host", choices=find_host_ids()) definition.add_required("filename", "string", "file name (or path)") # Read the command line arguments config = parse_arguments("open", definition, description="Open a file on a remote host") # ----------------------------------------------------------------- # Connect to remote remote = Remote() remote.setup(config.remote) # Determine the absolute file path filepath = remote.absolute_path(config.filename) # Determine the file path relative to the home directory relative_filepath = remote.relative_to_home(filepath) # Check if the file exists; otherwise don't bother mounting if not remote.is_file(filepath): log.error("The file does not exist") exit() # Disconnect the remote remote.logout() # ----------------------------------------------------------------- # Create the mounter
# Local path definition.add_positional_optional("local_path", "string", "path of the local directory to store the file/directory") # Create configuration config = parse_arguments("retrieve", definition, "Retrieve a file or directory from a remote host") # ----------------------------------------------------------------- # Create remote remote = Remote(host_id=config.remote) # ----------------------------------------------------------------- # Set full path of origin origin = remote.absolute_path(config.remote_path) # Set full path to the destination if config.local_path is not None: destination = fs.absolute_or_in_cwd(config.local_path) else: destination = fs.cwd() # ----------------------------------------------------------------- # Debugging log.debug("Origin: " + origin) log.debug("Destination: " + destination) # Upload remote.download(origin, destination) # -----------------------------------------------------------------
definition = ConfigurationDefinition() definition.add_required("local_path", "string", "path or name of the file or directory to send") definition.add_required("remote", "string", "the remote host to send to", choices=find_host_ids()) definition.add_optional("remote_path", "string", "path of the remote directory to send to") config = parse_arguments("send", definition) # ----------------------------------------------------------------- # Create remote remote = Remote(host_id=config.remote) # ----------------------------------------------------------------- # Set full path of origin origin = fs.absolute_or_in_cwd(config.local_path) name = fs.name(origin) # Set full path to the destination if config.path is not None: destination = fs.join(remote.home_directory, name) else: destination = remote.absolute_path(config.remote_path) # Upload remote.upload(origin, destination) # -----------------------------------------------------------------