def _on_cmd_login(self, usr, psw, act): try: get_ftp().login(usr, psw, act) root_dir = get_ftp().print_current_dir() root_fn = FileNode(name=root_dir, type=FILE_TYPE_DIR) get_directory_tree().set_root(root_fn) except Exception: return "Login failed"
def expand_node(self, node): dir_tuple = node.get_dir_tuple() node.set_expanded() import os path = os.path.join(*dir_tuple) for line in get_ftp().list_dir(path).split("\n"): if not line: continue fn = filenode_new_from_line(line) self.append_child_fn(fn, node=node)
def set_root(self, root_fn): if self._root.get_n_children(): self.emit("rf-directory-tree-remove-node", tree_dir_path_to_string( self._root.get_nth_child(0).get_path_tuple() )) root = DirectoryTreeNode(root_fn, self._root) self._root.child_list = [root] self.set_cur_node(root) self.emit("rf-directory-tree-add-node", tree_dir_path_to_string(root.get_path_tuple())) self.get_cur_node().set_expanded() for line in get_ftp().list_current_dir().split("\n"): if not line: continue fn = filenode_new_from_line(line) self.append_child_fn(fn)
def __init__(self): gobject.GObject.__init__(self) self.ftp = get_ftp() self.win = get_window() self._load_up_menubar() self._load_up_file_view() self._load_up_directory_view() self._load_up_console_view() self._load_up_resp_bar() self._set_up_layout() self.dir_tree = get_directory_tree() # Connect signals self.win.connect("destroy", lambda w: self.exit()) self.ftp.connect("rf-ftp-response", self._on_ftp_response) self.ftp.connect("rf-ftp-send-cmd", self._on_ftp_send_cmd) self.win.show()
def _on_cmd_pwd(self): return get_ftp().print_current_dir()
def _on_cmd_connect(self, host, port): if port: get_ftp().connect_to_host(host, port) else: get_ftp().connect_to_host(host)
def _on_cmd_ls(self): return get_ftp().list_current_dir()
def _func(self, *args, **kwargs): if get_ftp().is_login(): return func(self, *args, **kwargs) return "Must login in first!"
def set_cur_node(self, node): self.cur_node = node get_ftp().change_dir(dir_tuple_to_path(node.get_dir_tuple())) self.emit("rf-directory-tree-current-node-changed", tree_dir_path_to_string(node.get_path_tuple()))