-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·109 lines (77 loc) · 2.38 KB
/
main.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fileencoding=utf-8
"""
===========================
pyroview
===========================
SYNOPSIS
TODO helloworld [-h,--help] [-v,--verbose] [--version]
DESCRIPTION
TODO This describes how to use this script. This docstring
will be printed by the script if there is an error or
if the user requests help (-h or --help).
EXAMPLES
TODO: Show some examples of how to use this script.
EXIT STATUS
TODO: List exit codes
AUTHOR
Jesse Butcher <[email protected]>
LICENSE
This script is in the public domain, free from copyrights or restrictions.
Copyright (c) 2014, Jesse Butcher
See LICENSE.txt
::
This file is part of pyroview.
VImPy is free 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.
VImPy is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with VImPy. If not, see <http://www.gnu.org/licenses/>.
VERSION
0.5
"""
import sys
import traceback
import logging
import subprocess
from pyroview.logging import L
from pyroview.core import create_cmd
from pyroview.utils import get_cli_args
logging.basicConfig(level=L.level)
def main():
""" Main thread
"""
args = get_cli_args()
logging.debug('CLI Arguments: {}'.format(args))
logging.debug('<<<Main>>>')
cmd = create_cmd(args)
if cmd is not False:
if args['debug']:
one_liner = ' '.join(cmd)
print(one_liner)
else:
process = subprocess.Popen(cmd, stdout=subprocess.PIPE)
process.wait()
for line in process.stdout:
print(line)
if __name__ == '__main__':
try:
main()
sys.exit(0)
except KeyboardInterrupt as e:
# Ctrl-C
raise e
except SystemExit as e:
# sys.exit()
raise e
except Exception as e:
logging.error('ERROR, UNEXPECTED EXCEPTION')
logging.error(str(e))
traceback.print_exc()
sys.exit(1)