Changeset 5028


Ignore:
Timestamp:
Feb 13, 2008, 9:59:59 AM (17 years ago)
Author:
ole
Message:

Nicer data_audit API

Files:
2 edited

Legend:

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

    r5027 r5028  
    7373        all_files += 1
    7474       
    75         filename = join(dirpath, datafile)
     75        data_filename = join(dirpath, datafile)
    7676        basename, ext = splitext(datafile)
     77        license_filename = join(dirpath, basename + '.lic')
    7778
    7879        # Look for a XML license file with the .lic
    7980        status = 'OK'
    8081        try:
    81             fid = open(join(dirpath, basename + '.lic'))
     82            fid = open(license_filename)
    8283        except IOError:
    8384            status = 'NO LICENSE FILE'
    8485            all_files_accounted_for = False
    8586        else:
     87            fid.close()
     88           
    8689            try:
    87                 license_file_is_valid(fid, datafile, dirpath,
     90                license_file_is_valid(license_filename,
     91                                      data_filename,
     92                                      dirpath,
    8893                                      verbose=False)
    8994            except audit_exceptions, e:
     
    9398
    9499                try:
    95                     doc = xml2object(fid)
     100                    doc = xml2object(license_filename)
    96101                except:
    97                     status += 'XML file could not be read:'
    98                     fid.seek(0)
    99                     status += fid.read()                   
     102                    status += 'XML file %s could not be read:' %license_filename
     103                    fid = open(license_filename)
     104                    status += fid.read()
     105                    fid.close()
    100106                else:   
    101107                    status += str(doc)
    102108
    103             fid.close()
     109
    104110
    105111        if status == 'OK':
     
    114120                first_time = False
    115121
    116             print filename + ' (Checksum=%s): '\
    117                   %str(compute_checksum(filename)), status
     122            print data_filename + ' (Checksum=%s): '\
     123                  %str(compute_checksum(data_filename)), status
    118124
    119125
     
    165171
    166172
    167 def license_file_is_valid(fid, filename_to_verify,
     173def license_file_is_valid(license_filename, filename_to_verify,
    168174                          dirpath='.', verbose=False):
    169175    """Check that XML license file for given filename_to_verify is valid.
    170176
    171177    Input:
    172         fid: Open file object for XML license file
     178        license_filename: XML license file
    173179        file_name_to_verify: The data filename that is being audited
    174180        dir_path: Where the files live
     
    188194    """
    189195
    190     license_filename = fid.name
    191 
    192     doc = xml2object(fid)
     196
     197
     198    doc = xml2object(license_filename)
    193199    #print doc
    194200
  • create_distribution.py

    r5018 r5028  
    123123#---------------------------
    124124print 'Verifying data IP'
    125 if not IP_verified(distro_dir):
     125if not IP_verified(distro_dir, verbose=True):
    126126    msg = 'Files have not been verified for IP.\n'
    127127    msg += 'Each data file must have a license file with it.'
Note: See TracChangeset for help on using the changeset viewer.