Changeset 656 for branches


Ignore:
Timestamp:
Oct 21, 2007 8:04:00 PM (12 years ago)
Author:
jpfasano
Message:

Implement local version distutils.dep_util.newer(source,target) that depends on the version of python.
The intention is that this function can be used to determine if Third party codes has to be obtained because there is a new version of get.XXX.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/testScripts/NBosCommand.py

    r647 r656  
    33from socket import gethostname
    44import sys
     5import os
     6import re
     7
     8#------------------------------------------------------------------------
     9# newer(source, target)
     10# Return true if source exists and is more recently modified than target,
     11# or if source exists and target doesn't.
     12# Return false if both exist and target is the same age or newer than source.
     13# Raise DistutilsFileError if source does not exist.
     14#------------------------------------------------------------------------
     15def newer(source,target) :
     16  if sys.version[:6]>='2.5.0' :
     17    # Version of python being used does not have distutils
     18    if not os.path.isfile(source) : sys.exit(1)
     19    if os.name!="posix" :
     20      # Always assume target is out of date
     21      return True
     22    else :
     23      # running on posix so should be able to use ls command
     24      if not os.path.isfile(target) : return True
     25      lsSource=run("ls --full-time "+source)
     26      lsTarget=run("ls --full-time "+target)
     27      #-rwxrwxrwx 1 jpf4 None 12309 2007-10-21 16:13:47.395793600 -0400 nightlyBuild.py
     28      rexBase=r"(-|r|w|x){10} . (.+) (.+) (.+) (\d\d\d\d-\d\d-\d\d .+) "
     29      rexSource=rexBase+source
     30      rexTarget=rexBase+target
     31      timeSource=(re.findall(rexSource,lsSource['stdout']))[0][4]
     32      timeTarget=(re.findall(rexTarget,lsTarget['stdout']))[0][4]
     33      return timeSource > timeTarget
     34     
     35  else :
     36    import distutils.dep_util
     37    return distutils.dep_util.newer(source,target)
     38
    539
    640#------------------------------------------------------------------------
     
    3872
    3973
    40 #  run = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    41 #
    42 #  # Wait for the process to return
    43 #  import thread, threading
    44 #  out, err = [''], ['']
    45 #  #out, err = "", ""
    46 #  out_ended, err_ended = threading.Event(), threading.Event()
    47 #
    48 #  def getOutput(output, lines, ended_event) :
    49 #    #for i in output.readlines() : lines.append(i)
    50 #    for i in output.readlines() :
    51 #      lines[0] = lines[0]+i
    52 #    ended_event.set()
    53 #
    54 #  out_thread = thread.start_new_thread(getOutput, (run.stdout, out, out_ended))
    55 #  err_thread = thread.start_new_thread(getOutput, (run.stderr, err, err_ended))
    56 #
    57 #  out_ended.wait()
    58 #  err_ended.wait()
    59 #
    60 #  returncode = run.wait()
    61 #
    62 #  retVal = { 'returnCode':returncode, 'stdout':out[0], 'stderr':err[0] }
    63 #  return retVal
    6474
     75
Note: See TracChangeset for help on using the changeset viewer.