Skip to content

Commit aa06e0a

Browse files
committed
yet more fine-tuning prior to release
1 parent df13d05 commit aa06e0a

5 files changed

Lines changed: 156 additions & 22 deletions

File tree

examples/get_artifact.py

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env python
2+
3+
#################################################################################################
4+
#
5+
# get_artifact.py -- Get info for a specific instance of a Rally type
6+
# identified either by a FormattedID value
7+
#
8+
USAGE = """
9+
Usage: get_artifact.py <FormattedID>
10+
"""
11+
#################################################################################################
12+
13+
import sys
14+
import re
15+
import string
16+
17+
from pyral import Rally, rallyWorkset
18+
19+
#################################################################################################
20+
21+
errout = sys.stderr.write
22+
23+
STORY_ALIASES = ['Story', 'UserStory', 'User Story']
24+
25+
ARTIFACT_TYPE = { 'DE' : 'Defect',
26+
'TA' : 'Task',
27+
'TC' : 'TestCase',
28+
'US' : 'HierarchicalRequirement',
29+
'S' : 'HierarchicalRequirement',
30+
'F' : 'Feature',
31+
'I' : 'Initiative',
32+
'T' : 'Theme',
33+
}
34+
35+
FORMATTED_ID_PATT = re.compile(r'(?P<prefix>[A-Z]+)\d+')
36+
37+
COMMON_ATTRIBUTES = ['_type', 'oid', '_ref', '_CreatedAt', '_hydrated', 'Name']
38+
39+
#################################################################################################
40+
41+
def main(args):
42+
options = [opt for opt in args if opt.startswith('--')]
43+
args = [arg for arg in args if arg not in options]
44+
server, username, password, apikey, workspace, project = rallyWorkset(options)
45+
print(f'server: {server}')
46+
print(f'apikey: {apikey}')
47+
print(f'workspace: {workspace}')
48+
print(f'project : {project}')
49+
if apikey:
50+
#rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
51+
rally = Rally(server, apikey=apikey, workspace=workspace)
52+
else:
53+
#rally = Rally(server, user=username, password=password, workspace=workspace, project=project)
54+
rally = Rally(server, user=username, password=password, workspace=workspace)
55+
56+
rally.enableLogging('rally.hist.artifact') # name of file you want logging to go to
57+
58+
if len(args) != 1:
59+
errout(USAGE)
60+
sys.exit(2)
61+
ident = args.pop(0)
62+
63+
mo = FORMATTED_ID_PATT.match(ident)
64+
if mo:
65+
ident_query = 'FormattedID = "%s"' % ident
66+
else:
67+
errout('ERROR: Unable to detect a valid Rally FormattedID in your arg: %s\n' % ident)
68+
sys.exit(3)
69+
mo = re.match(r'^(?P<art_abbrev>DE|S|US|TA|TC|F|I|T)\d+$', ident)
70+
if not mo:
71+
errout('ERROR: Unable to extract a valid Rally artifact type abbrev in %s' % ident)
72+
sys.exit(4)
73+
art_abbrev = mo.group('art_abbrev')
74+
entity_name = ARTIFACT_TYPE[art_abbrev]
75+
76+
response = rally.get(entity_name, fetch=True, query=ident_query, workspace=workspace)
77+
78+
if response.errors:
79+
errout("Request could not be successfully serviced, error code: %d\n" % response.status_code)
80+
errout("\n".join(response.errors))
81+
sys.exit(1)
82+
83+
if response.resultCount == 0:
84+
errout('No item found for %s %s\n' % (entity_name, ident))
85+
sys.exit(4)
86+
elif response.resultCount > 1:
87+
errout('WARNING: more than 1 item returned matching your criteria\n')
88+
sys.exit(5)
89+
90+
for item in response:
91+
print(item.details())
92+
93+
#################################################################################################
94+
#################################################################################################
95+
96+
if __name__ == '__main__':
97+
main(sys.argv[1:])

setup.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
import sys
5-
64
#try:
75
# from distutils2.core import setup
86
#except:
@@ -20,12 +18,15 @@
2018
AUTHOR = 'Kip Lehman (Broadcom, Enterprise Software Division)'
2119
AUTHOR_EMAIL = 'kip.lehman@broadcom.com'
2220
LICENSE = 'BSD'
21+
KEYWORDS = ['rally', 'api']
2322
GITHUB_SITE = 'https://github.com/RallyTools/RallyRestToolkitForPython'
2423
GITHUB_DISTS = '%s/raw/master/dists' % GITHUB_SITE
2524
DOWNLOADABLE_ZIP = '%s/%s-%s.zip' % (GITHUB_DISTS, PACKAGE, VERSION)
2625
SHORT_DESCRIPTION = 'README.short'
2726
FULL_DESCRIPTION = 'README.rst'
28-
KEYWORDS = ['rally', 'api']
27+
LONG_DESCRIPTION = ""
28+
with open(FULL_DESCRIPTION, 'r') as d:
29+
LONG_DESCRIPTION = d.read()
2930

3031
MINIMUM_REQUESTS_VERSION = '2.12.5' # although 2.22.x is recommended
3132
REQUIRES = ['six',
@@ -55,10 +56,11 @@
5556
author_email=AUTHOR_EMAIL,
5657
url=GITHUB_SITE,
5758
download_url=DOWNLOADABLE_ZIP,
58-
long_description=open(FULL_DESCRIPTION, 'r').read(),
59+
long_description=LONG_DESCRIPTION,
60+
long_description_type='text/x-rst',
5961
license=LICENSE,
6062
keywords=KEYWORDS,
6163
install_requires=REQUIRES,
6264
classifiers=CLASSIFIERS
6365
)
64-
66+
Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,31 @@
11

