Prepare file configured logging
[pwnitter] / pwnitter.py
index 6995b0a..4ef93eb 100755 (executable)
@@ -8,6 +8,7 @@ import dbus.service
 import dbus.mainloop.glib
 import getopt, sys, pcap, dpkt, re, httplib, urllib
 import logging
+import logging.config
 import socket
 import time
 import gobject
@@ -41,9 +42,11 @@ class Pwnitter(dbus.service.Object):
                          in_signature='', out_signature='')
     def Start(self, filename=None):
         # FIXME: Prevent double Start()
-        device = self.device
         if filename is None: # Then we do *not* want to read from a PCap file but rather a monitor device
             self.setup_monitor(device)
+            device = self.device
+        else: # We have given a filename, so let's make PCap read from the file
+            device = filename
         self.is_running = True
         try:
             self.cap = pcap.pcap(device)
@@ -81,7 +84,7 @@ class Pwnitter(dbus.service.Object):
         return self.status
 
 
-    def tear_down_monitor(device='mon0'):
+    def tear_down_monitor(self, device='mon0'):
         cmd = '/sbin/ifconfig mon0 down'.split()
         subprocess.call(cmd)
         cmd = '/usr/sbin/iw dev mon0 del'.split()
@@ -237,6 +240,7 @@ if __name__ == '__main__':
                 'warn': logging.WARN, 'error': logging.ERROR,
                 'critical': logging.CRITICAL}.get(options.loglevel, "warn")
     logging.basicConfig(level=loglevel)
+    #logging.config.fileConfig('logging.conf') #FIXME: Have file configured logging
     log = logging.getLogger("Main")
 
     dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -250,7 +254,7 @@ if __name__ == '__main__':
     #object.Start()
 
     loop = gobject.MainLoop()
-    print "Running example signal emitter service."
+    log.info("Running example signal emitter service.")
     # FIXME: This is debug code
     #gobject.idle_add(pwnitter.MessageSent)