community-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject svn commit: r1690493 - /comdev/projects.apache.org/scripts/cronjobs/pubsubber.py
Date Sun, 12 Jul 2015 17:56:24 GMT
Author: sebb
Date: Sun Jul 12 17:56:24 2015
New Revision: 1690493

URL: http://svn.apache.org/r1690493
Log:
COMDEV-150 - pubsubber.py - incorrect argument validation

Modified:
    comdev/projects.apache.org/scripts/cronjobs/pubsubber.py

Modified: comdev/projects.apache.org/scripts/cronjobs/pubsubber.py
URL: http://svn.apache.org/viewvc/comdev/projects.apache.org/scripts/cronjobs/pubsubber.py?rev=1690493&r1=1690492&r2=1690493&view=diff
==============================================================================
--- comdev/projects.apache.org/scripts/cronjobs/pubsubber.py (original)
+++ comdev/projects.apache.org/scripts/cronjobs/pubsubber.py Sun Jul 12 17:56:24 2015
@@ -20,13 +20,6 @@ else:
     import json, http.client, urllib.request, urllib.parse, configparser, re, base64, sys,
os, time, atexit, signal, logging, subprocess
 
 
-if len(sys.argv) < 4:
-    print("Usage: pubsubber.py start|stop [repo-path] [file-path]")
-    print("for example: pubsubber.py start comdev/projects.apache.org /var/www/projects.apache.org")
-    sys.exit(1)
-    
-watchPath = sys.argv[2]
-filePath = sys.argv[3]
 debug = False
 
 ###########################################################
@@ -279,24 +272,32 @@ def main():
 class MyDaemon(daemon):
     def run(self):
         main()
- 
+
+def usage():
+    print("usage: %s start|stop|restart|foreground [repo-path] [file-path]" % sys.argv[0])
+    print("for example: %s start comdev/projects.apache.org /var/www/projects.apache.org"
 % sys.argv[0])
+    
 if __name__ == "__main__":
         daemon = MyDaemon('/tmp/pubsubber.pid')
         if len(sys.argv) >= 2:
-                if 'start' == sys.argv[1]:
+                if 'start' == sys.argv[1] and len(sys.argv) >= 4:
+                    watchPath = sys.argv[2]
+                    filePath = sys.argv[3]
                     daemon.start()
                 elif 'stop' == sys.argv[1]:
                     daemon.stop()
                 elif 'restart' == sys.argv[1]:
                     daemon.restart()
-                elif 'foreground' == sys.argv[1]:
+                elif 'foreground' == sys.argv[1] and len(sys.argv) >= 4:
                     debug = True
+                    watchPath = sys.argv[2]
+                    filePath = sys.argv[3]
                     main()
                 else:
-                    print("Unknown command")
+                    usage()
                     sys.exit(2)
                 sys.exit(0)
         else:
-                print("usage: %s start|stop|restart|foreground" % sys.argv[0])
+                usage()
                 sys.exit(2)
 



Mime
View raw message