Ability to run cmd scripts directly.
Add a conditional check to call main() in cmd scripts if they're
being invoked directly. Some already had them, but most simply
relied on the entrypoints wrappers declared in setup.py. With this
change, users can more easily test and debug the various command
scripts directly without needing setup magic.
Change-Id: I16c26e954687de8af5f971936fb8eee2072c06bc
Reviewed-on: https://review.openstack.org/26966
Reviewed-by: Paul Belanger <paul.belanger@polybeacon.com>
Reviewed-by: Khai Do <zaro0508@gmail.com>
Reviewed-by: Clark Boylan <clark.boylan@gmail.com>
Approved: James E. Blair <corvus@inaugust.com>
Reviewed-by: James E. Blair <corvus@inaugust.com>
Tested-by: Jenkins
diff --git a/jeepyb/cmd/close_pull_requests.py b/jeepyb/cmd/close_pull_requests.py
index 8ab9157..2fd509a 100644
--- a/jeepyb/cmd/close_pull_requests.py
+++ b/jeepyb/cmd/close_pull_requests.py
@@ -100,3 +100,6 @@
completed=True)
issue.create_comment(MESSAGE % vars)
req.edit(state="closed")
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/expire_old_reviews.py b/jeepyb/cmd/expire_old_reviews.py
index d381685..1cdd473 100644
--- a/jeepyb/cmd/expire_old_reviews.py
+++ b/jeepyb/cmd/expire_old_reviews.py
@@ -102,3 +102,6 @@
break
logger.info('End expire review')
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/fetch_remotes.py b/jeepyb/cmd/fetch_remotes.py
index f34e518..f808a9d 100644
--- a/jeepyb/cmd/fetch_remotes.py
+++ b/jeepyb/cmd/fetch_remotes.py
@@ -77,3 +77,6 @@
run_command("git remote add -f upstream %s" % remote_url)
# Fetch new revs from it
run_command("git remote update upstream")
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/manage_projects.py b/jeepyb/cmd/manage_projects.py
index 9c5bf52..d52f096 100644
--- a/jeepyb/cmd/manage_projects.py
+++ b/jeepyb/cmd/manage_projects.py
@@ -390,3 +390,6 @@
run_command("rm -fr %s" % tmpdir)
finally:
os.unlink(ssh_env['GIT_SSH'])
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/notify_impact.py b/jeepyb/cmd/notify_impact.py
index 559fd7f..fd14173 100644
--- a/jeepyb/cmd/notify_impact.py
+++ b/jeepyb/cmd/notify_impact.py
@@ -89,3 +89,6 @@
# Process impacts found in git log
if impacted(git_log, args.impact):
process_impact(git_log, args)
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/trivial_rebase.py b/jeepyb/cmd/trivial_rebase.py
index c930691..d9de410 100644
--- a/jeepyb/cmd/trivial_rebase.py
+++ b/jeepyb/cmd/trivial_rebase.py
@@ -278,3 +278,6 @@
approve_category, score, options.commit]
SuExec(options, approval["account_id"], ' '.join(gerrit_approve_cmd))
sys.exit(0)
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/update_blueprint.py b/jeepyb/cmd/update_blueprint.py
index 1f83124..af382d0 100644
--- a/jeepyb/cmd/update_blueprint.py
+++ b/jeepyb/cmd/update_blueprint.py
@@ -140,3 +140,6 @@
conn = MySQLdb.connect(user=DB_USER, passwd=DB_PASS, db=DB_DB)
find_specs(launchpad, conn, args)
+
+if __name__ == "__main__":
+ main()
diff --git a/jeepyb/cmd/update_bug.py b/jeepyb/cmd/update_bug.py
index e86be8d..69c2f98 100644
--- a/jeepyb/cmd/update_bug.py
+++ b/jeepyb/cmd/update_bug.py
@@ -274,3 +274,6 @@
# Process bugtasks found in git log
for bugtask in find_bugs(launchpad, git_log, args):
process_bugtask(launchpad, bugtask, git_log, args)
+
+if __name__ == "__main__":
+ main()