Changeset View
Changeset View
Standalone View
Standalone View
wallace/module_optout.py
Show First 20 Lines • Show All 160 Lines • ▼ Show 20 Lines | for answer in answers: | ||||
exec('modules.cb_action_%s(%r, %r)' % (answer,'optout', filename)) | exec('modules.cb_action_%s(%r, %r)' % (answer,'optout', filename)) | ||||
os.unlink(filepath) | os.unlink(filepath) | ||||
#print "Moving filepath %s to new_filepath %s" % (filepath, new_filepath) | #print "Moving filepath %s to new_filepath %s" % (filepath, new_filepath) | ||||
#os.rename(filepath, new_filepath) | #os.rename(filepath, new_filepath) | ||||
#if hasattr(modules, 'cb_action_%s' % (optout_answer)): | #if hasattr(modules, 'cb_action_%s' % (optout_answer)): | ||||
#log.debug(_("Attempting to execute cb_action_%s()") % (optout_answer), level=8) | #log.debug(_("Attempting to execute cb_action_%s()") % (optout_answer), level=8) | ||||
Lint: PEP8 E116: unexpected indentation (comment) | |||||
#exec('modules.cb_action_%s(%r, %r)' % (optout_answer,'optout', new_filepath)) | #exec('modules.cb_action_%s(%r, %r)' % (optout_answer,'optout', new_filepath)) | ||||
Lint: PEP8 E116 unexpected indentation (comment) Lint: PEP8 E116: unexpected indentation (comment) | |||||
#return | #return | ||||
Lint: PEP8 E116 unexpected indentation (comment) Lint: PEP8 E116: unexpected indentation (comment) | |||||
def request(params=None): | def request(params=None): | ||||
params = json.dumps(params) | params = json.dumps(params) | ||||
optout_url = conf.get('wallace_optout', 'optout_url') | optout_url = conf.get('wallace_optout', 'optout_url') | ||||
try: | try: | ||||
f = urllib.urlopen(optout_url, params) | f = urllib.urlopen(optout_url, params) | ||||
except Exception, e: | except Exception: | ||||
log.error(_("Could not send request to optout_url %s") % (optout_url)) | log.error(_("Could not send request to optout_url %s") % (optout_url)) | ||||
return "DEFER" | return "DEFER" | ||||
response = f.read() | response = f.read() | ||||
try: | try: | ||||
response_data = json.loads(response) | response_data = json.loads(response) | ||||
except ValueError, e: | except ValueError: | ||||
# Some data is not JSON | # Some data is not JSON | ||||
print "Response data is not JSON" | print "Response data is not JSON" | ||||
return response_data['result'] | return response_data['result'] |
unexpected indentation (comment)