borgend.py

Sat, 27 Jan 2018 12:19:39 +0000

author
Tuomo Valkonen <tuomov@iki.fi>
date
Sat, 27 Jan 2018 12:19:39 +0000
changeset 75
2a44b9649212
parent 74
4f56142e7497
child 76
4b08fca3ce34
permissions
-rwxr-xr-x

UI refresh fix; added debug messages

0
f5aecaad0bcf Some rough drafting
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
1 #!/usr/local/bin/python3
f5aecaad0bcf Some rough drafting
Tuomo Valkonen <tuomov@iki.fi>
parents:
diff changeset
2
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
3 import os
45
aa2a95dc6093 Further improvements to state reporting; indicate busyness if repository lock cannot be acquired
Tuomo Valkonen <tuomov@iki.fi>
parents: 43
diff changeset
4 import sys
4
d72c4844e791 Better borg output processing and some logging
Tuomo Valkonen <tuomov@iki.fi>
parents: 3
diff changeset
5 import logging
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
6 import logging.handlers
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
7 import argparse
43
8f3ac19f11b6 Use platform package to detect whether to:
Tuomo Valkonen <tuomov@iki.fi>
parents: 41
diff changeset
8 import platform
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
9
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
10 #
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
11 # Branding
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
12 #
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
13 appname="borgend"
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
14 appname_stylised="Borgend"
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
15
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
16 #
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
17 # Logging configuration
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
18 #
4
d72c4844e791 Better borg output processing and some logging
Tuomo Valkonen <tuomov@iki.fi>
parents: 3
diff changeset
19
73
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
20 loglevel=logging.INFO
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
21 logfmt="%(asctime)s:%(levelname)s:%(name)s:%(message)s"
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
22 fifolog_capacity=1000
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
23 fifolog_fmt="%(asctime)s:%(levelname)s:%(message)s"
4
d72c4844e791 Better borg output processing and some logging
Tuomo Valkonen <tuomov@iki.fi>
parents: 3
diff changeset
24
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
25 #
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
26 # Setup logger, needed by the config module to be loaded next
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
27 #
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
28
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
29 logger=logging.getLogger(appname)
52
aef860e99323 Have to clean up logger handlers in same cases to avoid duplicate messages
Tuomo Valkonen <tuomov@iki.fi>
parents: 50
diff changeset
30 logger.handlers.clear()
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
31 logger.setLevel(loglevel)
49
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
32 stderrlog=logging.StreamHandler()
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
33 stderrlog.setLevel(logging.WARNING)
49
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
34 logger.addHandler(stderrlog)
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
35 logger.propagate=True
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
36
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
37 #
49
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
38 # Import our own modules. This needs to be done here
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
39 # for the things above to be available to them
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
40 #
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
41
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
42 import config
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
43 from scheduler import Scheduler
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
44 from fifolog import FIFOHandler
74
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
45 from repository import Repository
49
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
46
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
47 #
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
48 # Argument processing
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
49 #
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
50
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
51 def do_args():
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
52 parser=argparse.ArgumentParser(
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
53 description=appname_stylised + ': BorgBackup scheduler and tray icon.',
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
54 epilog='Configuration file location:\n\n %s\n ' % config.cfgfile,
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
55 formatter_class=argparse.RawDescriptionHelpFormatter)
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
56
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
57 parser.add_argument(
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
58 '--no-tray',
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
59 dest='notray',
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
60 action='store_true',
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
61 help='Do not show the tray icon')
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
62
73
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
63 parser.add_argument(
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
64 '--debug',
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
65 dest='debug',
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
66 action='store_true',
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
67 help='Set logging level to debug')
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
68
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
69 return parser.parse_args()
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
70
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
71 #
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
72 # Main routine
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
73 #
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
74
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
75 # First, setup our own logging handlers
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
76 fifolog=FIFOHandler(fifolog_capacity)
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
77 logger.addHandler(fifolog)
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
78 fifolog.setFormatter(logging.Formatter(fifolog_fmt))
31
b4b4bb7a2ec5 More logging detail
Tuomo Valkonen <tuomov@iki.fi>
parents: 10
diff changeset
79
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
80 if __name__=="__main__":
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
81 # Parse args. Let argparse handle errors/exit if there are any
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
82 args= do_args()
46
ecb41072a1b7 Unsuccesfull attempts at clean quit on exceptions that fall through
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
83 tray = None
74
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
84 repos=[]
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
85 backups=[]
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
86
40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
87 try:
41
e2641cb9ca6d --no-tray command line option for running on non-MacOS systems
Tuomo Valkonen <tuomov@iki.fi>
parents: 40
diff changeset
88 args=do_args()
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
89
73
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
90 if args.debug:
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
91 logger.setLevel(logging.DEBUG)
4f0e9cf8f230 Added --debug switch to enable debug logging level
Tuomo Valkonen <tuomov@iki.fi>
parents: 52
diff changeset
92
40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
93 if not os.path.isdir(config.logs_dir):
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
94 os.makedirs(config.logs_dir)
34
9fce700d42de Log window and other logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 33
diff changeset
95
40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
96 handler=logging.handlers.TimedRotatingFileHandler(
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
97 os.path.join(config.logs_dir, appname+'.log'),
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
98 when='D', interval=1)
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
99 handler.setFormatter(logging.Formatter(logfmt))
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
100 logger.addHandler(handler)
1
4cdc9c1f6b28 basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
101
40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
102 from threading import Thread
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
103 from backup import Backup
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
104 from queue import Queue
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
105 import signal, os
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
106
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
107 scheduler = Scheduler()
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
108 scheduler.start()
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
109
74
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
110 repoconfigs=config.settings['repositories']
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
111
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
112 for i in range(len(repoconfigs)):
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
113 logger.info('Setting up repository %d' % i)
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
114 r=Repository(i, repoconfigs[i])
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
115 repos.append(r)
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
116
40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
117 backupconfigs=config.settings['backups']
1
4cdc9c1f6b28 basic scheduler structure draft, etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 0
diff changeset
118
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
119 for i in range(len(backupconfigs)):
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
120 logger.info('Setting up backup set %d' % i)
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
121 b=Backup(i, backupconfigs[i], scheduler)
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
122 backups.append(b)
49
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
123
74
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
124 for r in repos:
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
125 r.start()
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
126
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
127 for b in backups:
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
128 b.start()
3
4cad934aa9ce Can launch borg now; output not yet processed
Tuomo Valkonen <tuomov@iki.fi>
parents: 2
diff changeset
129
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
130 if args.notray or platform.system()!='Darwin':
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
131 # Wait for scheduler to finish
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
132 scheduler.join()
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
133 else:
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
134 # Start UI, and let it handle exit control
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
135 from ui import BorgendTray
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
136 tray=BorgendTray(backups);
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
137 tray.run()
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
138
40
cfbeeec8cb82 Improved exception reporting etc.
Tuomo Valkonen <tuomov@iki.fi>
parents: 39
diff changeset
139 except Exception as err:
49
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
140 # TODO: Should write errors here to stderr;
db33dfa64ad6 Improved scheduler
Tuomo Valkonen <tuomov@iki.fi>
parents: 46
diff changeset
141 # perhaps add an extra stderr logger for error level messages
50
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
142 logger.exception("Exception fell through to outer level: exiting")
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
143
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
144 finally:
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
145 for b in backups:
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
146 b.terminate()
2d8947351727 Logging improvements
Tuomo Valkonen <tuomov@iki.fi>
parents: 49
diff changeset
147
74
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
148 for r in repos:
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
149 r.terminate()
4f56142e7497 Separated repository configuration form backup configuration;
Tuomo Valkonen <tuomov@iki.fi>
parents: 73
diff changeset
150
46
ecb41072a1b7 Unsuccesfull attempts at clean quit on exceptions that fall through
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
151 if tray:
ecb41072a1b7 Unsuccesfull attempts at clean quit on exceptions that fall through
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
152 tray.quit()
ecb41072a1b7 Unsuccesfull attempts at clean quit on exceptions that fall through
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
153 else:
ecb41072a1b7 Unsuccesfull attempts at clean quit on exceptions that fall through
Tuomo Valkonen <tuomov@iki.fi>
parents: 45
diff changeset
154 logging.shutdown()
9
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
155
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
156 #
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
157 # This shit is fucked, disables ^C etc., and threading doesn't seem to help
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
158 #
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
159
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
160 # ui_thread=Thread(target=tray.run)
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
161 # ui_thread.daemon=True
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
162 # ui_thread.start()
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
163
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
164 # def quit_signal_handler(signum, frame):
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
165 # print('Signal handler called with signal %s' % str(signum))
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
166 # ui_thread.terminate()
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
167 # os.exit()
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
168
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
169 # signal.signal(signal.SIGTERM, quit_signal_handler)
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
170 # signal.signal(signal.SIGINT, quit_signal_handler)
aa121291eb0e Rumps/Mac UI stuff is fucked and disables ^C etc.; threading doesn't help
Tuomo Valkonen <tuomov@iki.fi>
parents: 8
diff changeset
171

mercurial