RoseFE_OpenAD

changeset 267:4d21d2b76d71

deal with blocked ping
author m_utkej@utke2.site
date Mon Nov 09 13:43:13 2009 -0600 (2009-11-09)
parents c2c21f20b857
children e425b4d69437
files bin/openadStatus
line diff
     1.1 --- a/bin/openadStatus	Mon Nov 02 09:24:33 2009 -0600
     1.2 +++ b/bin/openadStatus	Mon Nov 09 13:43:13 2009 -0600
     1.3 @@ -14,12 +14,23 @@
     1.4  import openadConfig
     1.5  sys.path.append(os.path.join(os.environ["OPENADROOT"],"tools","libpythontk"))
     1.6  import Repository
     1.7 +globPingTarget="www.rice.edu"
     1.8 +globNWTest=True
     1.9 +globSkipNWTest=False
    1.10  
    1.11  def netAvail() :
    1.12 -    ret=os.system("ping -c 1 -q terra.mcs.anl.gov > /dev/null 2>&1")
    1.13 +    global globSkipNWTest
    1.14 +    if (globSkipNWTest) : 
    1.15 +      return True
    1.16 +    global globNWTest
    1.17 +    if (not globNWTest): 
    1.18 +      return False
    1.19 +    global globPingTarget
    1.20 +    ret=os.system("ping -c 1 -q "+globPingTarget+" > /dev/null 2>&1")
    1.21      if (ret == 0) : 
    1.22  	return True
    1.23      else :
    1.24 +        globNWTest=False
    1.25  	return False	
    1.26  
    1.27  def isLink(path):
    1.28 @@ -63,6 +74,7 @@
    1.29      sys.stdout.flush()
    1.30  
    1.31  def main():
    1.32 +  global globPingTarget
    1.33    from optparse import OptionParser
    1.34    usage = '%prog [options]\n\tdisplays OpenAD repository status\n\tKind:   hg, svn or cvs\n\tR/W:    R=read-only, W=writeable, L=symbolic link\n\tLocal:  C=locally changed , U=locally pending updates (hg only) \n\tRemote: O=outgoing changes , I=incoming changes\n\tA \'?\' is shown when the network/server takes too long.'
    1.35    opt = OptionParser(usage=usage)
    1.36 @@ -72,6 +84,9 @@
    1.37    opt.add_option('-q','--quick',dest='quick',
    1.38                   help="don't check for uncommited changes or pending pushes",
    1.39                   action='store_true',default=False)
    1.40 +  opt.add_option('-s','--skipNetworkTest',dest='skipNetworkTest',
    1.41 +                 help="skip the network test (ping "+globPingTarget+") that we do to avoid waiting for repository commands when the network is unavailable, but sometimes pings are being blocked.",
    1.42 +                 action='store_true',default=False)
    1.43    opt.add_option('-t','--tagsOnly',dest='tagsOnly',
    1.44                   help="only list the repository and a version tag",
    1.45                   action='store_true',default=False)
    1.46 @@ -87,7 +102,12 @@
    1.47    doQuick=False
    1.48    if (options.verbose):
    1.49        sys.stdout.write("running for OPENADROOT="+os.environ["OPENADROOT"]+"\n")
    1.50 +  if (options.skipNetworkTest): 
    1.51 +      global globSkipNWTest
    1.52 +      globSkipNWTest=True
    1.53    try:
    1.54 +      if (not options.tagsOnly and  not netAvail() and not options.skipNetworkTest): 
    1.55 +	sys.stderr.write("WARNING: cannot ping "+globPingTarget+" - assuming network is unavailable (or try running with -s )\n")
    1.56        root=os.environ["OPENADROOT"]
    1.57        os.chdir(root)
    1.58        oaCfg=openadConfig.openadConfig(True,True,options.development)