Exemplo n.º 1
0
    def LIST(self, dirpath):
        if not self.authenticated:
            self.sendCommand('530 User not logged in.\r\n')
            return

        if not dirpath:
            pathname = os.path.abspath(os.path.join(self.cwd, '.'))
        elif dirpath.startswith(os.path.sep):
            pathname = os.path.abspath(dirpath)
        else:
            pathname = os.path.abspath(os.path.join(self.cwd, dirpath))

        log('LIST', pathname)
        if not self.authenticated:
            self.sendCommand('530 User not logged in.\r\n')

        elif not os.path.exists(pathname):
            self.sendCommand('550 LIST failed Path name not exists.\r\n')

        else:
            self.sendCommand('150 Here is listing.\r\n')
            self.startDataSock()
            if not os.path.isdir(pathname):
                fileMessage = fileProperty(pathname)
                self.dataSock.sock(fileMessage + '\r\n')

            else:
                for file in os.listdir(pathname):
                    fileMessage = fileProperty(os.path.join(pathname, file))
                    self.sendData(fileMessage + '\r\n')
            self.stopDataSock()
            self.sendCommand('226 List done.\r\n')
Exemplo n.º 2
0
    def LIST(self, dirpath):
        if not self.authenticated:
            self._send_command('530 User not logged in.\r\n')
            return

        if not dirpath:  # current directory
            pathname = os.path.abspath(os.path.join(self.cwd, '.'))
        elif dirpath.startswith(os.path.sep):  # start with /, abspath
            pathname = os.path.abspath(dirpath)
        else:  # cwd/dirpath
            pathname = os.path.abspath(os.path.join(self.cwd, dirpath))

        print('LIST:{}\n'.format(pathname))
        if not os.path.exists(pathname):
            self._send_command('550 LIST failed: Path name not exists.\r\n')
        else:
            self._send_command('150 Here is listing.\r\n')
            self.start_data_sock()

            # TODO
            if not os.path.isdir(pathname):
                fileMessage = fileProperty(pathname)
                self._send_data(fileMessage + '\r\n')
            else:
                for f in os.listdir(pathname):
                    # TODO
                    fileMessage = fileProperty(os.path.join(pathname, f))
                    self._send_data(fileMessage + '\r\n')

            self.stop_data_sock()
            self._send_command('226 List done.\r\n')
Exemplo n.º 3
0
    def LIST(self, directory_path):
        # Sends list of content in specified server path
        if not self.authenticated:
            self.sendResponse('530 User not logged in.\r\n')
            return

        if not directory_path:
            server_path = os.path.abspath(
                os.path.join(self.base_path + self.working_directory, '.'))
        elif directory_path.startswith(os.path.sep):
            server_path = os.path.abspath(directory_path)
        else:
            server_path = os.path.abspath(
                os.path.join(self.base_path + self.working_directory, '.'))

        log('LIST', server_path)

        if not self.authenticated:
            self.sendResponse('530 User not logged in.\r\n')
        elif not os.path.exists(server_path):
            self.sendResponse('550 LIST failed Path name not exists.\r\n')
        else:
            self.sendResponse('150 Here is listing.\r\n')
            self.createDataSocket()

            if not os.path.isdir(server_path):
                fileMessage = fileProperty(server_path)
                self.data_socket.sock(fileMessage + '\r\n')
            else:
                for file in os.listdir(server_path):
                    fileMessage = fileProperty(os.path.join(server_path, file))
                    self.sendData(fileMessage + '\r\n')

            self.terminateDataSocket()
            self.sendResponse('226 List done.\r\n')
Exemplo n.º 4
0
    def NLST(self, directory_path):
        # Sends a directory listing from server to user site with only names of content
        if not self.authenticated:
            self.sendResponse('530 User not logged in.\r\n')
            return

        if not directory_path:
            server_path = os.path.abspath(
                os.path.join(self.base_path + self.working_directory, '.'))
        elif directory_path.startswith(os.path.sep):
            server_path = os.path.abspath(directory_path)
        else:
            server_path = os.path.abspath(
                os.path.join(self.base_path + self.working_directory, '.'))

        log('NLST', directory_path)

        if not self.authenticated:
            self.sendResponse('530 User not logged in.\r\n')
        elif not os.path.exists(server_path):
            self.sendResponse('550 NLST failed Path name doesnt exist.\r\n')
        else:
            self.sendResponse('150 Here is listing.\r\n')
            self.createDataSocket()

            if not os.path.isdir(server_path):
                fileMessage = fileProperty(server_path)
                self.data_socket.sock(fileMessage + '\r\n')
            else:
                for file in os.listdir(server_path):
                    self.sendData(file + '\r\n')

            self.terminateDataSocket()
            self.sendResponse('226 List done.\r\n')
Exemplo n.º 5
0
 def loadToLocaFileList(self):
     self.local.refreshButton.setEnabled(True)
     self.localWordList = []
     self.localDir = {}
     for f in os.listdir(self.local_pwd):
         pathname = os.path.join(self.local_pwd, f)
         self.addItemToLocalFileList(fileProperty(pathname))
     self.local.completerModel.setStringList(self.localWordList)
Exemplo n.º 6
0
 def loadToLocaFileList(self):
     """
     load file and directory list from local computer
     """
     self.localWordList = [ ]
     self.localDir      = { }
     for f in os.listdir(self.local_pwd):
         pathname = os.path.join(self.local_pwd, f)
         self.addItemToLocalFileList(fileProperty(pathname))
     self.local.completerModel.setStringList(self.localWordList)
Exemplo n.º 7
0
 def loadToLocaFileList(self):
     """
     load file and directory list from local computer
     """
     self.localWordList = [ ]
     self.localDir      = { }
     for f in os.listdir(self.local_pwd):
         pathname = os.path.join(self.local_pwd, f)
         self.addItemToLocalFileList(fileProperty(pathname))
     self.local.completerModel.setStringList(self.localWordList)
Exemplo n.º 8
0
 def load_to_local_filelist(self):
     """
     load file and directory list from local computer
     """
     self.localWordList = []
     self.localDir = {}
     for f in os.listdir(self.local_pwd):
         pathname = os.path.join(self.local_pwd, f)
         self.add_item_to_local_filelist(fileProperty(pathname))
     self.local.completerModel.setStringList(self.localWordList)
     self.local.fileList.sortByColumn(0, Qt.SortOrder.AscendingOrder)