From d99eb9d2551aba89f14a98ae77fa32945d392047 Mon Sep 17 00:00:00 2001 From: Peter Onyisi <ponyisi@utexas.edu> Date: Tue, 30 Jun 2020 19:14:20 +0200 Subject: [PATCH] flake8 fixes --- .../DataQualityUtils/scripts/DQFileMove.py | 4 +-- .../scripts/DQHistogramMerge.py | 4 --- .../scripts/DQHistogramPrintStatistics.py | 5 ++-- .../scripts/DQM_Tier0Wrapper_tf.py | 5 ++-- .../scripts/DQM_Tier0Wrapper_trf.py | 5 ++-- .../scripts/DQPostProcessTest.py | 1 - .../DataQualityUtils/scripts/DQWebDisplay.py | 3 +-- .../DataQualityUtils/scripts/DeMoLib.py | 2 +- .../DataQualityUtils/scripts/DeMoScan.py | 11 +++----- .../DataQualityUtils/scripts/DeMoSetup.py | 3 +-- .../DataQualityUtils/scripts/DeMoStatus.py | 10 +++---- .../DataQualityUtils/scripts/DeMoUpdate.py | 13 ++++----- .../DataQualityUtils/scripts/ScanHistFile.py | 4 +-- .../scripts/StandAloneDisplay.py | 3 +-- .../scripts/checkCorrelInHIST.py | 7 +++-- .../scripts/dq_make_web_display.py | 22 +++++++-------- .../DataQualityUtils/scripts/hancool.py | 1 - .../DataQualityUtils/scripts/hancool_histo.py | 1 - .../DataQualityUtils/scripts/hotSpotInHIST.py | 7 +++-- .../DataQualityUtils/scripts/hotSpotInTAG.py | 17 +++++------- .../scripts/mergePhysValFiles.py | 2 +- .../scripts/physval_make_web_display.py | 27 ++++++++++--------- .../scripts/readTier0LARNOISE.py | 3 +-- .../DataQualityUtils/scripts/readTier0TAGs.py | 3 +-- 24 files changed, 66 insertions(+), 97 deletions(-) diff --git a/DataQuality/DataQualityUtils/scripts/DQFileMove.py b/DataQuality/DataQualityUtils/scripts/DQFileMove.py index 22f4415e87b..ce27ecd0b2c 100755 --- a/DataQuality/DataQualityUtils/scripts/DQFileMove.py +++ b/DataQuality/DataQualityUtils/scripts/DQFileMove.py @@ -31,13 +31,13 @@ if __name__ == '__main__': try: cmod = importConfiguration(configModule) - except Exception as e: + except Exception: print("Could not import configuration module \'" + configModule + "\'") sys.exit(1) try: config = cmod.dqconfig - except Exception as e: + except Exception: print("Configuration object 'dqconfig' not defined in module \'" + configModule + "\'") sys.exit(1) diff --git a/DataQuality/DataQualityUtils/scripts/DQHistogramMerge.py b/DataQuality/DataQualityUtils/scripts/DQHistogramMerge.py index 895717d9dd1..ea34c7f01eb 100755 --- a/DataQuality/DataQualityUtils/scripts/DQHistogramMerge.py +++ b/DataQuality/DataQualityUtils/scripts/DQHistogramMerge.py @@ -4,10 +4,6 @@ from __future__ import print_function -## ***************************************************************************** -VERSION = '$Id: DQHistogramMerge.py 509709 2012-07-10 16:03:00Z vogel $' -## ***************************************************************************** - import DataQualityUtils.DQHistogramMergeMod as mod import sys, os diff --git a/DataQuality/DataQualityUtils/scripts/DQHistogramPrintStatistics.py b/DataQuality/DataQualityUtils/scripts/DQHistogramPrintStatistics.py index befb16aebd9..ce7510378d1 100755 --- a/DataQuality/DataQualityUtils/scripts/DQHistogramPrintStatistics.py +++ b/DataQuality/DataQualityUtils/scripts/DQHistogramPrintStatistics.py @@ -5,11 +5,11 @@ from __future__ import print_function import os ## Needed to correct ROOT behavior; see below -CWD = os.getcwd() +CWD = os.getcwd() # noqa: E402 import sys -import ROOT +import ROOT # noqa: F401 ## Importing gSystem may change the current directory to one of the ## command-line arguments; chdir to original directory to have ## predictable behavior @@ -45,4 +45,3 @@ if __name__ == "__main__": sys.exit(0) DQHistogramPrintStatistics( sys.argv[1] ) - diff --git a/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_tf.py b/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_tf.py index 375764d3f98..19d85c4b01f 100755 --- a/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_tf.py +++ b/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_tf.py @@ -56,7 +56,7 @@ ######################################################################### from __future__ import print_function -import sys, string, os.path, os, json, time, pprint, xmlrpclib, traceback +import sys, os.path, os, json, time, pprint, traceback from six.moves import xmlrpc_client as xmlrpclib import six if six.PY2: @@ -82,7 +82,7 @@ def getSubFileMap(fname, nevts=0) : return map def publish_success_to_mq(run, ptag, stream, incr, ami, procpass, hcfg, isprod): - import stomp, json, os, ssl + import stomp, json, ssl from DataQualityUtils import stompconfig dest='/topic/atlas.dqm.progress' conn=stomp.Connection([('atlas-mb.cern.ch', 61013)], **stompconfig.config()) @@ -553,4 +553,3 @@ if __name__ == "__main__": else : jsonfile = sys.argv[1][len('--argJSON='):] dq_trf_wrapper(jsonfile) - diff --git a/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_trf.py b/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_trf.py index d25eddb552a..b10788862ca 100755 --- a/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_trf.py +++ b/DataQuality/DataQualityUtils/scripts/DQM_Tier0Wrapper_trf.py @@ -53,7 +53,7 @@ ######################################################################### from __future__ import print_function -import sys, string, os.path, os, pickle, time, pprint, xmlrpclib +import sys, string, os.path, os, pickle, time, pprint from six.moves import xmlrpc_client as xmlrpclib #sami import hashlib @@ -80,7 +80,7 @@ def getFileMap(fname, dsname, nevts=0) : return map def publish_success_to_mq(run, ptag, stream, incr, ami, procpass, hcfg, isprod): - import stomp, json, os, ssl + import stomp, json, ssl from DataQualityUtils import stompconfig dest='/topic/atlas.dqm.progress' #conn=stomp.Connection([('atlas-mb.cern.ch', 61023)], use_ssl=True, @@ -505,4 +505,3 @@ if __name__ == "__main__": else : picklefile = sys.argv[1][len('--argdict='):] dq_combined_trf(picklefile) - diff --git a/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py b/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py index f5bec963cab..0098b62330d 100644 --- a/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py +++ b/DataQuality/DataQualityUtils/scripts/DQPostProcessTest.py @@ -6,7 +6,6 @@ from __future__ import print_function import sys -import ROOT from ROOT import gROOT gROOT.SetBatch(True) diff --git a/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py b/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py index 9db0f3bf7dd..b0fa5512339 100755 --- a/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py +++ b/DataQuality/DataQualityUtils/scripts/DQWebDisplay.py @@ -23,7 +23,7 @@ import ROOT ## Importing gSystem may change the current directory to one of the ## command-line arguments; chdir to original directory to have ## predictable behavior -from ROOT import gSystem +from ROOT import gSystem # noqa: F401 os.chdir(CWD) from DataQualityUtils.DQWebDisplayMod import DQWebDisplay @@ -94,4 +94,3 @@ if __name__ == "__main__": DQWebDisplay( inputFile, runAccumulating, config ) - diff --git a/DataQuality/DataQualityUtils/scripts/DeMoLib.py b/DataQuality/DataQualityUtils/scripts/DeMoLib.py index 6ea23e4690e..fe292d2b820 100644 --- a/DataQuality/DataQualityUtils/scripts/DeMoLib.py +++ b/DataQuality/DataQualityUtils/scripts/DeMoLib.py @@ -4,7 +4,7 @@ ################################################################## from ROOT import THStack -from ROOT import TCanvas,TLegend +from ROOT import TCanvas from ROOT import kYellow,kOrange,kRed,kBlue,kPink,kMagenta,kGreen,kSpring,kViolet,kAzure,kCyan,kTeal,kBlack #import gb diff --git a/DataQuality/DataQualityUtils/scripts/DeMoScan.py b/DataQuality/DataQualityUtils/scripts/DeMoScan.py index 7794275726a..279aa5a7a3b 100644 --- a/DataQuality/DataQualityUtils/scripts/DeMoScan.py +++ b/DataQuality/DataQualityUtils/scripts/DeMoScan.py @@ -12,10 +12,9 @@ from re import match from time import strftime,gmtime from ROOT import TFile -from ROOT import TH1F from ROOT import TCanvas from ROOT import kTeal -from ROOT import gStyle,gROOT,gPad +from ROOT import gStyle,gPad sys.path.append("/afs/cern.ch/user/l/larmon/public/prod/Misc") @@ -31,7 +30,6 @@ debug = False ######################################################################## ######################################################################## # Main script -import os,sys from argparse import RawTextHelpFormatter,ArgumentParser @@ -97,7 +95,7 @@ if len(args.parser_year) == 1: singleYear = True else: singleYear = False - if (options['plotDiff2tags']): + if args.parser_diff2tags: print("To compare two tags, you must choose only one year. Exiting...") sys.exit() @@ -263,9 +261,9 @@ for iYT in yearTagList: tmpLines = sorted(f2.readlines()) for iline in tmpLines: # Loop on all lines of the loss-[defect/veto].dat files if defVetoType[iDefVeto] == "Intolerable defect": - read = match("(\d+) \((\d+) ub-1.*\) -> (\d+.\d+) pb-1 \D+(\d+.\d+)\D+",iline) + read = match(r"(\d+) \((\d+) ub-1.*\) -> (\d+.\d+) pb-1 \D+(\d+.\d+)\D+",iline) else:# Veto loss is never recoverable (not tolerable defects) - read = match("(\d+) \((\d+) ub-1.*\) -> (\d+.\d+) pb-1",iline) + read = match(r"(\d+) \((\d+) ub-1.*\) -> (\d+.\d+) pb-1",iline) # retrieve the run number runnumber = int(read.group(1)) # If the runs filter is activated (i.e. runsFilter != 0), check if the runs must be filtered @@ -569,4 +567,3 @@ if (len(yearTagList) == 2 and options['plotDiff2tags'] and singleYear): c_diffTwoYT[defOrVeto_type].cd(2) leg_diffTwoYT[defOrVeto_type].SetHeader(suffixTitle[iSuffix]) leg_diffTwoYT[defOrVeto_type].Draw() - diff --git a/DataQuality/DataQualityUtils/scripts/DeMoSetup.py b/DataQuality/DataQualityUtils/scripts/DeMoSetup.py index 5c24d27d754..6a76277f723 100644 --- a/DataQuality/DataQualityUtils/scripts/DeMoSetup.py +++ b/DataQuality/DataQualityUtils/scripts/DeMoSetup.py @@ -5,7 +5,7 @@ ################################################################## from __future__ import print_function -import os,sys +import os import argparse parser = argparse.ArgumentParser(description='') @@ -32,4 +32,3 @@ if not os.path.exists(direct): os.system("mkdir %s"%direct) os.system("mkdir %s/Run"%direct) os.system("mkdir %s/Weekly"%direct) - diff --git a/DataQuality/DataQualityUtils/scripts/DeMoStatus.py b/DataQuality/DataQualityUtils/scripts/DeMoStatus.py index 95095be3fff..fe06c41ecf5 100644 --- a/DataQuality/DataQualityUtils/scripts/DeMoStatus.py +++ b/DataQuality/DataQualityUtils/scripts/DeMoStatus.py @@ -5,20 +5,18 @@ ################################################################## from __future__ import print_function -import os,sys -from time import localtime, strftime +import os,sys from ROOT import TFile -from ROOT import TProfile,TH1F from ROOT import TCanvas from ROOT import gStyle,gPad -from ROOT import kBlack,kOrange,kGreen +from ROOT import kBlack sys.path.append("/afs/cern.ch/user/l/larmon/public/prod/Misc") from gb import MakeTH1,SetXLabel,MakeTProfile -from DeMoLib import strLumi, plotStack, initialize +from DeMoLib import plotStack, initialize global debug debug = False @@ -66,7 +64,6 @@ def ATLASLabel(x,y,text=""): ######################################################################## # Main script from argparse import RawTextHelpFormatter,ArgumentParser -from ROOT import gROOT parser = ArgumentParser(description='',formatter_class=RawTextHelpFormatter) parser.add_argument('-y','--year',dest='parser_year',default = ["2018"],nargs='*',help='Year [Default: 2018]',action='store') @@ -317,4 +314,3 @@ if (yearTagNb >= 2 and (options['plotYearStats'] or options['plotYearStatsLarge' plotStack("veto--Year--%s"%legendHeader,h1YearTag_Veto,veto["all"],defectVeto["description"],h1YearTag_IntLuminosity,options['lumiNotPercent'],stackResults,canvasResults,legendResults,False,True,options['approvedPlots']) if options['approvedPlots']: ATLASLabel(0.1,0.81,"Internal") - diff --git a/DataQuality/DataQualityUtils/scripts/DeMoUpdate.py b/DataQuality/DataQualityUtils/scripts/DeMoUpdate.py index 7b23608d994..ea8e39fb962 100644 --- a/DataQuality/DataQualityUtils/scripts/DeMoUpdate.py +++ b/DataQuality/DataQualityUtils/scripts/DeMoUpdate.py @@ -10,7 +10,6 @@ from string import ljust import time from ROOT import TFile -from ROOT import TH1F,TProfile from ROOT import TCanvas,TPaveText from ROOT import kBlack,kOrange,kGreen from ROOT import gStyle @@ -18,7 +17,7 @@ from ROOT import gStyle import six.moves.xmlrpc_client as xmlrpclib sys.path.append("/afs/cern.ch/user/l/larmon/public/prod/Misc") -from LArMonCoolLib import GetLBTimeStamps,GetOnlineLumiFromCOOL,GetOfflineLumiFromCOOL,GetLBDuration,GetReadyFlag,GetNumberOfCollidingBunches +from LArMonCoolLib import GetLBTimeStamps,GetOnlineLumiFromCOOL,GetOfflineLumiFromCOOL,GetReadyFlag,GetNumberOfCollidingBunches from gb import MakeTH1,SetXLabel,MakeTProfile from DeMoLib import strLumi,plotStack,initialize @@ -72,8 +71,6 @@ def findLB(lbts,startOfVetoPeriod): # Find the lumiblock where a veto period sta ################################################################################################################################################ # print single run report. Only printing, no computation def singleRunReport(runNumber,dict1,dict2,directory,defects,veto,exactVetoComput): - import string - if dict1['signoff'] == "DONE" or dict1['signoff'] == "FINAL OK": repOnDisk = True f = open('%s/Run/%s.txt' % (directory,runNumber), 'w') @@ -541,8 +538,8 @@ for iVeto in veto["all"]: runSpec['AllRuns']['lumiVeto_%s'%iVeto] = 0. # Total luminosity rejected by each time veto if (len(runSpec) == 1): - print "I did not find any run in runList." - print "Please check the run range/options" + print("I did not find any run in runList.") + print("Please check the run range/options") ####################################################################################### #### Main loop over selected runs @@ -1050,8 +1047,8 @@ if (options['saveHistos']): # yearStats update # If new runs were added to period plots, save them if (options['updateYearStats'] and bool_newRunsInYearStats): - print "WARNING: I am going to update the %s stats with the following runs:"%(options['year']) - print "NB: only runs fully signed off are considered" + print("WARNING: I am going to update the %s stats with the following runs:"%(options['year'])) + print("NB: only runs fully signed off are considered") for irun in runSpec.keys(): if (irun != "AllRuns"): if runSpec[irun]['newInYearStats']: diff --git a/DataQuality/DataQualityUtils/scripts/ScanHistFile.py b/DataQuality/DataQualityUtils/scripts/ScanHistFile.py index 9ca71ad3c03..f6bf0c5a9c0 100755 --- a/DataQuality/DataQualityUtils/scripts/ScanHistFile.py +++ b/DataQuality/DataQualityUtils/scripts/ScanHistFile.py @@ -57,7 +57,7 @@ def _dolsr(dir): del dirobj elif keyClass.InheritsFrom("TTree"): currObj=key.ReadObj() - if currObj == None: + if currObj is None: print("WARNING TTree Object \"%s\" in file:directory \"%s\" is corrupt "\ "keylen=%s numbytes=%s objlen=%s fseekkey=%s"%(name,dir.GetPath(),key.GetKeylen(), key.GetNbytes(),key.GetObjlen(),key.GetSeekKey())) @@ -80,7 +80,7 @@ def _dolsr(dir): del currObj else: currObj=key.ReadObj() - if currObj == None: + if currObj is None: print("WARNING Object \"%s\" in file:directory \"%s\" is corrupt "\ "keylen=%s numbytes=%s objlen=%s fseekkey=%s"%(name,dir.GetPath(),key.GetKeylen(), key.GetNbytes(),key.GetObjlen(),key.GetSeekKey())) diff --git a/DataQuality/DataQualityUtils/scripts/StandAloneDisplay.py b/DataQuality/DataQualityUtils/scripts/StandAloneDisplay.py index 168273f7320..5b032e1fe3e 100755 --- a/DataQuality/DataQualityUtils/scripts/StandAloneDisplay.py +++ b/DataQuality/DataQualityUtils/scripts/StandAloneDisplay.py @@ -9,7 +9,7 @@ CWD = os.getcwd() import sys -import ROOT +import ROOT # noqa: F401 ## Importing gSystem may change the current directory to one of the ## command-line arguments; chdir to original directory to have ## predictable behavior @@ -268,4 +268,3 @@ if __name__ == "__main__": html_dir=sys.argv[2] # destination directory for html files name=resultsFile handi( name, resultsFile, html_dir ) - diff --git a/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py b/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py index a11368e025a..c891d11c372 100644 --- a/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py +++ b/DataQuality/DataQualityUtils/scripts/checkCorrelInHIST.py @@ -35,15 +35,14 @@ # Author : Benjamin Trocme (LPSC Grenoble) / 2017 from __future__ import print_function -import os, sys -import string +import os, sys import argparse from six.moves import xmlrpc_client as xmlrpclib from DataQualityUtils import pathExtract -from ROOT import TFile,TCanvas,TBox,TPaveText,TColor -from ROOT import TH1,TH2,TH1I,TH1D,TH2D +from ROOT import TFile,TCanvas,TBox,TPaveText +from ROOT import TH1D,TH2D from ROOT import kBlue,kGreen,kRed from ROOT import gStyle diff --git a/DataQuality/DataQualityUtils/scripts/dq_make_web_display.py b/DataQuality/DataQualityUtils/scripts/dq_make_web_display.py index 60193216235..50366f2df8b 100755 --- a/DataQuality/DataQualityUtils/scripts/dq_make_web_display.py +++ b/DataQuality/DataQualityUtils/scripts/dq_make_web_display.py @@ -12,8 +12,7 @@ from __future__ import print_function #HANDIR='/afs/cern.ch/user/a/atlasdqm/dqmdisk/han_results/fastphysmon/1' -from DQConfMakerBase.DQElements import * -from DQConfMakerBase.Helpers import IDHelper, make_thresholds +from DQConfMakerBase.DQElements import DQReference, DQRegion, DQAlgorithm from DQHanConfMaker.hanwriter import writeHanConfiguration import ROOT @@ -57,21 +56,21 @@ def prune(dqregion): False if we should not """ params = dqregion.getDQParameters() - if params == None: + if params is None: params = [] subregions = dqregion.getSubRegions() - if subregions == None: + if subregions is None: subregions = [] else: subregions = subregions[:] # kill subregions for sr in subregions: - if sr == None: + if sr is None: continue if prune(sr): dqregion.delRelation('DQRegions', sr) subregions = dqregion.getSubRegions() - if subregions == None: + if subregions is None: subregions = [] if len(subregions) + len(params) == 0: return True @@ -80,10 +79,10 @@ def prune(dqregion): def paramcount(dqregion): params = dqregion.getDQParameters() - if params == None: + if params is None: params = [] subregions = dqregion.getSubRegions() - if subregions == None: + if subregions is None: subregions = [] return len(params) + sum([paramcount(region) for region in subregions]) @@ -124,6 +123,7 @@ def super_process(fname, options): hanoutput = None failed = False + prebuilt_hcfg = False @contextlib.contextmanager def tmpdir(): @@ -184,14 +184,14 @@ def super_process(fname, options): os.unlink(hanconfig) os.unlink(hanhcfg) os.unlink(hanoutput) - except: + except Exception: pass return not failed if __name__=="__main__": - import sys, optparse, shutil + import sys, optparse parser = optparse.OptionParser(usage='usage: %prog [options] inputfile run') parser.add_option('--webdir', default='/afs/cern.ch/user/a/atlasdqm/dqmdisk/han_results/fastphysmon', help='Change directory to store web display files') @@ -217,7 +217,7 @@ if __name__=="__main__": sys.exit(1) rv = super_process(fname, options) - if rv == True: + if rv: sys.exit(0) else: sys.exit(1) diff --git a/DataQuality/DataQualityUtils/scripts/hancool.py b/DataQuality/DataQualityUtils/scripts/hancool.py index 8ba1bf5e48a..5f7e77af8a3 100755 --- a/DataQuality/DataQualityUtils/scripts/hancool.py +++ b/DataQuality/DataQualityUtils/scripts/hancool.py @@ -52,4 +52,3 @@ if __name__ == "__main__": db_tag = "HEAD" mod.hancool(runNumber,filePath,dbConnection,dqmfOfl, db_tag) - diff --git a/DataQuality/DataQualityUtils/scripts/hancool_histo.py b/DataQuality/DataQualityUtils/scripts/hancool_histo.py index c17e1bb77ec..a28967c4b55 100755 --- a/DataQuality/DataQualityUtils/scripts/hancool_histo.py +++ b/DataQuality/DataQualityUtils/scripts/hancool_histo.py @@ -62,4 +62,3 @@ if __name__ == "__main__": dbTagName = "DetStatusDQMFOFLH-FDR2-02" mod.hancool_histo( inputFilePath, input_run, dbConnectionHisto,dqmfOflHisto, dbTagName) - diff --git a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py index e5d13f633f0..d11dbb687dc 100644 --- a/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py +++ b/DataQuality/DataQualityUtils/scripts/hotSpotInHIST.py @@ -32,15 +32,14 @@ # -g, --grl Look for Calo/LAr/Tile defects set in suspicious LBs # Author : Benjamin Trocme (LPSC Grenoble) / 2015-2016 -import os, sys -import string +import os, sys import argparse from six.moves import xmlrpc_client as xmlrpclib from DataQualityUtils import pathExtract -from ROOT import TFile,TCanvas,TBox,TColor,TLegend -from ROOT import TH1,TH2,TH1I +from ROOT import TFile,TCanvas,TBox,TLegend,TLine,TArrow +from ROOT import TH1I from ROOT import kBlue,kGreen,kOrange,kMagenta,kCyan,kRed from ROOT import gStyle diff --git a/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py b/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py index c3763ffa1f5..e8cfb30f075 100644 --- a/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py +++ b/DataQuality/DataQualityUtils/scripts/hotSpotInTAG.py @@ -20,19 +20,14 @@ from __future__ import print_function -import os, sys -import string,math +import sys from math import fabs import argparse -from DataQualityUtils import pathExtract - -import ROOT -from ROOT import * -from ROOT import gROOT, gDirectory -from ROOT import gStyle, TCanvas, TString -from ROOT import TFile, TTree -from ROOT import TH1F,TH2F,TBrowser -from ROOT import TPaveText +from DataQualityUtils import pathExtract, returnFilesPath + +from ROOT import gStyle, TCanvas +from ROOT import TChain +from ROOT import TH1D, TH2D, TH1I # Analysis functions=========================================================================================================== def analyzeTree(): diff --git a/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py b/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py index 2ff96586749..e246ea68b85 100755 --- a/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py +++ b/DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py @@ -9,7 +9,7 @@ #---------------------------------------------------------------------- from __future__ import print_function -import getopt,os,sys,glob,argparse,ROOT,time +import os,glob,argparse,ROOT,time start = time.clock() diff --git a/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py b/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py index 94c0b55c76d..8b29374ed54 100755 --- a/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py +++ b/DataQuality/DataQualityUtils/scripts/physval_make_web_display.py @@ -11,8 +11,8 @@ Adapted for physics validation 14 May 2014 from __future__ import print_function -from DQConfMakerBase.DQElements import * -from DQConfMakerBase.Helpers import IDHelper, make_thresholds +from DQConfMakerBase.DQElements import DQRegion, DQReference, DQAlgorithm, DQAlgorithmParameter +from DQConfMakerBase.Helpers import make_thresholds from DataQualityUtils.hanwriter import writeHanConfiguration import ROOT @@ -30,10 +30,10 @@ algorithmparameters = [DQAlgorithmParameter('AuxAlgName--Chi2Test_Chi2_per_NDF', # Edit this to change thresholds thresh = make_thresholds('Chi2_per_NDF', 1.0, 1.50, 'Chi2Thresholds') + def recurse(rdir, dqregion, ignorepath, modelrefs=[], displaystring='Draw=PE', displaystring2D='Draw=COLZ', regex=None, startpath=None, hists=None, manglefunc=None): - import re if manglefunc is None: - manglefunc = lambda a, b: a + manglefunc = lambda a, b: a # noqa: E731 for key in rdir.GetListOfKeys(): cl = key.GetClassName(); rcl = ROOT.TClass.GetClass(cl) if ' ' in key.GetName(): @@ -99,21 +99,21 @@ def prune(dqregion): False if we should not """ params = dqregion.getDQParameters() - if params == None: + if params is None: params = [] subregions = dqregion.getSubRegions() - if subregions == None: + if subregions is None: subregions = [] else: subregions = subregions[:] # kill subregions for sr in subregions: - if sr == None: + if sr is None: continue if prune(sr): dqregion.delRelation('DQRegions', sr) subregions = dqregion.getSubRegions() - if subregions == None: + if subregions is None: subregions = [] if len(subregions) + len(params) == 0: return True @@ -122,10 +122,10 @@ def prune(dqregion): def paramcount(dqregion): params = dqregion.getDQParameters() - if params == None: + if params is None: params = [] subregions = dqregion.getSubRegions() - if subregions == None: + if subregions is None: subregions = [] return len(params) + sum([paramcount(region) for region in subregions]) @@ -203,6 +203,7 @@ def super_process(fname, options): hanoutput = None failed = False + prebuilt_hcfg = False @contextlib.contextmanager def tmpdir(): @@ -271,14 +272,14 @@ def super_process(fname, options): os.unlink(hanconfig) os.unlink(hanhcfg) os.unlink(hanoutput) - except: + except Exception: pass return not failed if __name__=="__main__": - import sys, optparse, shutil, os + import sys, optparse, os os.environ['TDAQ_ERS_NO_SIGNAL_HANDLERS']='1' parser = optparse.OptionParser(usage='usage: %prog [options] inputfile') parser.add_option('--reffile', default=None, @@ -332,7 +333,7 @@ if __name__=="__main__": thresh = make_thresholds('P', 0.05, 0.01, 'pThresholds') rv = super_process(fname, options) - if rv == True: + if rv: sys.exit(0) else: sys.exit(1) diff --git a/DataQuality/DataQualityUtils/scripts/readTier0LARNOISE.py b/DataQuality/DataQualityUtils/scripts/readTier0LARNOISE.py index 0d5027ff051..fd2744a7378 100644 --- a/DataQuality/DataQualityUtils/scripts/readTier0LARNOISE.py +++ b/DataQuality/DataQualityUtils/scripts/readTier0LARNOISE.py @@ -17,7 +17,7 @@ import argparse from DataQualityUtils import pathExtract from six.moves import xmlrpc_client as xmlrpclib -from ROOT import TFile,TBrowser,TChain +from ROOT import TChain from ROOT import gStyle gStyle.SetPalette(1) @@ -72,4 +72,3 @@ if entries != 0: print("The chained tree contains %d entries"%(entries)) else: print("Empty chain...") - diff --git a/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py b/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py index 2b07ad25db8..60e2a4173b3 100644 --- a/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py +++ b/DataQuality/DataQualityUtils/scripts/readTier0TAGs.py @@ -17,7 +17,7 @@ import argparse from DataQualityUtils import pathExtract from six.moves import xmlrpc_client as xmlrpclib -from ROOT import TFile,TChain +from ROOT import TChain from ROOT import gStyle gStyle.SetPalette(1) @@ -72,4 +72,3 @@ if entries != 0: print("The chained tree contains %d entries"%(entries)) else: print("Empty chain...") - -- GitLab