-
Notifications
You must be signed in to change notification settings - Fork 3
/
fred-client
executable file
·80 lines (73 loc) · 2.84 KB
/
fred-client
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
#!/usr/bin/env python
#
#This file is part of FredClient.
#
# FredClient 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 2 of the License, or
# (at your option) any later version.
#
# FredClient 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 FredClient; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
"""
This is main script handling all functions of this client.
Here it's deside what type of application will be running.
Default is console. Next choice is running as a batch -
this is suitable using is in some shell scripts or for manage
web pages (php, html). It also run it in GUI mode GUI with
Qt environment.
Script check version of python at the beginning. This code is
in module fred. Next it use options from command line parsed
in module fred.translate during import.
MODES:
For console mode is used module fred.console.
For batch mode is used modules fred.creator and fred.sender.
For GUI moduel is used module guiqt.
"""
import sys, os
old_cwd = os.getcwd()
try:
os.chdir(os.path.dirname(sys.argv[0]))
except OSError:
pass
# setup.py will change this path to reflect changes in prefix
# and/or root option during install
sys.path.insert(0, '.')
import fred
from fred.translate import options, option_errors
import fred.console
if __name__ == '__main__':
msg_invalid = fred.check_python_version()
if len(msg_invalid):
print "%s %s" % (msg_invalid)
else:
from fred.console import help_option
if options['help']:
print '%s: %s [OPTIONS...]\n%s%s\n%s\n\n%s\n'%(_T('Usage'), 'fred-client',
help_option,
_T(""" -d COMMAND, --command=COMMAND
Send command to server and exit
-o OUTPUT_TYPE, --output=OUTPUT_TYPE
Display output as text (default), html, xml, php (Beware! For experimental only!)"""),
_T(""" -q, --qt
Run client in Qt4 GUI (Beware! For experimental only!)"""),
_T('See README for more information.'))
elif options['version']:
epp = fred.ClientSession()
print epp.version()
elif option_errors:
print option_errors
else:
if options['qt']:
from guiqt4.main import main
# (argv, lang, oldcwd, options)
main([], options['lang'], None, options)
else:
fred.console.main(options)
os.chdir(old_cwd)