Changeset 5039
- Timestamp:
- Feb 18, 2008, 3:26:42 PM (17 years ago)
- Location:
- anuga_core/source/anuga/utilities
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/utilities/data_audit.py
r5028 r5039 66 66 first_time = True 67 67 all_files_accounted_for = True 68 for dirpath, datafile in identify_datafiles(directory,68 for dirpath, filename in identify_datafiles(directory, 69 69 extensions_to_ignore, 70 70 directories_to_ignore, … … 73 73 all_files += 1 74 74 75 data_filename = join(dirpath, datafile) 76 basename, ext = splitext(datafile) 75 basename, ext = splitext(filename) 77 76 license_filename = join(dirpath, basename + '.lic') 77 78 78 79 79 # Look for a XML license file with the .lic … … 89 89 try: 90 90 license_file_is_valid(license_filename, 91 data_filename,91 filename, 92 92 dirpath, 93 93 verbose=False) … … 100 100 doc = xml2object(license_filename) 101 101 except: 102 status += 'XML file %s could not be read:' %license_filename 102 status += 'XML file %s could not be read:'\ 103 %license_filename 103 104 fid = open(license_filename) 104 105 status += fid.read() … … 116 117 # Print header 117 118 print '---------------------------------------------' 118 print 'Files that need to be assessed for IP issuses'.ljust(dirwidth), 'Status' 119 msg = 'Files that need to be assessed for IP issuses' 120 print msg.ljust(dirwidth), 'Status' 119 121 print '---------------------------------------------' 120 122 first_time = False 121 123 122 print data_filename + ' (Checksum=%s): '\ 123 %str(compute_checksum(data_filename)), status 124 print filename + ' (Checksum=%s): '\ 125 %str(compute_checksum(join(dirpath, filename))),\ 126 status 124 127 125 128 … … 127 130 print 128 131 print 'Audit result for %s:' %dirpath 129 print 'Number of files inaudited: %d' %(all_files)130 print 'Number of files inverified: %d' %(ok_files)132 print 'Number of files audited: %d' %(all_files) 133 print 'Number of files verified: %d' %(ok_files) 131 134 132 135 … … 171 174 172 175 173 def license_file_is_valid(license_filename, filename_to_verify,176 def license_file_is_valid(license_filename, data_filename, 174 177 dirpath='.', verbose=False): 175 178 """Check that XML license file for given filename_to_verify is valid. 176 179 177 180 Input: 178 license_filename: XML license file 179 file_name_to_verify: The data filename that is being audited181 license_filename: XML license file (must be an absolute path name) 182 data_filename: The data filename that is being audited 180 183 dir_path: Where the files live 181 184 verbose: Optional verbosity … … 194 197 """ 195 198 196 197 198 199 doc = xml2object(license_filename) 199 #print doc200 201 200 202 201 # Check that file is valid (e.g. all elements there) … … 256 255 found = False 257 256 for data in datafile: 258 if data['filename'] == filename_to_verify:257 if data['filename'] == data_filename: 259 258 found = True 260 259 if not found: 261 msg = 'Specified filename to verify %s ' % filename_to_verify260 msg = 'Specified filename to verify %s ' %data_filename 262 261 msg += 'did not appear in license file %s' %license_filename 263 262 raise FilenameMismatch, msg -
anuga_core/source/anuga/utilities/test_data_audit.py
r5020 r5039 72 72 licfid.close() 73 73 74 licfid = open(license_filename)74 #licfid = open(license_filename) 75 75 #print licfid.read() 76 77 try: 78 license_file_is_valid(licfid, tmp_name) 76 #licfid.close() 77 78 try: 79 license_file_is_valid(license_filename, tmp_name) 79 80 except CRCMismatch: 80 81 pass … … 84 85 85 86 # Clean up 86 licfid.close()87 #licfid.close() 87 88 os.remove(license_filename) 88 89 try: 89 90 os.remove(tmp_name) 90 91 except: 91 # FIXME(Ole) QThis doesn't work on Windows for some reason92 # FIXME(Ole) This doesn't work on Windows for some reason 92 93 pass 93 94
Note: See TracChangeset
for help on using the changeset viewer.