aa86873a1b9db21febf28de22752ee27a5778730 gperez2 Wed Mar 30 15:53:42 2022 -0700 Adding a -s flag to suppress and reduce cron emails, no RM diff --git src/utils/qa/hubPublicAutoUpdate src/utils/qa/hubPublicAutoUpdate index c8089e4..9b58616 100755 --- src/utils/qa/hubPublicAutoUpdate +++ src/utils/qa/hubPublicAutoUpdate @@ -19,30 +19,32 @@ def parseArgs(): """ Parse the command line arguments. """ parser = argparse.ArgumentParser(description = __doc__, formatter_class=argparse.RawDescriptionHelpFormatter) optional = parser._action_groups.pop() required = parser.add_argument_group('required arguments') required.add_argument ("server", help = "Server from which to query the hubPublic table. Can be dev, hgwbeta, or rr.") optional.add_argument ("-t", "--test", dest = "testMode", default = False, action = "store_true", help = "Optional: Run in test mode. Print out any discrepancies but do not run any " + \ "commands.") + optional.add_argument ("-s", "--silent", dest = "silent", default = False, action = "store_true", + help = "Optional: Suppress output messages when hubs are not responding.") if (len(sys.argv) == 1): parser.print_usage() print("\nGiven a server (dev/hgwbeta/rr) will query hubPublic table URLs and verify that\n" + \ "the shortLabel, longLabel, dbCount and dbList matches what is in the hubPublic table.\n" + \ "Any inconsistencies will be automatically updated. Will print out the commands as\n" + \ "well as run them.\n\n" + \ "Can optionally be run in test mode where it will only print commands without executing.\n\n" + \ "Example run:\n" + \ " hubPublicAutoUpdate dev\n" + \ " hubPublicAutoUpdate hgwbeta -t\n" + \ " hubPublicAutoUpdate rr\n") exit(0) parser._action_groups.append(optional) options = parser.parse_args() return options @@ -140,35 +142,37 @@ def compareResults(hubPublicDic,currentHub,hub,hgsqlInput,testMode): """Compare the hubPublic values to the queried currentHub values and report""" if hubPublicDic[hub]['shortLabel'] != currentHub['shortLabel'].rstrip().lstrip(): printHgsql(hub,'shortLabel',escapeDoubleQuotesOnLabels(currentHub['shortLabel'].rstrip().lstrip()),hgsqlInput,testMode) if hubPublicDic[hub]['longLabel'] != currentHub['longLabel'].rstrip().lstrip(): printHgsql(hub,'longLabel',escapeDoubleQuotesOnLabels(currentHub['longLabel'].rstrip().lstrip()),hgsqlInput,testMode) if int(hubPublicDic[hub]['dbCount']) != int(currentHub['dbCount']): printHgsql(hub,'dbCount',currentHub['dbCount'],hgsqlInput,testMode) if set(hubPublicDic[hub]['dbList'][:-1].split(',')) != set(currentHub['dbList']): printHgsql(hub,'dbList',",".join(currentHub['dbList'])+",",hgsqlInput,testMode) -def hubPublicCompare(hubPublicDic,hgsqlInput,testMode): +def hubPublicCompare(hubPublicDic,hgsqlInput,testMode,silent): """Query hub.txt files and compare values to hubPublic values""" for hub in hubPublicDic.keys(): try: #Try for timeout connections currentHub = buildCurrentHubTxtDic(hub) currentHub = queryHubTxt(currentHub,hub) compareResults(hubPublicDic,currentHub,hub,hgsqlInput,testMode) except: + if not silent: print("The following hub has an error or is not responsive: "+str(hub)) def main(): """Initialize options and call other functions""" options = parseArgs() serverToQuery = options.server testMode = options.testMode + silent = options.silent hgsqlInput = evaluateServer(serverToQuery) hubPublicDic = buildPubHubDic(hgsqlInput) - hubPublicCompare(hubPublicDic,hgsqlInput,testMode) + hubPublicCompare(hubPublicDic,hgsqlInput,testMode,silent) main()