ATLAS Offline Software
Loading...
Searching...
No Matches
python.LArBadChannelBrowserTools Namespace Reference

Functions

 ChooseOptionFromList (sTitle, sMessage, sPrompt, sChoiceList, iPlusMinus, bPlusMinus, optionDict)
 TypeEnterToContinue (sMessage)
 YesNoQuestion (sMessage)

Function Documentation

◆ ChooseOptionFromList()

python.LArBadChannelBrowserTools.ChooseOptionFromList ( sTitle,
sMessage,
sPrompt,
sChoiceList,
iPlusMinus,
bPlusMinus,
optionDict )

Definition at line 4 of file LArBadChannelBrowserTools.py.

4def ChooseOptionFromList(sTitle,sMessage,sPrompt,sChoiceList,iPlusMinus,bPlusMinus,optionDict):
5
6 print ("")
7 print (sTitle)
8
9 if bPlusMinus is False:
10 for index,s in enumerate(sChoiceList):
11 print ("%3d : %-20s" % (index+iPlusMinus,s))
12 else:
13 for index,s in enumerate(sChoiceList):
14 print ("%3d/%3d : %-20s" % (index+iPlusMinus,-index,s))
15
16 # option menu
17 sMenu=""
18 for s,v in optionDict:
19 sMenu=sMenu+s+" "+v+" "
20 if sMenu!="":
21 print ("\n"+sMenu)
22
23 bValidResponse=False
24 while bValidResponse is False:
25
26 print (" .. "+sPrompt+" > ", end='')
27 tty = open("/dev/tty", "r+")
28 rep=tty.readline()
29 rep=rep.strip()
30
31 # response is in option list
32 for s,v in optionDict:
33 if rep==s:
34 return rep
35
36 # convert response to integer
37 try:
38 iResponse=int(rep)
39
40 # reponse in indexes
41 if bPlusMinus is False:
42 if iResponse in range(iPlusMinus, len(sChoiceList)+iPlusMinus):
43 return iResponse
44
45 # reponse in indexes
46 if bPlusMinus is True:
47 if iResponse in range(iPlusMinus, len(sChoiceList)+iPlusMinus+1):
48 return iResponse
49 if iResponse in range(-len(sChoiceList)+iPlusMinus,iPlusMinus-1):
50 return iResponse
51
52 print ("WARNING : response out of range")
53
54 except Exception:
55 print ("???")
56
57

◆ TypeEnterToContinue()

python.LArBadChannelBrowserTools.TypeEnterToContinue ( sMessage)

Definition at line 58 of file LArBadChannelBrowserTools.py.

58def TypeEnterToContinue(sMessage):
59
60 if sMessage!="":
61 print (sMessage)
62 print (" .. Type ENTER to continue > ", end='')
63 tty = open("/dev/tty", "r+")
64 tty.readline()
65
66

◆ YesNoQuestion()

python.LArBadChannelBrowserTools.YesNoQuestion ( sMessage)

Definition at line 67 of file LArBadChannelBrowserTools.py.

67def YesNoQuestion(sMessage):
68
69 print ("")
70 print (sMessage+" [y/n] :", end='')
71 tty = open("/dev/tty", "r+")
72 rep=tty.readline()
73 rep=rep.strip()
74
75 if rep=="y" or rep=="Y":
76 return 1
77 return 0
78
79
80
81 from ROOT import TSQLServer
82 def getNextAtlasRunNumber(self):
83 """
84 Returns the next free ATLAS run number
85 """
86
87 runNum = -1
88 server = "oracle://localhost/atlr"
89 statement = "select MAX(RUNNUMBER) FROM atlas_run_number.RUNNUMBER"
90 db = TSQLServer.Connect(server,"atlas_run_number_r","07-Run.Num.rEaDeR")
91 if not db or not db.IsConnected():
92 raise(Exception("Problem connecting to run number server \"%s\"" % server))
93 stmt = db.Statement(statement)
94 if stmt.Process():
95 stmt.StoreResult()
96 stmt.NextResultRow()
97 runNum = (stmt.GetUInt(0)+1)
98 else:
99 raise(Exception("Error in processing statement \"%s\"" % statement ))
100 db.Close()
101 return runNum
102
103
104