forked from RallyTools/RallyRestToolkitForPython
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rallyfire.py
executable file
·66 lines (53 loc) · 2.89 KB
/
rallyfire.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
#################################################################################################
#
# rallyfire - Exemplar script to test the basic connectivity to a Rally server
# and obtain basic workspace and project information
#
#################################################################################################
import sys
from pyral import Rally, rallyWorkset
#################################################################################################
errout = sys.stderr.write
#################################################################################################
def main(args):
options = [opt for opt in args if opt.startswith('--')]
args = [arg for arg in args if arg not in options]
server, user, password, apikey, workspace, project = rallyWorkset(options)
print " ".join(["|%s|" % item for item in [server, user, password, workspace, project]])
# If you want to use BasicAuth, use the following form
rally = Rally(server, user, password, workspace=workspace, project=project)
# If you want to use API Key, you can use the following form
#rally = Rally(server, apikey=apikey, workspace=workspace, project=project)
rally.enableLogging('fire.log')
# the following form of obtaining a Rally instance will use the apikey if it is present (non None)
# otherwise it will use the user and password for BasicAuth
# add in the debug=True keyword arg if you want more verbiage ...
#rally = Rally(server, user, password, apikey=apikey, workspace=workspace, project=project, debug=True)
specified_workspace = workspace
workspace = rally.getWorkspace()
print "Workspace: %s " % workspace.Name
if specified_workspace != workspace.Name:
print " ** The workspace you specified: %s is not a valid workspace name for your account, using your default workspace instead" % specified_workspace
#print "Workspace: %12.12s %-18.18s (%s)" % (workspace.oid, workspace.Name, workspace.ref)
project = rally.getProject()
print "Project : %s " % project.Name
#print "Project : %12.12s %-18.18s (%s)" % (project.oid, project.Name, project.ref)
# uncomment this to see all of your accessible workspaces and projects
# workspaces = rally.getWorkspaces()
# for workspace in workspaces:
# print " ", workspace.Name
# projects = rally.getProjects(workspace=workspace.Name)
# if projects:
# print ""
# print " Projects:"
# for project in projects:
# print " ", project.Name
# else:
# print " No projects"
# print ""
sys.exit(0)
#################################################################################################
#################################################################################################
if __name__ == '__main__':
main(sys.argv[1:])