-
Notifications
You must be signed in to change notification settings - Fork 5
/
cmd_logalyzer.py
executable file
·58 lines (44 loc) · 1.25 KB
/
cmd_logalyzer.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
#!/usr/bin/env python
#
# Copyright (c) 2012 Liraz Siri <liraz@turnkeylinux.org>
#
# This file is part of CloudTask.
#
# CloudTask is open source software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
#
"""
Analyze session logs
"""
from os.path import *
import sys
import getopt
from cloudtask import logalyzer
def usage(e=None):
if e:
print >> sys.stderr, "error: " + str(e)
print >> sys.stderr, "Usage: %s [ -opts ] path/to/session" % sys.argv[0]
print >> sys.stderr, __doc__.strip()
sys.exit(1)
def fatal(e):
print >> sys.stderr, "error: " + str(e)
sys.exit(1)
def main():
try:
opts, args = getopt.gnu_getopt(sys.argv[1:],
'h', [ 'help' ])
except getopt.GetoptError, e:
usage(e)
for opt, val in opts:
if opt in ('-h', '--help'):
usage()
if len(args) != 1:
usage()
session_path = args[0]
if not isdir(session_path):
fatal("not a directory '%s'" % session_path)
print logalyzer.logalyzer(session_path)
if __name__ == "__main__":
main()