Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make register-github-webhooks multi-instance friendly.

  • Loading branch information...
commit 327b624ac70ce5b59ff7d4567e64330577a7e0f6 1 parent 009c1c3
@spladug authored
Showing with 26 additions and 3 deletions.
  1. +26 −3 register-github-webhooks.py
View
29 register-github-webhooks.py
@@ -5,7 +5,9 @@
import json
import requests
from requests.auth import HTTPBasicAuth
+import os
import urlparse
+import sys
from harold.plugins.github import REPOSITORY_PREFIX
@@ -23,17 +25,38 @@ def _make_hooks_url(repo, endpoint=None):
None
))
+
+# config file is an expected argument
+bin_name = os.path.basename(sys.argv[0])
+if len(sys.argv) != 2:
+ print >> sys.stderr, "USAGE: %s INI_FILE" % bin_name
+ sys.exit(1)
+
+config_file = sys.argv[1]
+try:
+ parser = ConfigParser.ConfigParser()
+ with open(config_file, "r") as f:
+ parser.readfp(f)
+except Exception as e:
+ print >> sys.stderr, "%s: failed to read config file %r: %s" % (
+ bin_name,
+ config_file,
+ e,
+ )
+ sys.exit(1)
+
# figure out which repos we care about
repositories = []
-parser = ConfigParser.ConfigParser()
-with open("harold.ini", "r") as f:
- parser.readfp(f)
for section in parser.sections():
if not section.startswith(REPOSITORY_PREFIX):
continue
repositories.append(section[len(REPOSITORY_PREFIX):])
+if not repositories:
+ print "No repositories to register with!"
+ sys.exit(0)
+
print "I will ensure webhooks are registered for:"
for repo in repositories:
print " - " + repo

0 comments on commit 327b624

Please sign in to comment.
Something went wrong with that request. Please try again.