diff options
Diffstat (limited to 'ricky')
| -rw-r--r-- | ricky/config.py | 12 | ||||
| -rw-r--r-- | ricky/pb.py | 20 | ||||
| -rw-r--r-- | ricky/pbbreaker/__init__.py | 2 |
3 files changed, 25 insertions, 9 deletions
diff --git a/ricky/config.py b/ricky/config.py index 9d0ddfa..04da7e1 100644 --- a/ricky/config.py +++ b/ricky/config.py @@ -4,10 +4,10 @@ TEST_URL = ( "http://i.asdf.us/im/" "65/imBreak5qI6DN2_14254-PbPattern_1444004782_pepper.png" ) -PATTERN_URL_BASE = "http://localhost:8999/impattern/patterns" -IMPATTERN_URL = "http://localhost:8999/im/api/impattern" -IMGRID_URL = "http://localhost:8999/im/api/imgrid" -IMGRADIENT_URL = "http://localhost:8999/im/api/imgradient" -IMBREAK_URL = "http://localhost:8999/im/api/imbreak" -OFFLINE = False +PATTERN_URL_BASE = "http://asdf.us/impattern/patterns" +IMPATTERN_URL = "http://asdf.us/im/api/impattern" +IMGRID_URL = "http://asdf.us/im/api/imgrid" +IMGRADIENT_URL = "http://asdf.us/im/api/imgradient" +IMBREAK_URL = "http://asdf.us/im/api/imbreak" +OFFLINE = True PROBABILITIES_DIR = "share/probabilities" diff --git a/ricky/pb.py b/ricky/pb.py index 6e70ea6..d600708 100644 --- a/ricky/pb.py +++ b/ricky/pb.py @@ -26,14 +26,28 @@ class Pb(object): req = urllib2.Request(url, params, headers) response = urllib2.urlopen(req) return response.read() - except urllib.error.HTTPError: - sys.stderr.write("Post Request failed!") + except ValueError: + sys.stderr.write( + "Bad Post params or Url sent to photoblaster" + "api.\n" + ) + except urllib2.URLError: + sys.stderr.write( + "Could not complete post request to the given url:\n" + + ("URL: %s\n" % url) + + ("PARAMS: %s\n" % params) + ) def call(self, params): if self._offline: sys.path.append("./photoblaster") from photoblaster.modules import Pb - pass + for pbcls in Pb.__subclasses__(): + if pbcls.__name__ == self.__class__.__name__: + params_dict = params.as_dict() + instance = pbcls(**params_dict) + instance.create() + return instance.file_dict() return json.loads( self.post_request(self.url, params.as_dict()) ) diff --git a/ricky/pbbreaker/__init__.py b/ricky/pbbreaker/__init__.py index 3a25a2b..2a1c105 100644 --- a/ricky/pbbreaker/__init__.py +++ b/ricky/pbbreaker/__init__.py @@ -5,7 +5,9 @@ from ricky.config import IMBREAK_URL class PbBreaker(Pb): def __init__(self): + super(PbBreaker, self).__init__() self.url = IMBREAK_URL + def params_init(self): new_params = Params() # new_params = self.get_from_server() |
