equal
deleted
inserted
replaced
7 # This script is provided under the terms of the GNU General Public License, |
7 # This script is provided under the terms of the GNU General Public License, |
8 # see the file COPYING in the root mcabber source directory. |
8 # see the file COPYING in the root mcabber source directory. |
9 # |
9 # |
10 |
10 |
11 import sys, getopt |
11 import sys, getopt |
|
12 import os |
12 import pynotify |
13 import pynotify |
13 |
14 |
14 CONFFILE = "mcevent.cfg" |
15 CONFFILE = "mcevent.cfg" |
15 |
16 |
16 # Default option values |
17 # Default option values |
47 encoding = (locale.getdefaultlocale())[1] |
48 encoding = (locale.getdefaultlocale())[1] |
48 NOTIFY_LOADED = True |
49 NOTIFY_LOADED = True |
49 |
50 |
50 def read_conf_from_file(): |
51 def read_conf_from_file(): |
51 import ConfigParser |
52 import ConfigParser |
52 |
|
53 # TODO: Do not re-read file if it hasn't been touched |
|
54 |
53 |
55 config = ConfigParser.ConfigParser() |
54 config = ConfigParser.ConfigParser() |
56 config.read(CONFFILE) |
55 config.read(CONFFILE) |
57 |
56 |
58 contact_map.clear() |
57 contact_map.clear() |
214 |
213 |
215 for o, a in opts: |
214 for o, a in opts: |
216 if o == "-c": |
215 if o == "-c": |
217 CONFFILE = a |
216 CONFFILE = a |
218 |
217 |
|
218 try: |
|
219 last_conf_read = os.stat(CONFFILE).st_ctime |
|
220 except OSError: |
|
221 sys.stderr.write("Cannot read config file!\n") |
|
222 sys.exit(3) |
|
223 |
|
224 read_conf_from_file() |
|
225 |
219 NOTIFY_LOADED = False |
226 NOTIFY_LOADED = False |
220 |
227 |
221 # read stdin line by line |
228 # read stdin line by line |
222 while 1: |
229 while 1: |
223 try: |
230 try: |
226 print "\nInterrupted!" |
233 print "\nInterrupted!" |
227 exit(0) |
234 exit(0) |
228 if not line: |
235 if not line: |
229 break |
236 break |
230 |
237 |
231 read_conf_from_file() |
238 last_conf_change = os.stat(CONFFILE).st_ctime |
|
239 if last_conf_change > last_conf_read: |
|
240 read_conf_from_file() |
|
241 last_conf_read = last_conf_change |
232 lineargs = line.split() |
242 lineargs = line.split() |
233 process_line(lineargs) |
243 process_line(lineargs) |
234 |
244 |
235 if NOTIFY_LOADED: |
245 if NOTIFY_LOADED: |
236 pynotify.uninit() |
246 pynotify.uninit() |