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
|
#!/usr/bin/env python3
import os, sys, signal
from PyQt4 import QtGui
# Flexible install dir (we assume that 'lib' and 'resources' will be subdirs)
INSTALL_DIR = os.path.dirname(os.path.realpath(__file__))
# Append the lib directory in our installation path to get remaining libraries.
sys.path.append(os.path.join(INSTALL_DIR, 'lib'))
from resources import Resources
from scudcloud import ScudCloud
from qsingleapplication import QSingleApplication
# The ScudCloud QMainWindow
win = None
VERSION = '1.0.73'
def main():
global win;
Resources.INSTALL_DIR = INSTALL_DIR
signal.signal(signal.SIGINT, exit)
app = QSingleApplication(sys.argv)
app.setApplicationName(Resources.APP_NAME)
app.setWindowIcon(QtGui.QIcon(Resources.get_path('scudcloud.png')))
args = parse_arguments()
ScudCloud.debug = args.debug
ScudCloud.minimized = True if args.minimized is True else None
ScudCloud.plugins = False if args.no_plugins is True else True
try:
settings_path = load_settings(args.confdir)
except:
print("Configuration directory "+args.confdir+" could not be created! Exiting...")
raise SystemExit()
win = ScudCloud(settings_path=settings_path)
app.singleStart(win, "scudcloud.pid")
win.restore()
sys.exit(app.exec_())
def load_settings(confdir):
if not os.path.isdir(confdir):
os.makedirs(confdir)
if confdir not in sys.path:
sys.path[0:0] = [confdir]
return confdir
def parse_arguments():
from argparse import ArgumentParser
from os.path import expanduser
if 'XDG_CONFIG_HOME' in os.environ and os.environ['XDG_CONFIG_HOME']:
default_confdir = os.environ['XDG_CONFIG_HOME'] + '/scudcloud'
else:
default_confdir = '~/.config/scudcloud'
parser = ArgumentParser()
parser.add_argument('--confdir', dest='confdir', metavar='dir', default=default_confdir, help="change the configuration directory")
parser.add_argument('--debug', dest='debug', type=bool, default=False, help="enable webkit debug console (default: False)")
parser.add_argument('--minimized', dest='minimized', type=bool, default=False, help="start minimized to tray (default: False)")
parser.add_argument('--no_plugins', dest='no_plugins', type=bool, default=False, help="disable web plugins (default: False)")
parser.add_argument('--version', action="store_true", help="print version and exit")
args = parser.parse_args()
if args.version:
print("ScudCloud "+VERSION)
sys.exit()
args.confdir = expanduser(args.confdir)
return args
def exit(*args):
if win is not None:
win.exit()
else:
QSingleApplication.quit()
if __name__ == '__main__':
main()
|