Skip to content

Commit 7e6a733

Browse files
author
Kevin D Smith
committed
Update tool documentation
1 parent 3c55bf7 commit 7e6a733

14 files changed

+186
-30
lines changed

cicd/download-wheels.py

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

3-
''' Download Wheel files from URL '''
3+
'''
4+
Download Wheel files from URL
5+
6+
Wheel files may be stored in a staging area before being published to the
7+
public PyPI repository. This is done so that new packages can be tested
8+
before being published officially.
9+
10+
This utility allows you to download a set of wheel files from a repository
11+
(optionally specifying a specific version of the package) and storing
12+
them in a local directory. They can then be uploaded to the final location
13+
using `twine`.
14+
15+
'''
416

517
import argparse
618
import os
@@ -35,7 +47,8 @@ def main(args):
3547

3648

3749
if __name__ == '__main__':
38-
parser = argparse.ArgumentParser(prog='download-wheels')
50+
parser = argparse.ArgumentParser(description=__doc__.strip(),
51+
formatter_class=argparse.RawTextHelpFormatter)
3952

4053
parser.add_argument('--version', '-v', type=str, metavar='version',
4154
help='version of package to download')

cicd/generate-tox-ini.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
'''
44
Generate a Tox config file for all test configurations
55
6+
To create a test matrix for all supported versions of Python,
7+
this utility takes a template `tox.ini` file and adds additional
8+
Tox environments to the end of it. The version of Python and
9+
pandas used in the environments are determined by those available
10+
on Anaconda.
11+
12+
The versions of Python on Anaconda are intesected with the versions
13+
of Python supported in the SWAT C extensions in the package
14+
(e.g., _pyswat.so (2.7), _pyswa35.so (3.5), etc.). Pandas versions
15+
are distributed across the version of Python to increase overall
16+
coverage.
17+
618
'''
719

820
import argparse
@@ -144,7 +156,8 @@ def main(args):
144156

145157

146158
if __name__ == '__main__':
147-
parser = argparse.ArgumentParser(description=__doc__.strip())
159+
parser = argparse.ArgumentParser(description=__doc__.strip(),
160+
formatter_class=argparse.RawTextHelpFormatter)
148161

149162
parser.add_argument('tox_ini', type=str, metavar='ini-file',
150163
help='path to tox.ini file')

cicd/get-basename.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,8 @@ def main(args):
7878

7979

8080
if __name__ == '__main__':
81-
parser = argparse.ArgumentParser(description=__doc__.strip())
81+
parser = argparse.ArgumentParser(description=__doc__.strip(),
82+
formatter_class=argparse.RawTextHelpFormatter)
8283

8384
parser.add_argument('root', type=str, metavar='<directory>', nargs='?', default='.',
8485
help='root directory of Python package')

cicd/get-host.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
'''
44
Return a random hostname from the specified collection of names
55
6+
This utility is used to randomly choose a hostname from a list
7+
or names with a numeric range. It allows you to put bracketed
8+
lists or ranges of values in one or more places in the hostname
9+
to enumerate the possibilities. For example, if you had test
10+
machines named `test01`, `test02`, and `test03`. You could
11+
retrieve a random item from this list with the following call:
12+
13+
get-host.py 'test[01,02,03]'
14+
15+
This would return one of the following:
16+
17+
test01
18+
test02
19+
test03
20+
21+
You can also specify numeric ranges:
22+
23+
get-host.py 'test[01-03]'
24+
25+
Which would return one of the above results as well.
26+
627
'''
728

829
import argparse
@@ -37,7 +58,8 @@ def main(args):
3758

3859

3960
if __name__ == '__main__':
40-
parser = argparse.ArgumentParser(description=__doc__.strip())
61+
parser = argparse.ArgumentParser(description=__doc__.strip(),
62+
formatter_class=argparse.RawTextHelpFormatter)
4163

4264
parser.add_argument('host_expr', type=str, metavar='hostname-expr', nargs='+',
4365
help='hostname expression (ex. myhost[01-06].com)')

cicd/get-protocol.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
'''
44
Return the preferred CAS protocol ('cas' if TK is available; 'http' otherwise)
55
6+
This utility checks the package `__init__.py` file for a `__tk_version__`
7+
parameter that indicates the packaged version of the TK libraries.
8+
If it finds it, the `cas` protocol will be returned. If the value is
9+
set to `None`, the `http` protocol is returned.
10+
611
'''
712

813
import argparse
@@ -16,7 +21,12 @@ def main(args):
1621
''' Main routine '''
1722
version = None
1823

19-
init = glob.glob(os.path.join(args.root, 'swat', '__init__.py'))[0]
24+
try:
25+
init = glob.glob(os.path.join(args.root, 'swat', '__init__.py'))[0]
26+
except IndexError:
27+
sys.stderr.write('ERROR: Could not locate swat/__init__.py file\n')
28+
sys.exit(1)
29+
2030
with open(init, 'r') as init_in:
2131
for line in init_in:
2232
m = re.match(r'''__tk_version__\s*=\s*['"]([^'"]+)['"]''', line)
@@ -30,7 +40,8 @@ def main(args):
3040

3141

3242
if __name__ == '__main__':
33-
parser = argparse.ArgumentParser(description=__doc__.strip())
43+
parser = argparse.ArgumentParser(description=__doc__.strip(),
44+
formatter_class=argparse.RawTextHelpFormatter)
3445

