def _process_listdir(self): """ Lists the content of a directory and returns it to the command listener, either including or not the file sizes. Syntax: LISTDIR <size> <path> size: Indicates if the returned list should containg the size or not. 0 indicates no, 1 indicates yes. path: The path to the file or folder that will be listed. """ include_size, path = self._args.split(' ', 1) include_size = (include_size == '1') FileUtils.list_dir(path, include_size, self._send_to_listener)
def _process_copy_file(self): files = self._args.split('>') if len(files) < 2: raise RuntimeError('Invalid call to the COPY_FILE command') src = files[0] tgt = files[1] tgt_backup = "" if len(files) > 2: tgt_backup = files[2] src.strip() tgt.strip() tgt_backup.strip() FileUtils.copy_file(src, tgt, tgt_backup)
def _process_remove_directory_recursive(self): FileUtils.remove_directory_recursive(self._args)
def _process_create_directory_recursive(self): FileUtils.create_directory_recursive(self._args)
def _process_create_directory(self): FileUtils.create_directory(self._args)
def _process_check_path_exists(self): self._client.send(str(FileUtils.check_path_exists(self._args)))
def _process_check_dir_writable(self): self._client.send(str(FileUtils.check_dir_writable(self._args)))
def _process_get_free_space(self): free_space = FileUtils.get_free_space(self._args) self._client.send(str(free_space))
def _process_get_file_owner(self): self._client.send(str(FileUtils.get_file_owner(self._args)))
def _process_delete_file(self): FileUtils.delete_file(self._args)
def _process_getfile_lines(self): #GETFILE_LINES <skip> <path> skip, path = self._args.split(' ', 1) skip = int(skip) FileUtils.get_file_lines(path, skip, self._send_to_listener)