aboutsummaryrefslogtreecommitdiffstats
path: root/git_deps/handler.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_deps/handler.py')
-rwxr-xr-xgit_deps/handler.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/git_deps/handler.py b/git_deps/handler.py
index 2fa2c54..572ed84 100755
--- a/git_deps/handler.py
+++ b/git_deps/handler.py
@@ -2,9 +2,13 @@
from __future__ import print_function
+import logging
+import logging.handlers
import os
+import re
import subprocess
import sys
+import urllib
from urlparse import urlparse
from git_deps.utils import abort
@@ -14,11 +18,34 @@ def usage():
abort("usage: git-handler URL")
+def get_logger():
+ logger = logging.getLogger('foo')
+ # logger.setLevel(logging.DEBUG)
+
+ slh = logging.handlers.SysLogHandler(address='/dev/log')
+ slf = logging.Formatter('gitfile-handler: %(message)s')
+ slh.setFormatter(slf)
+ logger.addHandler(slh)
+ logger.addHandler(logging.StreamHandler())
+
+ return logger
+
+
def main(args):
if len(args) != 1:
usage()
+ logger = get_logger()
+
url = args[0]
+ logger.debug("received URL: %s" % url)
+ if re.search(r'%23', url):
+ # Uh-oh, double-encoded URIs! Some versions of Chrome
+ # encode the value you set location.href too.
+ url = urllib.unquote(url)
+ logger.debug("unquoted: %s" % url)
+ url = urlparse(url)
+ logger.debug("parsed: %r" % repr(url))
if url.scheme != 'gitfile':
abort("URL must use gitfile:// scheme")