@@ -58,26 +58,31 @@ def timestamp():
5858RALLY_ARG_SETTING_PATT2 = re .compile ('^--([ASUPWasupw][a-z]+)=(.+)\s*$' )
5959RALLY_CONFIG_FILE_PATT = re .compile ('^--(cfg|conf|config|rallyConfig)=(\S+)$' )
6060
61+ TRUTHY_VALUES = ['t' , 'true' , 'y' , 'yes' , '1' ]
62+ FALSEY_VALUES = ['f' , 'false' , 'n' , 'no' , '0' ]
63+
6164################################################################################
6265
63- def rallySettings (args ):
66+ def rallyWorkset (args ):
6467 """
68+ intended to supplant rallySettings as of pyral 2.0.x
69+
6570 priority order of Python Rally REST API server ident, credentials, workspace/project:
66- 1) command line args with --rallyServer, --rallyUser, --rallyPassword, --workspace, --project
71+ 1) command line args with --rallyServer, --rallyUser, --rallyPassword, --apikey, -- workspace, --project, --ping
6772 2) command line arg specifying a config file --rallyConfig=<config_file_name>
6873 or --config=<config_file_name>
6974 or --conf=<config_file_name>
7075 or --cfg=<config_file_name>
7176 3) ENV variable with location of rally-<version>.cfg --> RALLY_CONFIG
7277 4) current directory with rally-<version>.cfg
73- 5) RALLY_SERVER, RALLY_USER_NAME, RALLY_PASSWORD, RALLY_WORKSPACE, RALLY_PROJECT env VARS
78+ 5) RALLY_SERVER, RALLY_USER_NAME, RALLY_PASSWORD, APIKEY, RALLY_WORKSPACE, RALLY_PROJECT, RALLY_PING env VARS
7479 6) SERVER, USER_NAME, PASSWORD defined in this module
7580
7681 start by priming the return values with #6 and work your way up the priority ladder
7782 """
7883 # #6
7984 # start with the defaults defined in this module
80- server_creds = [SERVER , USER_NAME , PASSWORD , "default" , "default" ]
85+ server_creds = [SERVER , USER_NAME , PASSWORD , "" , " default" , "default" ]
8186
8287 def snarfSettings (targetFile , server_creds ):
8388 """
@@ -103,23 +108,33 @@ def snarfSettings(targetFile, server_creds):
103108 server_creds [1 ] = value
104109 elif item == 'PASSWORD' :
105110 server_creds [2 ] = value
106- elif item == 'WORKSPACE' :
111+ elif item == "APIKEY" :
107112 server_creds [3 ] = value
108- elif item == 'PROJECT ' :
113+ elif item == 'WORKSPACE ' :
109114 server_creds [4 ] = value
115+ elif item == 'PROJECT' :
116+ server_creds [5 ] = value
117+ elif item == 'RALLY_PING' :
118+ if value .lower () in TRUTHY_VALUES :
119+ os .environ ['RALLY_PING' ] = 'true'
120+ elif value .lower () in FALSEY_VALUES :
121+ os .environ ['RALLY_PING' ] = 'false'
122+ else :
123+ os .environ ['RALLY_PING' ] = 'true'
110124 cf .close ()
111- sc = "%s, %s, %s, %s, %s" % tuple (server_creds )
125+ sc = "%s, %s, %s, %s, %s, %s " % tuple (server_creds )
112126 return server_creds
113127 except Exception as ex :
114128 pass
115129
116130 # #5
117131 # if there are environment vars, use them
118132 #
119- for ix , name in enumerate (['RALLY_SERVER' , 'RALLY_USER' , 'RALLY_PASSWORD' , 'RALLY_WORKSPACE' , 'RALLY_PROJECT' ]):
133+ # purposely excluding RALLY_PING ...
134+ for ix , name in enumerate (['RALLY_SERVER' , 'RALLY_USER' , 'RALLY_PASSWORD' , 'APIKEY' , 'RALLY_WORKSPACE' , 'RALLY_PROJECT' ]):
120135 if name in os .environ :
121136 server_creds [ix ] = os .environ [name ]
122-
137+
123138 # #4
124139 # if there is a rally-<version>.cfg file in the current directory matching the WS_API_VERSION
125140 # load with contents of that file
@@ -151,7 +166,7 @@ def snarfSettings(targetFile, server_creds):
151166 # #1
152167 # now look at the args (from command line invocation)
153168 # grab any --rallyServer=?, --rallyUser=?, --rallyPassword=?, --rallyWorkspace=?, --rallyProject=? in args
154- # grab any --server=?, --user=?, --password=?, --workspace=?, --project=? in args
169+ # grab any --server=?, --user=?, --password=?, --apikey=?, -- workspace=?, --project=? --ping=? in args
155170 for arg in args :
156171 mo = RALLY_ARG_SETTING_PATT1 .match (arg )
157172 if mo :
@@ -162,10 +177,12 @@ def snarfSettings(targetFile, server_creds):
162177 server_creds [1 ] = value
163178 elif item == 'rallyPassword' :
164179 server_creds [2 ] = value
180+ #elif item = 'rallyApikey': # enable this if we ever decide that apikey arg should ever be specified as --rallyApikey
181+ # server_creds[3] = value
165182 elif item == 'rallyWorkspace' :
166- server_creds [3 ] = value
167- elif item == 'rallyProject' :
168183 server_creds [4 ] = value
184+ elif item == 'rallyProject' :
185+ server_creds [5 ] = value
169186
170187 mo = RALLY_ARG_SETTING_PATT2 .match (arg )
171188 if mo :
@@ -176,35 +193,42 @@ def snarfSettings(targetFile, server_creds):
176193 server_creds [1 ] = value
177194 elif item == 'password' :
178195 server_creds [2 ] = value
179- elif item == 'workspace ' :
196+ elif item == 'apikey ' :
180197 server_creds [3 ] = value
181- elif item == 'project ' :
198+ elif item == 'workspace ' :
182199 server_creds [4 ] = value
200+ elif item == 'project' :
201+ server_creds [5 ] = value
202+ elif item == 'ping' :
203+ if value .lower () in TRUTHY_VALUES :
204+ os .environ ['RALLY_PING' ] = 'true'
205+ elif value .lower () in FALSEY_VALUES :
206+ os .environ ['RALLY_PING' ] = 'false'
207+ else :
208+ os .environ ['RALLY_PING' ] = 'true'
183209
184210 return server_creds
185211
186- ###################################################################################################
212+ ################################################################################
187213
188- def rallyWorkset (args ):
214+ def rallySettings (args ):
189215 """
190- intended to supplant rallySettings as of pyral 2.0.x
191-
192216 priority order of Python Rally REST API server ident, credentials, workspace/project:
193- 1) command line args with --rallyServer, --rallyUser, --rallyPassword, --apikey, -- workspace, --project
217+ 1) command line args with --rallyServer, --rallyUser, --rallyPassword, --workspace, --project
194218 2) command line arg specifying a config file --rallyConfig=<config_file_name>
195219 or --config=<config_file_name>
196220 or --conf=<config_file_name>
197221 or --cfg=<config_file_name>
198222 3) ENV variable with location of rally-<version>.cfg --> RALLY_CONFIG
199223 4) current directory with rally-<version>.cfg
200- 5) RALLY_SERVER, RALLY_USER_NAME, RALLY_PASSWORD, APIKEY, RALLY_WORKSPACE, RALLY_PROJECT env VARS
224+ 5) RALLY_SERVER, RALLY_USER_NAME, RALLY_PASSWORD, RALLY_WORKSPACE, RALLY_PROJECT env VARS
201225 6) SERVER, USER_NAME, PASSWORD defined in this module
202226
203227 start by priming the return values with #6 and work your way up the priority ladder
204228 """
205229 # #6
206230 # start with the defaults defined in this module
207- server_creds = [SERVER , USER_NAME , PASSWORD , "" , " default" , "default" ]
231+ server_creds = [SERVER , USER_NAME , PASSWORD , "default" , "default" ]
208232
209233 def snarfSettings (targetFile , server_creds ):
210234 """
@@ -230,22 +254,20 @@ def snarfSettings(targetFile, server_creds):
230254 server_creds [1 ] = value
231255 elif item == 'PASSWORD' :
232256 server_creds [2 ] = value
233- elif item == "APIKEY" :
234- server_creds [3 ] = value
235257 elif item == 'WORKSPACE' :
236- server_creds [4 ] = value
258+ server_creds [3 ] = value
237259 elif item == 'PROJECT' :
238- server_creds [5 ] = value
260+ server_creds [4 ] = value
239261 cf .close ()
240- sc = "%s, %s, %s, %s, %s, %s " % tuple (server_creds )
262+ sc = "%s, %s, %s, %s, %s" % tuple (server_creds )
241263 return server_creds
242264 except Exception as ex :
243265 pass
244266
245267 # #5
246268 # if there are environment vars, use them
247269 #
248- for ix , name in enumerate (['RALLY_SERVER' , 'RALLY_USER' , 'RALLY_PASSWORD' , 'APIKEY' , ' RALLY_WORKSPACE' , 'RALLY_PROJECT' ]):
270+ for ix , name in enumerate (['RALLY_SERVER' , 'RALLY_USER' , 'RALLY_PASSWORD' , 'RALLY_WORKSPACE' , 'RALLY_PROJECT' ]):
249271 if name in os .environ :
250272 server_creds [ix ] = os .environ [name ]
251273
@@ -280,7 +302,7 @@ def snarfSettings(targetFile, server_creds):
280302 # #1
281303 # now look at the args (from command line invocation)
282304 # grab any --rallyServer=?, --rallyUser=?, --rallyPassword=?, --rallyWorkspace=?, --rallyProject=? in args
283- # grab any --server=?, --user=?, --password=?, --apikey=?, -- workspace=?, --project=? in args
305+ # grab any --server=?, --user=?, --password=?, --workspace=?, --project=? in args
284306 for arg in args :
285307 mo = RALLY_ARG_SETTING_PATT1 .match (arg )
286308 if mo :
@@ -291,12 +313,10 @@ def snarfSettings(targetFile, server_creds):
291313 server_creds [1 ] = value
292314 elif item == 'rallyPassword' :
293315 server_creds [2 ] = value
294- #elif item = 'rallyApikey': # enable this if we ever decide that apikey arg should ever be specified as --rallyApikey
295- # server_creds[3] = value
296316 elif item == 'rallyWorkspace' :
297- server_creds [4 ] = value
317+ server_creds [3 ] = value
298318 elif item == 'rallyProject' :
299- server_creds [5 ] = value
319+ server_creds [4 ] = value
300320
301321 mo = RALLY_ARG_SETTING_PATT2 .match (arg )
302322 if mo :
@@ -307,11 +327,12 @@ def snarfSettings(targetFile, server_creds):
307327 server_creds [1 ] = value
308328 elif item == 'password' :
309329 server_creds [2 ] = value
310- elif item == 'apikey' :
311- server_creds [3 ] = value
312330 elif item == 'workspace' :
313- server_creds [4 ] = value
331+ server_creds [3 ] = value
314332 elif item == 'project' :
315- server_creds [5 ] = value
333+ server_creds [4 ] = value
316334
317335 return server_creds
336+
337+ ###################################################################################################
338+ ###################################################################################################
0 commit comments