Return-Path: X-Original-To: apmail-community-commits-archive@minotaur.apache.org Delivered-To: apmail-community-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A198F18AE9 for ; Sun, 12 Jul 2015 17:56:25 +0000 (UTC) Received: (qmail 59994 invoked by uid 500); 12 Jul 2015 17:56:25 -0000 Delivered-To: apmail-community-commits-archive@community.apache.org Received: (qmail 59968 invoked by uid 500); 12 Jul 2015 17:56:25 -0000 Mailing-List: contact commits-help@community.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@community.apache.org Delivered-To: mailing list commits@community.apache.org Received: (qmail 59959 invoked by uid 99); 12 Jul 2015 17:56:25 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 12 Jul 2015 17:56:25 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 23A7CAC0113 for ; Sun, 12 Jul 2015 17:56:25 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1690493 - /comdev/projects.apache.org/scripts/cronjobs/pubsubber.py Date: Sun, 12 Jul 2015 17:56:24 -0000 To: commits@community.apache.org From: sebb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150712175625.23A7CAC0113@hades.apache.org> 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)