2-
AGICEN = "rally1.rallydev.com"
3-
PROD = "rally1.rallydev.com"
2+
RALLY = "1yllar.rallydev.com"
3+
PROD = "officialness.rallydev.com"
44

5-
AGICEN_USER = "yeti@rallydev.com"
6-
AGICEN_PSWD = "Vistabahn"
7-
AGICEN_NICKNAME = "Yeti"
8-
#API_KEY = "_ABC123DEF456GHI789JKL012MNO345PQR678STU901VWXZ"
5+
RALLY_USER = "usernumbernonei@acme.com"
6+
RALLY_PSWD = "B1G^S3Kretz"
7+
RALLY_NICKNAME = "Wiley"
8+
APIKEY = "_ABC123DEF456GHI789JKL012MNO345PQR678STU901VWXZ"
9+
10+
DEFAULT_WORKSPACE = "Your Default Workspace"
11+
DEFAULT_PROJECT = "Your Default Project"
12+
13+
NON_DEFAULT_PROJECT = "A non-default Project"
914

10-
DEFAULT_WORKSPACE = "AC WSAPI Toolkit Python"
11-
DEFAULT_PROJECT = "Sample Project"
12-
NON_DEFAULT_PROJECT = "My Project"
1315
ALTERNATE_WORKSPACE = "An Alternate Workspace"
14-
#ALTERNATE_PROJECT = "Dynamic"
1516
ALTERNATE_PROJECT = "An Alternate Project"
1617

1718
BOONDOCKS_WORKSPACE = 'Darwin Social Club'
1819
BOONDOCKS_PROJECT = 'Linoleum Blast'
1920

21+
LARGE_WORKSPACE = "Bonktorius Maximus"
22+
LARGE_PROJECT_TREE_BASE = "Amalgamated Hoodoo"
23+
24+
PROD_USER = "somebody@aplace.com"
25+
PROD_PSWD = "urSECr8He@R"
26+
27+
ACCOUNT_WITH_NO_DEFAULTS_CREDENTIALS = ('mortel.e.woonded@torso00bam.com', 'T2Y*&9mm409')
28+
2029
PROJECT_SCOPING_TREE = {
2130
'TOP_LEVEL_PROJECT' : {'Arctic Elevation' :
2231
[ 'My ship is stuck and I cant get out!',
@@ -38,12 +47,38 @@
3847
}
3948
}
4049

41-
ACCOUNT_WITH_NO_DEFAULTS_CREDENTIALS = ('mortel.e.woonded@torso00bam.com', 'T2Y*&9mm409')
42-
4350

4451
HTTPS_PROXY = "127.0.0.1:3128"
52+
HTTPS_PROXY = "127.0.0.1:9654"
53+
54+
#---------------------------------------------------------------------------
55+
56+
# uncomment this block for entries for access to the alternate test environment
57+
58+
#RALLY = 'us1.rallydev.com'
59+
#PROD = 'us1.rallydev.com'
60+
61+
#RALLY_USER = 'kip@closedprojects.com'
62+
#RALLY_PSWD = 'TwinLakes55'
63+
#RALLY_NICKNAME = 'Kip'
64+
65+
#DEFAULT_WORKSPACE = 'NMDS'
66+
#DEFAULT_PROJECT = 'My Project'
67+
#NON_DEFAULT_PROJECT = 'Sample Project'
68+
69+
#ALTERNATE_WORKSPACE = '404'
70+
#ALTERNATE_PROJECT = 'Name'
71+
72+
#API_KEY = "_DFyvCutVTKAxibNJ7mHvABywT3UIwtspVjJNWf40"
73+
74+
#PROD_USER = "rascal@mischief.com"
75+
#PROD_PSWD = "StRiPeSand-D-a-s-h-e-s"
76+
77+
#-----------------------------------------------------------------------------------------
78+
4579

46-
__all__ = [AGICEN, AGICEN_USER, AGICEN_PSWD, AGICEN_NICKNAME, PROD,
80+
__all__ = [RALLY, RALLY_USER, RALLY_PSWD, RALLY_NICKNAME,
81+
PROD, PROD_USER, PROD_PSWD,
4782
DEFAULT_WORKSPACE, DEFAULT_PROJECT,
4883
NON_DEFAULT_PROJECT, ALTERNATE_WORKSPACE, ALTERNATE_PROJECT,
4984
PROJECT_SCOPING_TREE, HTTPS_PROXY]

test/test_conn_headers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
##################################################################################################
1313

14-
from rally_targets import RALLY, API_KEY
14+
from rally_targets import RALLY, APIKEY
1515

1616
##################################################################################################
1717

@@ -21,7 +21,7 @@ def test_basic_connection_with_a_header():
2121
request against a known valid Rally entity.
2222
"""
2323
headers = {'name': 'Fungibles Goods Burn Up/Down', 'vendor': 'Archimedes', 'version': '1.2.3'}
24-
rally = Rally(RALLY, apikey=API_KEY, headers=headers)
24+
rally = Rally(RALLY, apikey=APIKEY, headers=headers)
2525
response = rally.get('Project', fetch=False, limit=10)
2626
assert response != None
2727
assert response.status_code == 200

test/test_ranking.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python
22

3-
import sys, os
4-
import pprint
3+
#import sys, os
4+
#import pprint
55

66
from pyral import Rally
77

0 commit comments

Comments
 (0)