[Secure-testing-commits] r39342 - bin

Sebastien Delafond seb at moszumanska.debian.org
Sat Jan 30 10:04:54 UTC 2016


Author: seb
Date: 2016-01-30 10:04:53 +0000 (Sat, 30 Jan 2016)
New Revision: 39342

Modified:
   bin/tracker_service.py
Log:
[tracker] Massage tracker_service.py a bit, so it can be import'ed in ipython

Modified: bin/tracker_service.py
===================================================================
--- bin/tracker_service.py	2016-01-30 09:43:14 UTC (rev 39341)
+++ bin/tracker_service.py	2016-01-30 10:04:53 UTC (rev 39342)
@@ -8,20 +8,23 @@
 from web_support import *
 import json
 
-if len(sys.argv) not in (3, 5):
-    print "usage: python tracker_service.py SOCKET-PATH DATABASE-PATH"
-    print "       python tracker_service.py URL HOST PORT DATABASE-PATH"
-    sys.exit(1)
-if len(sys.argv) == 3:
-    socket_name = sys.argv[1]
-    db_name = sys.argv[2]
-    webservice_base_class = WebService
+if __name__ == "__main__":
+    if len(sys.argv) not in (3, 5):
+        print "usage: python tracker_service.py SOCKET-PATH DATABASE-PATH"
+        print "       python tracker_service.py URL HOST PORT DATABASE-PATH"
+        sys.exit(1)
+    if len(sys.argv) == 3:
+        socket_name = sys.argv[1]
+        db_name = sys.argv[2]
+        webservice_base_class = WebService
+    else:
+        server_base_url = sys.argv[1]
+        server_address = sys.argv[2]
+        server_port = int(sys.argv[3])
+        socket_name = (server_base_url, server_address, server_port)
+        db_name = sys.argv[4]
+        webservice_base_class = WebServiceHTTP
 else:
-    server_base_url = sys.argv[1]
-    server_address = sys.argv[2]
-    server_port = int(sys.argv[3])
-    socket_name = (server_base_url, server_address, server_port)
-    db_name = sys.argv[4]
     webservice_base_class = WebServiceHTTP
 
 def clean_dict(d):
@@ -1622,4 +1625,5 @@
     def pre_dispatch(self):
         pass
 
-TrackerService(socket_name, db_name).run()
+if __name__ == "__main__":
+    TrackerService(socket_name, db_name).run()




More information about the Secure-testing-commits mailing list