예제 #1
0
    def handleMission(self):
        if self.fileinfo:
            self.filename = self.fileinfo.split(divider_arg)[1]
            self.filename = self.filename.replace(anti_dir_divider(),
                                                  dir_divider())
            self.file_path = str(self.save_path + dir_divider() +
                                 self.filename)
            self.file_path = self.file_path.replace(anti_dir_divider(),
                                                    dir_divider())
            self.filesize = int(self.fileinfo.split(divider_arg)[2])
        if self.filesize >= 0:
            self.file_md5 = self.fileinfo.split(divider_arg)[3]
            self.write_filedata()
        elif self.filesize == -1:
            if not os.path.exists(self.file_path):
                os.makedirs(self.file_path)
            index = int(self.fileinfo.split(divider_arg)[3])
            dir = self.fileinfo.split(divider_arg)[1]

            if index == 0:
                print(right_arrows + dict('ms') + left_arrows)
                print('-' * 30)
                self.commandThread.rootdir_create(self.fileinfo)
            else:
                self.commandThread.dir_created(self.fileinfo)
            print(dict('cd') + ': ' + dir)
예제 #2
0
 def onFindDir(self,dir_path):
     global msg_index
     msg_index += 1
     print('创建文件夹'+ os.path.basename(self.rootpath)+dir_divider()+relative_path(self.rootpath,dir_path))
     self.filename = dir_path
     self.filesize = -1
     self.commandThread.send_fileinfo(COMMANE_FILE_INFO + divider_arg
                                      +os.path.basename(self.rootpath) + dir_divider()+relative_path(self.rootpath,dir_path)+ divider_arg
                                      +str(-1)+divider_arg+
                                      str(msg_index))
예제 #3
0
 def onFindFile(self,file_path,size):
     global msg_index
     msg_index += 1
     print('文件 :'+ os.path.basename(self.rootpath)+dir_divider()+relative_path(self.rootpath,file_path) +
           ' '+ formated_size(size))
     self.filename = file_path
     self.filesize = size
     if (os.path.isfile(file_path) and relative_path(self.rootpath,file_path) == ''):
         self.commandThread.send_fileinfo(COMMANE_FILE_INFO + divider_arg +
                                          os.path.basename(file_path) + divider_arg+
                                          str(size) + divider_arg+
                                          getFileMd5(file_path) + divider_arg+
                                          str(msg_index))
     else:
         self.commandThread.send_fileinfo(COMMANE_FILE_INFO + divider_arg +
                                          os.path.basename(self.rootpath) + dir_divider()+ relative_path(self.rootpath,file_path) + divider_arg+
                                          str(size) + divider_arg +
                                          getFileMd5(file_path) + divider_arg +
                                          str(msg_index))
예제 #4
0
def keyInFilePath():
    while True:
        filepath = input('请输入文件或者文件夹的路径:')
        if filepath.endswith(dir_divider()):
            filepath2 = filepath[:len(filepath)-1]
        else:
            filepath2 = filepath
        if checkfile(filepath2)[0]:
            return filepath2, True
        else:
            print('该路径下不存在任何东西')
예제 #5
0
def keyInFilePath():
    while True:
        filepath = input(dict('pif'))
        if filepath.endswith(dir_divider()):
            filepath2 = filepath[:len(filepath) - 1]
        else:
            filepath2 = filepath
        if checkfile(filepath2)[0]:
            return filepath2, True
        else:
            print(dict('pde'))