|
43 |
import sys |
43 |
import sys |
44 |
|
44 |
|
45 |
import notifier |
45 |
import notifier |
|
|
46 |
import notifier.log as nflog |
46 |
|
47 |
|
47 |
if __name__ == '__main__': |
48 |
if __name__ == '__main__': |
48 |
if os.getuid() != 0: |
49 |
if os.getuid() != 0: |
49 |
sys.stderr.write( '%s must be started as root\n' % os.path.basename( sys.argv[ 0 ] ) ) |
50 |
sys.stderr.write( '%s must be started as root\n' % os.path.basename( sys.argv[ 0 ] ) ) |
50 |
sys.exit( 1 ) |
51 |
sys.exit( 1 ) |
51 |
|
52 |
|
52 |
notifier.init( notifier.GENERIC ) |
|
|
53 |
|
54 |
parser = OptionParser( usage = "usage: %prog [options]" ) |
53 |
parser = OptionParser( usage = "usage: %prog [options]" ) |
55 |
parser.add_option( '-s', '--socket', type = 'string', action = 'store', |
54 |
parser.add_option( '-s', '--socket', type = 'string', action = 'store', dest = 'socket', |
56 |
dest = 'socket', help = 'defines the socket to bind to' ) |
55 |
help = 'defines the socket to bind to' ) |
57 |
parser.add_option( '-l', '--language', type = 'string', action = 'store', |
56 |
parser.add_option( '-l', '--language', type = 'string', action = 'store', dest = 'language', default = 'C', |
58 |
dest = 'language', default = 'C', |
|
|
59 |
help = 'defines the language to use' ) |
57 |
help = 'defines the language to use' ) |
60 |
parser.add_option( '-m', '--module', type = 'string', |
58 |
parser.add_option( '-m', '--module', type = 'string', action = 'store', dest = 'module', |
61 |
action = 'store', dest = 'module', |
|
|
62 |
help = 'set the UMC daemon module to load' ) |
59 |
help = 'set the UMC daemon module to load' ) |
|
|
60 |
parser.add_option( '-n', '--notifier', type = 'string', action = 'store', dest = 'notifier', default = 'generic', |
61 |
help = 'defines the notifier implementation to use' ) |
63 |
|
62 |
|
64 |
default_debug = MODULE_DEBUG_LEVEL |
63 |
default_debug = MODULE_DEBUG_LEVEL |
65 |
parser.add_option( '-d', '--debug', action = 'store', type = 'int', dest = 'debug', default = default_debug, |
64 |
parser.add_option( '-d', '--debug', action = 'store', type = 'int', dest = 'debug', default = default_debug, |
|
71 |
daemon = DaemonContext( detach_process = False, umask = 0077 ) |
70 |
daemon = DaemonContext( detach_process = False, umask = 0077 ) |
72 |
daemon.open() |
71 |
daemon.open() |
73 |
|
72 |
|
|
|
73 |
# MUST be called after initializing the deamon |
74 |
if options.notifier.lower() == 'generic': |
75 |
notifier.init( notifier.GENERIC ) |
76 |
elif options.notifier.lower() == 'qt': |
77 |
import PyQt4.Qt as qt |
78 |
qApp = qt.QCoreApplication( sys.argv ) |
79 |
notifier.init( notifier.QT ) |
80 |
|
74 |
# init logging |
81 |
# init logging |
75 |
debug_fd = log_init( '%s-%s' % ( options.logfile, options.module ), options.debug ) |
82 |
debug_fd = log_init( '%s-%s' % ( options.logfile, options.module ), options.debug ) |
|
|
83 |
# no notifier logging |
84 |
nflog.instance.handlers = [] |
85 |
# to activate notifier logging |
86 |
# nflog.set_level( nflog.DEBUG ) |
87 |
# nflog.open() |
76 |
|
88 |
|
77 |
localeok = False |
89 |
localeok = False |
78 |
try: |
90 |
try: |