Ignore:
Timestamp:
23/10/15 09:31:51 (4 years ago)
Author:
mjuckes
Message:

updates for python 3

File:
1 edited

Legend:

Unmodified
Added
Removed
  • CMIP6dreq/trunk/dreqPy/simpleCheck.py

    r425 r435  
     1from __init__ import DOC_DIR 
    12 
    23try: 
     
    78except: 
    89  pkgutilFailed=True 
    9   print 'Failed to load pkgutil .. more limited tests on available modules will be done' 
     10  print ( 'Failed to load pkgutil .. more limited tests on available modules will be done' ) 
    1011  ll = [] 
    1112 
    12  
    13 requiredModules = ['xml','string','collections','os'] 
     13requiredModules = ['xml'] 
    1414confirmed = [] 
    1515installFailed = [] 
     
    1818  if x in ll or pkgutilFailed: 
    1919      try: 
    20         cmd = 'import %s' % x 
    21         exec cmd 
     20        __import__(x) 
    2221        confirmed.append( x ) 
    2322      except: 
    2423        installFailed.append( x ) 
    25         print 'Failed to install %s' % x 
     24        print ( 'Failed to install %s' % x ) 
    2625  else: 
    2726      missingLib.append( x ) 
    2827 
    2928if len( missingLib ) > 0 or len(installFailed) > 0: 
    30   print 'Could not load all required python libraries' 
     29  print ( 'Could not load all required python libraries' ) 
    3130  if len(missingLib) > 0: 
    32     print 'MISSING LIBRARIES:',str(missingLib) 
     31    print ( 'MISSING LIBRARIES: %s' % str(missingLib) ) 
    3332  if len(installFailed) > 0: 
    34     print 'LIBRARIES PRESENT BUT FAILED TO INSTALL:',str(missingLib) 
     33    print ( 'LIBRARIES PRESENT BUT FAILED TO INSTALL:%s' % str(missingLib) ) 
    3534  all = False 
    3635  exit(0) 
    3736else: 
    38   print 'Required libraries present' 
     37  print ( 'Required libraries present' ) 
    3938  all = True 
    40  
    4139 
    4240import inspect 
     
    4745 
    4846#document directory 
    49     self.docdir = '../docs' 
     47    self.docdir = DOC_DIR 
    5048#schema location 
    5149    self.schema = '%s/dreq2Schema.xsd' % self.docdir 
     
    6462          ok &= self.ok 
    6563        except: 
    66           print 'Failed to complete check %s' % tag 
     64          print ( 'Failed to complete check %s' % tag ) 
    6765    if ok: 
    68       print '%s: All checks passed' % lab 
     66      print ( '%s: All checks passed' % lab ) 
    6967    else:  
    70       print '%s: Errors detected' % lab 
     68      print ( '%s: Errors detected' % lab ) 
    7169        
    7270class check1(checkbase): 
    7371  def _ch01_importDreq(self): 
    7472    import dreq 
    75     print 'Dreq software import checked' 
     73    print ( 'Dreq software import checked' ) 
    7674    self.ok = True 
    7775 
     
    7977    import dreq 
    8078    rq = dreq.loadDreq( dreqXML=self.sampleXml,configdoc=self.defnXml ) 
    81     print 'Dreq sample load checked' 
     79    print ( 'Dreq sample load checked' ) 
    8280    self.ok = True 
    8381 
     
    9391    ii = open( '.simpleCheck_check2_err.txt' ).readlines() 
    9492    if len(ii) > 0: 
    95       print 'WARNING[001]: failed to detect xmllint command line program' 
    96       print 'optional checks omitted' 
     93      print ( 'WARNING[001]: failed to detect xmllint command line program' ) 
     94      print ( 'optional checks omitted' ) 
    9795      self.ok = False 
    9896      self._clear_ch03() 
     
    10098    ii = open( '.simpleCheck_check2.txt' ).readlines() 
    10199    if len(ii) < 1: 
    102       print 'WARNING[002]: failed to detect xmllint command line program' 
    103       print 'optional checks omitted' 
     100      print ( 'WARNING[002]: failed to detect xmllint command line program' ) 
     101      print ( 'Optional checks omitted' ) 
    104102      self.ok = False 
    105103      self._clear_ch03() 
     
    110108    ii = open( '.simpleCheck_check2_err.txt' ).readlines() 
    111109    if len(ii) == 0: 
    112       print 'WARNING[003]: Failed to capture xmllint response' 
    113       print cmd 
     110      print ( 'WARNING[003]: Failed to capture xmllint response' ) 
     111      print ( cmd ) 
    114112      self.ok = False 
    115113      self._clear_ch03() 
    116114      return 
    117115    if string.find(ii[0],'validates') != -1: 
    118       print 'Sample XML validated' 
     116      print ( 'Sample XML validated' ) 
    119117      self.ok = True 
    120118      self._clear_ch03() 
    121119    else: 
    122       print 'Sample XML failed to validate' 
    123       print cmd 
     120      print ( 'Sample XML failed to validate' ) 
     121      print ( cmd ) 
    124122      self.ok = False 
    125123    return 
     
    129127 
    130128if all: 
    131   print 'ALL CHECK PASSED' 
     129  print ( 'ALL CHECK PASSED' ) 
Note: See TracChangeset for help on using the changeset viewer.