Ignore:
Timestamp:
02/05/08 11:24:56 (11 years ago)
Author:
cbyrom
Message:

Improve checking of return vals from db calls - to nullify these if
nothing has been returned + adjust logging + simplify file utils.

Location:
TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/FileUtilities.py

    r3821 r3844  
    4444        if not exists(dpath): 
    4545            makedirs(dpath) 
    46         return normpath(abspath(path)) 
     46        status = normpath(abspath(path)) 
     47         
     48        if status == 0: 
     49            logging.info("Directory created successfully") 
     50        return status 
    4751 
    4852     
     
    6165                sys.exit("Failed at setting up directory, %s" %dir) 
    6266 
     67        logging.info("Directory set up successfully") 
    6368 
    6469    def cleanDir(self, dir): 
     
    7277 
    7378        status = os.system(commandline) 
    74         if status !=0: 
     79        if status != 0: 
    7580            sys.exit("Failed at cleaning out directory, %s" %dir) 
     81         
     82        logging.info("Directory cleaned successfully") 
    7683 
    7784         
     
    8491        logging.info("Creating backup directory (" + original_dir + \ 
    8592                                " --> " + backup_dir + ")") 
    86         commandline = "mkdir " + backup_dir 
    87         logging.debug("Executing : " + commandline) 
     93        self.makepath(backup_dir) 
     94     
     95        commandline = "find " + original_dir + " -type f -print | xargs -i cp \{\} " + backup_dir 
     96        logging.info("Executing : " + commandline) 
    8897        status = os.system(commandline) 
    8998        if status !=0: 
    90             sys.exit("Failed at creating backup directory %s" %backup_dir) 
     99            sys.exit("Failed at copying to backup directory %s" %backup_dir) 
     100             
     101        logging.info("Backup completed successfully") 
    91102     
    92 #            commandline = "ls -1 " + original_dir + " | xargs -i cp " + original_dir + "{\} " + backup_dir 
    93             commandline = "find " + original_dir + " -type f -print | xargs -i cp \{\} " + backup_dir 
    94             logging.info("Executing : " + commandline) 
    95             status = os.system(commandline) 
    96             if status !=0: 
    97                 sys.exit("Failed at copying to backup directory %s" %backup_dir) 
    98      
  • TI01-discovery/branches/ingestAutomation-upgrade/OAIBatch/db_funcs.py

    r3839 r3844  
    3535        connection.commit() 
    3636        logging.info("SQL command completed successfully") 
    37         return cursor.fetchall() 
    3837 
     38        # work out if there's anything to return; if so, return it 
     39        try: 
     40                data = cursor.fetchall() 
     41                logging.debug("Command returned data: %s" %data) 
     42                 
     43                # test for empty array 
     44                if data[0]: 
     45                        return data 
     46                else: 
     47                        logging.debug("No actual data returned in array") 
     48                        return 
     49        except: 
     50                logging.debug("Command returned no data") 
     51 
     52        return 
Note: See TracChangeset for help on using the changeset viewer.