コード例 #1
0
    def file_check(self,originalDirectory,
                   newDirectory,text):  # only for directory.
        #if str(e).find("not a directory")  !=-1:
        #        return 1 #flag
        if os.path.isdir(originalDirectory) == False:  #Debugg it
            return 1
        ''' return flag when newDirectory or originalDirectory does not exist: can we use the commandline isexist() for this?
        '''
        
        ''' It needs to have another command which supports the txt file; the addresses are required.
        '''
        #======================================================================= initialization
        olDfiles = os.listdir(originalDirectory)
        neWfiles = os.listdir(newDirectory)
        olDname = []
        neWname = []
        log = text_log()
        olDfilesSize = self.get_size(originalDirectory)
        neWfilesSize = self.get_size(newDirectory)
        #=======================================================================
        #======================================================================= Process #1

        olDfilesSize = self.get_size(originalDirectory)
        neWfilesSize = self.get_size(newDirectory)
        for i in range(0,len(olDfiles)):
            global totaLfileCounter
            totaLfileCounter = i
            olDname.append( originalDirectory+"\\"+str(olDfiles[i]))
        for i in range(0, len(neWfiles)):
            global fileCounter
            fileCounter = i
            neWname.append( newDirectory+"\\"+str(neWfiles[i]))
        #======================================================================= Process #2
        log.describe("\n\n해당되는 주소:",text)
        log.write(originalDirectory,text)
        log.describe("\n%%"+"전체 파일 " +str(len(olDfiles))+"중"+str(len(neWfiles))+"파일 또는 폴더 복사 완료"+"%%\n",text)
        difference = list(set(olDfiles)-set(neWfiles))
        if( difference == []):
             for i in range(0, len(olDname)):
                 constant = abs(os.stat(olDname[i]).st_size-os.stat(neWname[i]).st_size)
                 if(constant %4096 ==0 and constant != 0):
                    log.describe("WARNING :=\t"+olDname[i] +"\t의 메타 데이터 ( 데이터 정보) 복사 실패 하였습니다 폴더 찾기가 안되어 있을수 있습니다.\n",text)
                 if(constant !=0 and constant %4096 != 0):
                      log.describe("실패한 파일:\t",text)
                      log.write(olDname[i],text)
                      log.describe("\n 잃어버린 바이트 :\t",text)
                      self.loss_byte(constant,text)
    
        else: 
             for i in range(0,len(difference)):
                  constant = os.stat(originalDirectory+"\\"+str(difference[i])).st_size
                  log.describe("\n\n실패한폴더 또는 파일:\t"+((difference[i]))+"\n",text) #cannot calculate when there is a permission lock on the file. .
                  if(constant !=0):
        #            draw the line.
                     log.describe(("잃어버린자료 용량 :\t"),text)
                     self.loss_byte(constant,text)
コード例 #2
0
    def loss_byte(Constant2,text): 

        log = text_log()
        if (Constant2 <1e3):
            log.describe(str(Constant2 +("\t바이트\n")),text)
        elif (1e3<Constant2< 1e6):
            log.describe(str(Constant2*1e-3) +("\t킬로바이트\n"),text)
        elif (1e6<Constant2<1e9):
            log.describe(str(Constant2*1e-6) +("\t메가바이트\n"),text)
        elif (1e9<Constant2<1e12):
            log.describe(str(Constant2*1e-9) +("\t기가바이트\n"),text)    
コード例 #3
0
ファイル: copy_function.py プロジェクト: jmhwang/Back_up_0.1
 def __init__(self, directory_path, log_path, drive,flag = 0):
     
     
     try: 
         self.path = directory_path
         self.log_path = log_path
          #Use the txt log. May other classes will be implemented to ask
         #an opinion of the extensions.
         #log.make_report(log_path)>> do that in the main
         self.copy_function(directory_path,  log_path, drive,flag)
     except Exception as e:
         ############================= changed
         log = text_log()
         if not log.finalContain(self.log_path):
             log.failed(self.log_path)
         log.error(self.log_path,str(e))
         ###################################### eRROR LiSTING
         if ('[Error 5]' in str(e) or 'error listing files' in str(e)):
             #Error 5
             log.describe("\n\t 복사나 제거가 불가능  합니다 : 관리자의 권한이 필요합니다.\n\n",log_path)
         elif('could not delete' in str(e)): 
              log.describe("\n\t 복사나 제거 도중 다른 파일에 영향을 끼칠 수 있습니다: 관리자의 권한이 필요합니다.\n\n",log_path)
コード例 #4
0
ファイル: main.py プロジェクト: jmhwang/Back_up_0.1
    ##  global password
    ##  global addresses
    reportPath = ''
    folderName = ''
    try:
        #need to make the directory before make the text.
        #global reportPath
        folderName = folderNameDate
        if not os.path.exists(folderName):
            os.makedirs (folderName)
        else:
            folderName = folderNameTime
            flag = 1
            os.makedirs (folderName)
        reportPath = folderName +"\\"+reportName
        text = text_log()
        ##text.send_email(email,password,addresses)
        text.make_report(reportPath)
        text.initial(reportPath)
        function_address = extract_address()
        
        address = function_address.main(open(directoryPath))
        
        ''' Copy the given directory
        '''
        counter = 0
        while counter < len(address) and address[counter] is not None:

            copy_folder(address[counter], reportPath, drive,flag)
            newAddress = copy_folder(address[counter], reportPath, drive,flag).get_directory_address(address[counter],drive,flag)
            ### do it here.=====================================