diff options
| author | pepperpepperpepper <pepper@scannerjammer.com> | 2015-12-08 13:06:25 -0800 |
|---|---|---|
| committer | pepperpepperpepper <pepper@scannerjammer.com> | 2015-12-08 13:06:25 -0800 |
| commit | d3bd099bc89bb06e0d2e569e6cbab9a932ef2237 (patch) | |
| tree | 8f77520353e9b8c26cd310917d7a4af6c9271906 /ricky/utils.py | |
| parent | f2bdf5dbdb85ec0317e341f8963c21053624f479 (diff) | |
continuing to phase out api class
Diffstat (limited to 'ricky/utils.py')
| -rw-r--r-- | ricky/utils.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/ricky/utils.py b/ricky/utils.py index e887fa0..04e2074 100644 --- a/ricky/utils.py +++ b/ricky/utils.py @@ -1,6 +1,31 @@ +import os import sys import urllib import urllib2 +import simplejson as json +from ricky.config import OFFLINE, PB_DATA_URL + + +def data_from_url(url): + """ + retrieves image params from db using the url + """ + newfile = os.path.split(url)[-1] + if OFFLINE: + sys.path.append("./photoblaster") + from photoblaster.db.models.imcmd import ImCmd + result = ImCmd.search(newfile=newfile).first() + try: + return { + "module": result.tag.split(":")[0], + "params": json.loads(result.dataobj) + } + except AttributeError: + sys.stderr.write("No usable data found in db\n") + return None + else: + print http_request("%s?newfile=%s" % (PB_DATA_URL, newfile)) + raise NotImplementedError("Not yet implemented\n") def http_request(url, params={}): |
