support fnmatch() args match
authorKonstantin Stepanov <kstep@p-nut.info>
Tue, 21 Dec 2010 23:27:01 +0000 (01:27 +0200)
committerKonstantin Stepanov <kstep@p-nut.info>
Tue, 21 Dec 2010 23:47:15 +0000 (01:47 +0200)
dbuscron/bus.py
migrate-dbus-scripts.py

index 3b7a74e..ccf54da 100644 (file)
@@ -1,6 +1,7 @@
 from __future__ import with_statement
 
 import dbus, os
+from fnmatch import fnmatch
 
 from dbuscron.logger import Logger
 log = Logger(__name__)
@@ -124,7 +125,6 @@ class DbusRule(object):
         return ','.join(rule)
 
     def match(self, bus, message):
-
         if self._bus not in (None, bus):
             return False
 
@@ -153,8 +153,10 @@ class DbusRule(object):
             for i, arg in enumerate(args_):
                 if i >= len(self._args):
                     break
-                if self._args[i] not in (None, dbus_to_str(arg)):
-                    return False
+                a = dbus_to_str(arg)
+                if self._args[i] not in (None, a):
+                    if not fnmatch(a, self._args[i]):
+                        return False
 
         return True
 
index 358854c..0684348 100755 (executable)
@@ -60,10 +60,6 @@ for fn in os.listdir(dbus_scripts_dir):
                     skip_args += 1
                 opts['args'] = ';'*skip_args + opts['args']
 
-                if opts['args'] != '*' \
-                    and '*' in opts['args']:
-                    print >> sys.stderr, 'Warning: %s:%d: arguments contain wildcard characters, unsupported by dbuscron.' % (fnam, lineno)
-
                 # bus type sender interface path member destination args command
                 res = 'S signal,method_call %(src)s %(iface)s * %(meth)s %(dest)s %(args)s !%(cmd)s' % opts
                 print >> o, res