3546
parser.add_argument('root', type=str, metavar='<directory>',
3647
default='.', nargs='?',

cicd/get-server-info.py

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

33
'''
4-
get-server-info
4+
Retrieve CAS server information from CAS log
55
6-
Retrieve CAS server information using CAS log. The CAS server command
7-
is expected to have a -display option with a unique key for the invoked
8-
server. This is used to retrieve the PID of the server process. The
9-
basename of the CAS log file must match the value in the -display option.
6+
The CAS server command is expected to have a `-display` option with a unique
7+
key for the invoked server. This is used to retrieve the PID of the server
8+
process. The basename of the CAS log file must match the value in the
9+
`-display` option.
1010
1111
'''
1212

@@ -35,7 +35,7 @@ def main(args):
3535
3636
'''
3737
if not os.path.isfile(args.log_file):
38-
print_err('ERROR: File not found: {}'.format(args.log_file))
38+
print_err('ERROR: File not found: {}.'.format(args.log_file))
3939
sys.exit(1)
4040

4141
iters = 0
@@ -118,7 +118,8 @@ def main(args):
118118

119119
if __name__ == '__main__':
120120

121-
opts = argparse.ArgumentParser(description=__doc__.strip())
121+
opts = argparse.ArgumentParser(description=__doc__.strip(),
122+
formatter_class=argparse.RawTextHelpFormatter)
122123

123124
opts.add_argument('log_file', type=str, metavar='log-file',
124125
help='path to CAS server log')

cicd/get-version.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
'''
44
Return the version of the package
55
6+
This command looks for the `__version__` attribute in the `swat/__init__.py`
7+
file to determine the package version.
8+
69
'''
710

811
from __future__ import print_function, division, absolute_import, unicode_literals
@@ -25,7 +28,12 @@ def main(args):
2528

2629
version = None
2730

28-
init = glob.glob(os.path.join(args.root, 'swat', '__init__.py'))[0]
31+
try:
32+
init = glob.glob(os.path.join(args.root, 'swat', '__init__.py'))[0]
33+
except IndexError:
34+
sys.stderr.write('ERROR: Could not locate swat/__init__.py file\n')
35+
return 1
36+
2937
with open(init, 'r') as init_in:
3038
for line in init_in:
3139
m = re.search(r'''^__version__\s*=\s*['"]([^'"]+)['"]''', line)

cicd/get-workspace-url.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
'''
44
Return the WORKSPACE as a URL
55
6+
Some downstream commands require the path to a Jenkins `WORKSPACE` variable
7+
as a URL rather than a file path. This URL must be formatted differently for
8+
Windows than for UNIX-like operating systems. This utility does the proper
9+
formatting for the host type.
10+
611
'''
712

813
import argparse
@@ -26,7 +31,8 @@ def main(args):
2631

2732

2833
if __name__ == '__main__':
29-
parser = argparse.ArgumentParser(description=__doc__.strip())
34+
parser = argparse.ArgumentParser(description=__doc__.strip(),
35+
formatter_class=argparse.RawTextHelpFormatter)
3036

3137
args = parser.parse_args()
3238

cicd/install-tk.py

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,20 @@
33
'''
44
Install TK libraries and C extensions
55
6+
In order to support the binary CAS protocol, the SWAT package needs both
7+
a C extension which surfaces the API for that protocol as well as the underlying
8+
support libraries (known as TK). This utility will download the TK libraries
9+
and the C extension from a repository and insert the extensions into the
10+
proper directory in the SWAT package directory structure. This location is:
11+
12+
swat/libs/{platform}/
13+
14+
Where `{platform}` is `win` or `linux`.
15+
16+
Since there may be multiple TK versions available at each release (for example,
17+
shipped and hot-fix versions), the libraries are searched for in the proper
18+
order.
19+
620
'''
721

822
import argparse
@@ -277,7 +291,8 @@ def main(args):
277291

278292

279293
if __name__ == '__main__':
280-
parser = argparse.ArgumentParser(description=__doc__.strip())
294+
parser = argparse.ArgumentParser(description=__doc__.strip(),
295+
formatter_class=argparse.RawTextHelpFormatter)
281296

282297
parser.add_argument('root', type=str, nargs='?', default='.',
283298
help='root directory of Python package')

cicd/promote-release-candidate.py

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

3-
''' Utitily for moving a release candidate to a full release '''
3+
'''
4+
Utitily for moving a release candidate to a full release
5+
6+
When a Github release is first created, it is done as a draft release.
7+
This is done so that the release can be tested and verified before going
8+
public as an official release. This utility is used to promote a
9+
draft release to a public release.
10+
11+
'''
412

513
import argparse
614
import datetime
@@ -18,7 +26,15 @@
1826
from urllib.request import urlopen, urlretrieve
1927

2028

21-
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
29+
if '--help' not in sys.argv and '-h' not in sys.argv:
30+
try:
31+
GITHUB_TOKEN = os.environ['GITHUB_TOKEN']
32+
except KeyError:
33+
sys.stderr.write('ERROR: This utility requires a Github token '
34+
'for accessing the Github release API.\n')
35+
sys.stderr.write(' The variable should be held in an '
36+
'environment variable named GITHUB_TOKEN.\n')
37+
sys.exit(1)
2238

2339

2440
def get_repo():
@@ -250,7 +266,8 @@ def main(args):
250266

251267

252268
if __name__ == '__main__':
253-
parser = argparse.ArgumentParser(prog='stage-release-candidate')
269+
parser = argparse.ArgumentParser(prog='stage-release-candidate',
270+
formatter_class=argparse.RawTextHelpFormatter)
254271

255272
parser.add_argument('tag', type=tag_type, metavar='tag',
256273
help='tag of the release to promote')

0 commit comments

Comments
 (0)