-
Notifications
You must be signed in to change notification settings - Fork 4
/
powa-collector.py
executable file
·48 lines (36 loc) · 1.05 KB
/
powa-collector.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
#!/usr/bin/env python
import getopt
import os
import sys
from powa_collector import PowaCollector, getVersion
def usage(rc):
"""Show tool usage
"""
print("""Usage:
%s [ -? | --help ] [ -V | --version ]
-? | --help Show this message and exits
-v | --version Report powa-collector version and exits
See https://powa.readthedocs.io/en/latest/powa-collector/ for
more information about this tool.
""" % os.path.basename(__file__))
sys.exit(rc)
def main():
"""Instantiates and starts a PowaCollector object
"""
try:
opts, args = getopt.getopt(sys.argv[1:], "?V", ["help", "version"])
except getopt.GetoptError as e:
print(str(e))
usage(1)
for o, a in opts:
if o in ("-?", "--help"):
usage(0)
elif o in ("-V", "--version"):
print("%s version %s" % (os.path.basename(__file__), getVersion()))
sys.exit(0)
else:
assert False, "unhandled option"
app = PowaCollector()
app.main()
if (__name__ == "__main__"):
main()