Index: /pykota/trunk/pykota/accounters/snmp.py
===================================================================
--- /pykota/trunk/pykota/accounters/snmp.py (revision 2438)
+++ /pykota/trunk/pykota/accounters/snmp.py (revision 2506)
@@ -187,4 +187,27 @@
             return self.printerInternalPageCounter
             
+def main(hostname) :
+    """Tries SNMP accounting for a printer host."""
+    class fakeFilter :
+        def __init__(self) :
+            self.PrinterName = "FakePrintQueue"
+            self.JobSizeBytes = 1
+            
+        def printInfo(self, msg, level="info") :
+            sys.stderr.write("%s : %s\n" % (level.upper(), msg))
+            sys.stderr.flush()
+            
+        def logdebug(self, msg) :    
+            self.printInfo(msg, "debug")
+            
+    class fakeAccounter :        
+        def __init__(self) :
+            self.arguments = "snmp:public"
+            self.filter = fakeFilter()
+            self.protocolHandler = Handler(self, hostname)
+        
+    acc = fakeAccounter()            
+    return acc.protocolHandler.retrieveInternalPageCounter()
+        
 if __name__ == "__main__" :            
     if len(sys.argv) != 2 :    
@@ -194,22 +217,4 @@
             return msg
             
-        class fakeFilter :
-            def __init__(self) :
-                self.PrinterName = "FakePrintQueue"
-                self.JobSizeBytes = 1
-                
-            def printInfo(self, msg, level="info") :
-                sys.stderr.write("%s : %s\n" % (level.upper(), msg))
-                sys.stderr.flush()
-                
-            def logdebug(self, msg) :    
-                self.printInfo(msg, "debug")
-                
-        class fakeAccounter :        
-            def __init__(self) :
-                self.arguments = "snmp:public"
-                self.filter = fakeFilter()
-                self.protocolHandler = Handler(self, sys.argv[1])
-            
-        acc = fakeAccounter()            
-        print "Internal page counter's value is : %s" % acc.protocolHandler.retrieveInternalPageCounter()
+        pagecounter = main(sys.argv[1])
+        print "Internal page counter's value is : %s" % pagecounter
Index: /pykota/trunk/pykota/accounters/pjl.py
===================================================================
--- /pykota/trunk/pykota/accounters/pjl.py (revision 2438)
+++ /pykota/trunk/pykota/accounters/pjl.py (revision 2506)
@@ -185,4 +185,27 @@
         return self.printerInternalPageCounter
             
+def main(hostname) :
+    """Tries PJL accounting for a printer host."""
+    class fakeFilter :
+        def __init__(self) :
+            self.PrinterName = "FakePrintQueue"
+            self.JobSizeBytes = 1
+            
+        def printInfo(self, msg, level="info") :
+            sys.stderr.write("%s : %s\n" % (level.upper(), msg))
+            sys.stderr.flush()
+            
+        def logdebug(self, msg) :    
+            self.printInfo(msg, "debug")
+            
+    class fakeAccounter :        
+        def __init__(self) :
+            self.arguments = "pjl:9100"
+            self.filter = fakeFilter()
+            self.protocolHandler = Handler(self, sys.argv[1])
+        
+    acc = fakeAccounter()            
+    return acc.protocolHandler.retrieveInternalPageCounter()
+    
 if __name__ == "__main__" :            
     if len(sys.argv) != 2 :    
@@ -192,22 +215,5 @@
             return msg
             
-        class fakeFilter :
-            def __init__(self) :
-                self.PrinterName = "FakePrintQueue"
-                self.JobSizeBytes = 1
-                
-            def printInfo(self, msg, level="info") :
-                sys.stderr.write("%s : %s\n" % (level.upper(), msg))
-                sys.stderr.flush()
-                
-            def logdebug(self, msg) :    
-                self.printInfo(msg, "debug")
-                
-        class fakeAccounter :        
-            def __init__(self) :
-                self.arguments = "pjl:9100"
-                self.filter = fakeFilter()
-                self.protocolHandler = Handler(self, sys.argv[1])
-            
-        acc = fakeAccounter()            
-        print "Internal page counter's value is : %s" % acc.protocolHandler.retrieveInternalPageCounter()
+        pagecounter = main(sys.argv[1])
+        print "Internal page counter's value is : %s" % pagecounter
+        
