#! /usr/bin/env python import re, os, sys, time # Find the produtil package and load produtil.setup: try: import produtil.setup except ImportError as ie: altpath=os.path.join(os.path.dirname(os.path.realpath(__file__)),'produtil/NCEPLIBS-pyprodutil') if not os.path.isdir(altpath): fail('%s is missing and produtil is not in PYTHONPATH. Is your produtil/NCEPLIBS-pyprodutil external missing?'%(altpath,)) sys.path.append(altpath) import produtil.setup produtil.setup.setup(send_dbn=False,ologlevel=None) import produtil.cd from produtil.run import exe,runstr,run,alias,ExitStatusException ######################################################################## # Parse arguments comdir=sys.argv[1] logdir=os.path.abspath(os.path.join(os.path.dirname(comdir),'tmp/log')) stattxt=sys.argv[2] mode=sys.argv[3] timestamp=None just_status=False if len(sys.argv)>4: timestamp=int(sys.argv[4]) if mode=='status': just_status=True elif mode!='txt': sys.stderr.write('Warning: output mode %s is not supported. I will ' 'assume you meant "txt"'%(mode,)) def rtreport(line=''): if not just_status: print line def rtstatus(line,also_report=True): if also_report or just_status: print line def get_md5(md5file): with open(md5file,'rt') as f: line=f.readline() split=line.strip().split() if not split: return (None,None) if len(split)<2: return (split[0],None) else: return (split[0],split[1]) if timestamp is not None: rtreport('WORKFLOW STARTED AT %s (+%d)'%( time.ctime(timestamp),timestamp)) checkout_top=os.path.dirname(os.path.dirname(os.path.dirname( os.path.realpath(__file__)))) rtreport( 'Repository information:') rtreport() rtreport() try: with produtil.cd.NamedDir(checkout_top): if os.path.exists(os.path.join(checkout_top,'.svn')): rtreport( 'REPO TOP:') svn=alias(exe('svn')) info=alias(svn['info']) rtreport(runstr(info['.'])) status=runstr(svn['status',checkout_top]) for line in status.splitlines(): m=re.match('X\s+(.*)',line) if not m: continue rtreport('EXTERNAL %s:'%(m.group(1),)) rtreport(runstr(info[os.path.join(checkout_top,m.group(1))])) else: git_info=exe(os.path.abspath(os.path.join( os.path.dirname(__file__),'git_info.sh'))) rtreport(runstr(git_info)) except(ValueError,KeyError,ExitStatusException,EnvironmentError) as e: print 'WARNING: Could not complete subversion checks: '+str(e) itest=0 success=True finished=True build_count=0 tests_passed=0 tests_failed=0 builds_failed=0 builds_passed=0 with open(stattxt,'rt') as f: for line in f: m=re.match(r'''(?isx) (?P \d+ ) \s+ (?P \S+ ) \s+ (?P \S+ ) \s+ (?P \S+ ) \s+ (?P \S+ ) \s+ (?P \S+ ) \s+ (?P