Skip to content

Commit e45ae22

Browse files
committed
adjusted detection of --ping command line arg and RALLY_PING environment variable setting, upped package version to 1.2.0 in setup.py
1 parent 2c142ba commit e45ae22

File tree

8 files changed

+409
-64
lines changed

8 files changed

+409
-64
lines changed

build_dist.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
'get_attachments.py',
3737
'get_schedulable_artifacts.py',
3838
'add_tcrs.py',
39-
'defrevs.py'
39+
'defrevs.py',
40+
'updtag.py'
4041
]
4142
DOC_FILES = ['doc/Makefile',
4243
'doc/source/conf.py',
@@ -67,6 +68,8 @@
6768
'test/test_search.py',
6869
'test/test_wksprj_setting.py',
6970
'test/test_attachments.py',
71+
'test/test_workspaces.py'
72+
'test/test_ranking.py'
7073
]
7174

7275
################################################################################

pyral/config.py

Lines changed: 57 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,31 @@ def timestamp():
5858
RALLY_ARG_SETTING_PATT2 = re.compile('^--([ASUPWasupw][a-z]+)=(.+)\s*$')
5959
RALLY_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+
###################################################################################################

pyral/context.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -825,6 +825,7 @@ class Pinger(object):
825825
Response to the ping command results in the ping method returning True,
826826
otherwise a False is returned
827827
"""
828+
called = False
828829
MAX_PING_ATTEMPTS = 2
829830
DEFAULT_PING_TIMEOUT = 6
830831
ping_timeout = os.getenv('PYRAL_PING_TIMEOUT', None)
@@ -843,6 +844,7 @@ class Pinger(object):
843844

844845
@classmethod
845846
def ping(self, target):
847+
Pinger.called = True
846848
plat_ident = platform.system()
847849
if plat_ident.startswith('CYGWIN'):
848850
plat_ident = 'Cygwin'

pyral/restapi.py

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -175,23 +175,28 @@ class Rally(object):
175175
MAX_ATTACHMENT_SIZE = 50000000 # approx 50 MB
176176

177177
def __init__(self, server=SERVER, user=None, password=None, apikey=None,
178-
version=WS_API_VERSION, warn=True, server_ping=True,
178+
version=WS_API_VERSION, warn=True, server_ping=None,
179179
isolated_workspace=False, **kwargs):
180-
self.server = server
181-
self.user = user or USER_NAME
182-
self.password = password or PASSWORD
183-
self.apikey = apikey
184-
self.version = WS_API_VERSION # we only support v2.0 now
185-
self._inflated = False
186-
self.service_url = "%s://%s/%s" % (PROTOCOL, self.server, WEB_SERVICE % self.version)
187-
self.schema_url = "%s://%s/%s" % (PROTOCOL, self.server, SCHEMA_SERVICE % self.version)
188-
self.hydration = "full"
189-
self._sec_token = None
190-
self._log = False
191-
self._logDest = None
192-
self._logAttrGet = False
193-
self._warn = warn
194-
self._server_ping = server_ping
180+
self.server = server
181+
self.user = user or USER_NAME
182+
self.password = password or PASSWORD
183+
self.apikey = apikey
184+
self.version = WS_API_VERSION # we only support v2.0 now
185+
self._inflated = False
186+
self.service_url = "%s://%s/%s" % (PROTOCOL, self.server, WEB_SERVICE % self.version)
187+
self.schema_url = "%s://%s/%s" % (PROTOCOL, self.server, SCHEMA_SERVICE % self.version)
188+
self.hydration = "full"
189+
self._sec_token = None
190+
self._log = False
191+
self._logDest = None
192+
self._logAttrGet = False
193+
self._warn = warn
194+
self._server_ping = True # this is the default for 1.2.0
195+
if 'RALLY_PING' in os.environ:
196+
if os.environ['RALLY_PING'].lower() in ['f', 'false', 'n', 'no', '0']:
197+
self._server_ping = False
198+
if server_ping == False:
199+
self._server_ping = False
195200
self.isolated_workspace = isolated_workspace
196201
config = {}
197202
if kwargs and 'debug' in kwargs and kwargs.get('debug', False):
@@ -229,7 +234,8 @@ def __init__(self, server=SERVER, user=None, password=None, apikey=None,
229234

230235
global _rallyCache
231236

232-
self.contextHelper = RallyContextHelper(self, self.server, self.user, self.password or self.apikey, self._server_ping)
237+
self.contextHelper = RallyContextHelper(self, self.server, self.user, self.password or self.apikey,
238+
self._server_ping)
233239
_rallyCache[self.contextHelper.context] = {'rally' : self }
234240
wksp = None
235241
proj = None

rallyfire.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import sys
1111

1212
from pyral import Rally, rallyWorkset
13+
from pyral import context
1314

1415
#################################################################################################
1516

@@ -41,21 +42,21 @@ def main(args):
4142

4243
project = rally.getProject()
4344
print("Project : %s " % project.Name)
44-
#print "Project : %12.12s %-18.18s (%s)" % (project.oid, project.Name, project.ref)
45+
#print("Project : %12.12s %-18.18s (%s)" % (project.oid, project.Name, project.ref))
4546

4647
# uncomment this to see all of your accessible workspaces and projects
4748
# workspaces = rally.getWorkspaces()
4849
# for workspace in workspaces:
49-
# print " ", workspace.Name
50+
# print(" ", workspace.Name)
5051
# projects = rally.getProjects(workspace=workspace.Name)
5152
# if projects:
52-
# print ""
53-
# print " Projects:"
53+
# print("")
54+
# print(" Projects:")
5455
# for project in projects:
55-
# print " ", project.Name
56+
# print(" ", project.Name)
5657
# else:
57-
# print " No projects"
58-
# print ""
58+
# print(" No projects")
59+
# print("")
5960

6061
sys.exit(0)
6162

setup.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
from setuptools import setup
1313

1414
PACKAGE = 'pyral'
15-
VERSION = '1.1.1'
15+
VERSION = '1.2.0'
1616
OFFICIAL_NAME = 'Python toolkit for Rally REST API'
1717
PKG_URL_NAME = 'python-toolkit-rally-rest-api'
1818
AUTHOR = 'Kip Lehman (Rally Software Development)'
@@ -21,7 +21,7 @@
2121
GITHUB_DISTS = '%s/blob/master/dists' % GITHUB_SITE
2222
DOWNLOADABLE_ZIP = '%s/%s-%s.zip' % (GITHUB_DISTS, PACKAGE, VERSION)
2323

24-
MINIMUM_REQUESTS_VERSION = '2.0.0'
24+
MINIMUM_REQUESTS_VERSION = '2.3.0'
2525

2626
setup(name=PACKAGE,
2727
version=VERSION,
@@ -33,7 +33,7 @@
3333
long_description=open('README.rst').read(),
3434
packages=[PACKAGE],
3535
license='BSD',
36-
requires=["python (< 3.0)"],
36+
#requires=["python"],
3737
#install_requires=['requests>=%s' % MINIMUM_REQUESTS_VERSION],
3838
classifiers=[
3939
'Development Status :: 5 - Production/Stable',
@@ -44,6 +44,7 @@
4444
'Programming Language :: Python',
4545
'Programming Language :: Python :: 2.6',
4646
'Programming Language :: Python :: 2.7',
47+
'Programming Language :: Python :: 3.5',
4748
'Topic :: Internet :: WWW/HTTP',
4849
'Topic :: Software Development :: Libraries',
4950
],

0 commit comments

Comments
 (0)