def download(self, bigfileid): if not self._imapReady: return splitedfileslist = dba.getSplitedFilesListByBigFileId(bigfileid) if not len(splitedfileslist) > 0: return False print 'Downloading Big file: %s' % splitedfileslist[0][1] if self._downloadSplitedFiles(splitedfileslist): if self._rebuid(splitedfileslist): print 'Download successfully!' self._RemoteRarPassword = splitedfileslist[0][9] self._RemoteFileName = splitedfileslist[0][5] self._OriginalFileBaseName = splitedfileslist[0][1] self._OriginalFileHash = splitedfileslist[0][2] if '' != self._RemoteRarPassword : fE = fileEncryptor(self._RemoteFileName, self._RemoteRarPassword) if fE.getUnRarFile(self._RemoteFileName) and getFileMD5(self._OriginalFileBaseName) == self._OriginalFileHash: print '\n------------->RAR file password :%s' % self._RemoteRarPassword print 'you can delete the rar file <%s> manually\n' % self._RemoteFileName #os.remove(self._RemoteFileName) self._cleanDownloadTempFiles(splitedfileslist) return True else: if getFileMD5(self._OriginalFileBaseName) == self._OriginalFileHash: self._cleanDownloadTempFiles(splitedfileslist) return True return False
def download(self, bigfileid): if not self._imapReady: return splitedfileslist = dba.getSplitedFilesListByBigFileId(bigfileid) if not len(splitedfileslist) > 0: return False print 'Downloading Big file: %s' % splitedfileslist[0][1] if self._downloadSplitedFiles(splitedfileslist): if self._rebuid(splitedfileslist): print 'Download successfully!' self._RemoteRarPassword = splitedfileslist[0][9] self._RemoteFileName = splitedfileslist[0][5] self._OriginalFileBaseName = splitedfileslist[0][1] self._OriginalFileHash = splitedfileslist[0][2] if '' != self._RemoteRarPassword: fE = fileEncryptor(self._RemoteFileName, self._RemoteRarPassword) if fE.getUnRarFile(self._RemoteFileName) and getFileMD5( self._OriginalFileBaseName ) == self._OriginalFileHash: print '\n------------->RAR file password :%s' % self._RemoteRarPassword print 'you can delete the rar file <%s> manually\n' % self._RemoteFileName #os.remove(self._RemoteFileName) self._cleanDownloadTempFiles(splitedfileslist) return True else: if getFileMD5(self._OriginalFileBaseName ) == self._OriginalFileHash: self._cleanDownloadTempFiles(splitedfileslist) return True return False
def download(self, imapuid, splitedfilename, splitedfilehash): if not self._imap: if not self._login(): return False t,d = self._imap.select(self.imap_diskname) if not t == 'OK': print 'self._imap.select(self.imap_diskname)' return False t,d = self._imap.uid('FETCH', imapuid, '(RFC822)') if not t == 'OK': print 'imap uid search failure..' return False email_body = d[0][1] mail = email.message_from_string(email_body) for part in mail.walk(): if part.get_content_maintype() == 'multipart': continue if part.get('Content-Disposition') is None: continue #filename = part.get_filename() fp = open(splitedfilename, 'wb') fp.write(part.get_payload(decode=True)) fp.close() #print splitedfilename if not os.path.exists(splitedfilename): print 'file downloaded but not exists' return False tmpHash = getFileMD5(splitedfilename) if not tmpHash == splitedfilehash: print 'imapDisk hash failure..' return False return True
def download(self, imapuid, splitedfilename, splitedfilehash): if not self._imap: if not self._login(): return False t, d = self._imap.select(self.imap_diskname) if not t == 'OK': print 'self._imap.select(self.imap_diskname)' return False t, d = self._imap.uid('FETCH', imapuid, '(RFC822)') if not t == 'OK': print 'imap uid search failure..' return False email_body = d[0][1] mail = email.message_from_string(email_body) for part in mail.walk(): if part.get_content_maintype() == 'multipart': continue if part.get('Content-Disposition') is None: continue #filename = part.get_filename() fp = open(splitedfilename, 'wb') fp.write(part.get_payload(decode=True)) fp.close() #print splitedfilename if not os.path.exists(splitedfilename): print 'file downloaded but not exists' return False tmpHash = getFileMD5(splitedfilename) if not tmpHash == splitedfilehash: print 'imapDisk hash failure..' return False return True
def _initOriginalFileInfo(self): self._OriginalFileBaseName = os.path.basename(self.OriginalFileFullName) self._OriginalFileMTime = '%.6f' % os.path.getmtime(self.OriginalFileFullName) self._OriginalFileSize = os.path.getsize(self.OriginalFileFullName) self._OriginalFileHash = getFileMD5(self.OriginalFileFullName) self._LocalTempFullName = self.OriginalFileFullName self._RemoteFileName = self._OriginalFileBaseName self._BigFileId = self._checkFileIsInDBByHash(self._OriginalFileHash);
def _initOriginalFileInfo(self): self._OriginalFileBaseName = os.path.basename( self.OriginalFileFullName) self._OriginalFileMTime = '%.6f' % os.path.getmtime( self.OriginalFileFullName) self._OriginalFileSize = os.path.getsize(self.OriginalFileFullName) self._OriginalFileHash = getFileMD5(self.OriginalFileFullName) self._LocalTempFullName = self.OriginalFileFullName self._RemoteFileName = self._OriginalFileBaseName self._BigFileId = self._checkFileIsInDBByHash(self._OriginalFileHash)
def _rebuid(self, splitedfileslist): self._RemoteFileName = splitedfileslist[0][5] self._RemoteFileHash = splitedfileslist[0][6] try: fpbig = open(self._RemoteFileName, 'wb') for fileinfo in splitedfileslist: splitedfilename = fileinfo[12] fpsplited = open(splitedfilename, 'rb') fpbig.write(fpsplited.read()) fpsplited.close() fpbig.close() except: return False tmpHash = getFileMD5(self._RemoteFileName) if not tmpHash == self._RemoteFileHash: print 'Remote file hash error..' return False return True
def _rebuid(self,splitedfileslist): self._RemoteFileName = splitedfileslist[0][5] self._RemoteFileHash = splitedfileslist[0][6] try: fpbig = open(self._RemoteFileName, 'wb') for fileinfo in splitedfileslist: splitedfilename = fileinfo[12] fpsplited = open(splitedfilename, 'rb') fpbig.write(fpsplited.read()) fpsplited.close() fpbig.close() except: return False tmpHash = getFileMD5(self._RemoteFileName) if not tmpHash == self._RemoteFileHash: print 'Remote file hash error..' return False return True