Changeset 5039


Ignore:
Timestamp:
Feb 18, 2008, 3:26:42 PM (17 years ago)
Author:
ole
Message:

fiddled

Location:
anuga_core/source/anuga/utilities
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_core/source/anuga/utilities/data_audit.py

    r5028 r5039  
    6666    first_time = True
    6767    all_files_accounted_for = True
    68     for dirpath, datafile in identify_datafiles(directory,
     68    for dirpath, filename in identify_datafiles(directory,
    6969                                                extensions_to_ignore,
    7070                                                directories_to_ignore,
     
    7373        all_files += 1
    7474       
    75         data_filename = join(dirpath, datafile)
    76         basename, ext = splitext(datafile)
     75        basename, ext = splitext(filename)
    7776        license_filename = join(dirpath, basename + '.lic')
     77
    7878
    7979        # Look for a XML license file with the .lic
     
    8989            try:
    9090                license_file_is_valid(license_filename,
    91                                       data_filename,
     91                                      filename,
    9292                                      dirpath,
    9393                                      verbose=False)
     
    100100                    doc = xml2object(license_filename)
    101101                except:
    102                     status += 'XML file %s could not be read:' %license_filename
     102                    status += 'XML file %s could not be read:'\
     103                              %license_filename
    103104                    fid = open(license_filename)
    104105                    status += fid.read()
     
    116117                # Print header
    117118                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'
    119121                print '---------------------------------------------'
    120122                first_time = False
    121123
    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
    124127
    125128
     
    127130        print
    128131        print 'Audit result for %s:' %dirpath
    129         print 'Number of files in audited:  %d' %(all_files)
    130         print 'Number of files in verified: %d' %(ok_files)       
     132        print 'Number of files audited:  %d' %(all_files)
     133        print 'Number of files verified: %d' %(ok_files)       
    131134
    132135
     
    171174
    172175
    173 def license_file_is_valid(license_filename, filename_to_verify,
     176def license_file_is_valid(license_filename, data_filename,
    174177                          dirpath='.', verbose=False):
    175178    """Check that XML license file for given filename_to_verify is valid.
    176179
    177180    Input:
    178         license_filename: XML license file
    179         file_name_to_verify: The data filename that is being audited
     181        license_filename: XML license file (must be an absolute path name)
     182        data_filename: The data filename that is being audited
    180183        dir_path: Where the files live
    181184        verbose: Optional verbosity
     
    194197    """
    195198
    196 
    197 
    198199    doc = xml2object(license_filename)
    199     #print doc
    200 
    201200   
    202201    # Check that file is valid (e.g. all elements there)
     
    256255    found = False
    257256    for data in datafile:   
    258         if data['filename'] == filename_to_verify:
     257        if data['filename'] == data_filename:
    259258            found = True
    260259    if not found:
    261         msg = 'Specified filename to verify %s ' %filename_to_verify
     260        msg = 'Specified filename to verify %s ' %data_filename
    262261        msg += 'did not appear in license file %s' %license_filename
    263262        raise FilenameMismatch, msg               
  • anuga_core/source/anuga/utilities/test_data_audit.py

    r5020 r5039  
    7272        licfid.close()
    7373
    74         licfid = open(license_filename)
     74        #licfid = open(license_filename)
    7575        #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)
    7980        except CRCMismatch:
    8081            pass
     
    8485               
    8586        # Clean up
    86         licfid.close()
     87        #licfid.close()
    8788        os.remove(license_filename)
    8889        try:
    8990            os.remove(tmp_name)       
    9091        except:
    91             # FIXME(Ole)QThis doesn't work on Windows for some reason
     92            # FIXME(Ole) This doesn't work on Windows for some reason
    9293            pass
    9394       
Note: See TracChangeset for help on using the changeset viewer.