Changeset 4965


Ignore:
Timestamp:
Jan 22, 2008, 6:10:50 PM (16 years ago)
Author:
ole
Message:

A little work on IP tracking

File:
1 edited

Legend:

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

    r4963 r4965  
    1717audit_exceptions = (NotPublishable, FilenameMismatch, CRCMismatch, Invalid, WrongTags)
    1818
    19 def IP_verified(directory):
     19def IP_verified(directory, verbose=False):
    2020    """Find and audit potential data files that might violate IP
    2121
     
    3030        # Proceed boldly with confidence
    3131       
     32    verbose controls standard output.
     33    If verbose is False, only diagnostics about failed audits will appear.
     34    All files that check OK will pass silently.
     35   
    3236
    3337    """
     
    4650    all_files_accounted_for = True
    4751    for dirpath, datafile in identify_datafiles(directory):
     52       
    4853        filename = join(dirpath, datafile)
    49        
    50         print filename + ' (Checksum=%s): ' %str(compute_checksum(filename)),
    51 
    5254        basename, ext = splitext(datafile)
    5355
    5456        # Look for a XML license file with the .lic
     57        status = 'OK'
    5558        try:
    5659            fid = open(join(dirpath, basename + '.lic'))
    5760        except IOError:
    58             print 'NO LICENSE FILE'
     61            status = 'NO LICENSE FILE'
    5962            all_files_accounted_for = False
    6063        else:
    6164            try:
    62                 license_file_is_valid(fid, dirpath, verbose=False)
     65                license_file_is_valid(fid, dirpath, verbose=verbose)
    6366            except audit_exceptions, e:
    6467                all_files_accounted_for = False                               
    65                 print 'LICENSE FILE NOT VALID'
    66                 print 'REASON:', e
     68                status = 'LICENSE FILE NOT VALID'
     69                status += 'REASON: %s' %e
    6770
    6871                #doc = parse(fid)
    6972                #pretty_print_tree(doc)
    7073                fid.seek(0)
    71                 print fid.read()
    72 
    73             else:       
    74                 print 'OK'
     74                status += fid.read()
     75
     76            #else:       
     77            #    if verbose: print 'OK'
    7578
    7679            fid.close()
     80           
     81        if status != 'OK' or verbose is True:
     82            print filename + ' (Checksum=%s): '\
     83                  %str(compute_checksum(filename)), status
     84
     85
    7786
    7887    # Return result       
Note: See TracChangeset for help on using the changeset viewer.