diff options
author | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-03-04 09:18:14 +0000 |
---|---|---|
committer | Adam Coldrick <adam.coldrick@codethink.co.uk> | 2014-03-04 09:18:14 +0000 |
commit | 48db041a53092c965e474ac6ffad72e2effdd292 (patch) | |
tree | 2df8499e75446516e7ccde9a6ddcd7420da612c2 | |
parent | 90cfc7566a962a99890035b948cfc8b155f0e3f9 (diff) | |
download | lorry-controller-48db041a53092c965e474ac6ffad72e2effdd292.tar.gz |
Update lorry-controller to allow it to make http requests
-rwxr-xr-x | lorry-controller | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/lorry-controller b/lorry-controller index 01c0225..a8a769f 100755 --- a/lorry-controller +++ b/lorry-controller @@ -21,6 +21,7 @@ import logging import os import time import re +import urllib2 from lorrycontroller.confparser import LorryControllerConfig @@ -274,6 +275,15 @@ class LorryController(cliapp.Application): self.runcmd(['git']+args, cwd=os.path.join(self.settings['work-area'], 'git')) + def maybe_http_request(self, url, dry=False): + if (not self.settings['dry-run']) or dry: + request = urllib2.Request(url, None, None) + response = urllib2.urlopen(request) + return responsecode, data, error + else: + logging.debug('DRY-RUN: Not sending a request to %s' % url) + return 0, 'DRY-RUN', 'DRY-RUN' + def maybe_runcmd(self, cmdline, dry=False, *args, **kwargs): if (not self.settings['dry-run']) or dry: return self.runcmd_unchecked(cmdline, *args, **kwargs) |