示例#1
0
    def LIST(self, dirpath):
        if not self.authenticated:
            self.commSock.send("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.commSock.send("530 User not logged in.\r\n")

        elif not os.path.exists(pathname):
            self.commSock.send("550 LIST failed Path name not exists.\r\n")

        else:
            self.commSock.send("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.dataSock.send(fileMessage + "\r\n")
            self.stopDataSock()
            self.commSock.send("226 List done.\r\n")
示例#2
0
    def LIST(self, dirpath):
        if not self.authenticated:
            self.commSock.send('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.commSock.send('530 User not logged in.\r\n')

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

        else:
            self.commSock.send('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.dataSock.send(fileMessage + '\r\n')
            self.stopDataSock()
            self.commSock.send('226 List done.\r\n')
示例#3
0
	def loadToLocaFileList(self): #load file and directory list from local computer
		self.localWordList = []
		self.localDir = {}
		for f in filter( lambda x: not x.startswith("."), os.listdir(self.local_pwd)):
			pathname = os.path.join(self.local_pwd, f)
			self.addItemToLocalFileList(fileProperty(pathname))
		self.local.completerModel.setStringList(self.localWordList)
示例#4
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)
示例#5
0
文件: ftpClient.py 项目: Conanjun/ftp
 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)