def hlp(self, cmds): if len(cmds) == 1: print(help.help()) elif len(cmds) == 2: print(help.helping([cmds[1]])) else: print(error.get(cmds, 'warning')) print(help.helping(cmds))
def mv(self, cmds): if len(cmds) == 3: self.executions.copy_within_filesystem(cmds[1], cmds[2], keep=False) else: print(help.helping(cmds))
def cp(self, cmds): if len(cmds) == 3: return self.executions.copy_within_filesystem(cmds[1], cmds[2], keep=True) else: print(help.helping(cmds))
def cd(self, cmds): if len(cmds) == 2: try: self.executions.change_directory(cmds[1]) except: print(error.get(cmds, 'error')) else: print(help.helping(cmds))
def mk(self, cmds): if len(cmds) == 2: if "." not in cmds[1]: self.executions.make_directory(cmds[1]) else: print(error.get(cmds, 'file_error')) else: print(help.helping(cmds))
def rm(self, cmds, unmuted=None): if len(cmds) == 2: files = self.executions.remove_object(cmds[1]) if files: for file in files: self.unionpath.edit_dictionary(file, 'del') else: print(help.helping(cmds))
def reg(self, cmds): if len(cmds) == 3: if re.match("^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$", cmds[1]): self.executions.register_to_server(cmds[1], cmds[2]) return "reg" else: print(color.yellow("{} is not a valid IP-address.".format(cmds[1]))) else: print(help.helping(cmds))
def rm(self, cmds): if len(cmds) == 2: files, filehashes = self.executions.remove_object(cmds[1]) if files: for file in files: self.unionpath.edit_dictionary(file, 'del') print("result length: {}".format(len(["rm", filehashes]))) return "rm", filehashes else: print(help.helping(cmds))
def mount(self, cmds): if len(cmds) == 2: while True: response = input(color.yellow("Do you want to upload or download a partition? [u/d/stop] -> ")).lower() if response == "d" or response == "download": return self.executions.download_mount_partition(cmds[1]) elif response == "u" or response == "upload": return self.executions.upload_mount_partition(cmds[1]) elif response == "stop": return elif len(cmds) == 3: response = cmds[2] if response == "d" or response == "download": return self.executions.download_mount_partition(cmds[1]) elif response == "u" or response == "upload": return self.executions.upload_mount_partition(cmds[1]) else: print(help.helping(cmds)) else: print(help.helping(cmds))
def ls(self, cmds): if len(cmds) == 1: if "+" in cmds[0]: additional = True else: additional = False files = help_functions.get_files_from_current_dir(self.unionpath) # "ls" else: # error: too many arguments given print(help.helping(cmds)) return if files: #if files has ben set, it went trough sucessfully and can be printed if len(files) > 20: #if there are more than 20 files to display: ask i = input("would you like to display all ({}) entries? [y/n]: ".format(len(files))).lower() if i == 'y': self.executions.list_folder_content(files, True, additional=additional) else: self.executions.list_folder_content(files, additional=additional)
def ls(self, cmds): if len(cmds) == 1: if "+" in cmds[0]: additional = True else: additional = False files = help_functions.get_files_from_current_dir(self.unionpath) else: print(help.helping(cmds)) return if files: if len(files) > 20: i = input( "would you like to display all ({}) entries? [y/n]: ". format(len(files))).lower() if i == 'y': self.executions.list_folder_content(files, True, additional=additional) else: self.executions.list_folder_content(files, additional=additional)
def add(self, cmds, unmuted=None): if len(cmds) < 2 or len(cmds) > 3: if not unmuted: print(help.helping(cmds)) return if self.unionpath.filesystem_root_dir in cmds[1]: print(error.get(cmds, 'fs_error')) return if len(cmds) == 2: source = cmds[1] destination = None else: source = cmds[1] destination = cmds[2] if os.path.isdir(source): self.executions.add_directory_to_filesystem(source, destination) elif os.path.isfile(source): self.executions.add_file_to_filesystem(source, destination) else: print(error.get(cmds, 'path_error')) return
def open(self, cmds): if len(cmds) == 2: self.executions.open_file(cmds[1]) else: print(help.helping(cmds))
def srv(self, cmds): if len(cmds) == 1: self.executions.show_registered_servers() else: print(help.helping(cmds))
def con(self, cmds): if len(cmds) == 2: self.executions.connect_to_server(cmds[1]) else: print(help.helping(cmds))
def clear(self, cmds): if len(cmds) == 1: self.executions.clear_terminal() else: print(help.helping(cmds))
def rn(self, cmds): if len(cmds) == 3: self.executions.rename_object(cmds[1], cmds[2]) else: print(help.helping(cmds))