Add parameters for scripts that talk to Gerrit

Not all gerrit installations are configured the same.  This adds parameters
to the gerrit sync script and expire script so that it can work from the
command line and cron on all servers.

Fixes bug #994201

Change-Id: Iac37e18aaf7a10fb5594be233e33b000eabed336
diff --git a/expire_old_reviews.py b/expire_old_reviews.py
index 89686c8..1ba936e 100644
--- a/expire_old_reviews.py
+++ b/expire_old_reviews.py
@@ -22,10 +22,15 @@
 import paramiko
 import json
 import logging
+import argparse
 
-GERRIT_USER = os.environ.get('GERRIT_USER', 'launchpadsync')
-GERRIT_SSH_KEY = os.environ.get('GERRIT_SSH_KEY',
-                                 '/home/gerrit2/.ssh/launchpadsync_rsa')
+parser = argparse.ArgumentParser()
+parser.add_argument('user', help='The gerrit admin user')
+parser.add_argument('ssh_key', help='The gerrit admin SSH key file')
+options = parser.parse_args()
+
+GERRIT_USER = options.user
+GERRIT_SSH_KEY = options.ssh_key
 
 logging.basicConfig(format='%(asctime)-6s: %(name)s - %(levelname)s - %(message)s', filename='/var/log/gerrit/expire_reviews.log')
 logger= logging.getLogger('expire_reviews')
diff --git a/update_gerrit_users.py b/update_gerrit_users.py
index 0414230..6816291 100755
--- a/update_gerrit_users.py
+++ b/update_gerrit_users.py
@@ -25,7 +25,7 @@
 
 import StringIO
 import ConfigParser
-
+import argparse
 import MySQLdb
 
 from launchpadlib.launchpad import Launchpad
@@ -36,13 +36,18 @@
 
 DEBUG = False
 
-GERRIT_USER = os.environ.get('GERRIT_USER', 'launchpadsync')
+parser = argparse.ArgumentParser()
+parser.add_argument('user', help='The gerrit admin user')
+parser.add_argument('ssh_key', help='The gerrit admin SSH key file')
+parser.add_argument('site', help='The site in use (typically openstack or stackforge)')
+options = parser.parse_args()
+
+GERRIT_USER = options.user
 GERRIT_CONFIG = os.environ.get('GERRIT_CONFIG',
                                  '/home/gerrit2/review_site/etc/gerrit.config')
 GERRIT_SECURE_CONFIG = os.environ.get('GERRIT_SECURE_CONFIG',
                                  '/home/gerrit2/review_site/etc/secure.config')
-GERRIT_SSH_KEY = os.environ.get('GERRIT_SSH_KEY',
-                                 '/home/gerrit2/.ssh/launchpadsync_rsa')
+GERRIT_SSH_KEY = options.ssh_key
 GERRIT_CACHE_DIR = os.path.expanduser(os.environ.get('GERRIT_CACHE_DIR',
                                 '~/.launchpadlib/cache'))
 GERRIT_CREDENTIALS = os.path.expanduser(os.environ.get('GERRIT_CREDENTIALS',
@@ -368,7 +373,7 @@
         if os_project_name is not None:
           if os_project_name.endswith("-core"):
               os_project_name = os_project_name[:-5]
-          os_project_name = "openstack/%s" % os_project_name
+          os_project_name = "{site}/{project}".format(site=options.site, project=os_project_name)
           if os_project_name in projects:
             if not cur.execute("""select account_id
                                    from account_project_watches