def handle_noargs(self, **options): print "Downloading rates http://openexchangerates.org/api/latest.json" url = "http://openexchangerates.org/api/latest.json?app_id=%s" % OPENEXCHANGERATES_API_KEY print "Parsing rates..." rates_result = json.load(urllib.urlopen(url)) print "Downloading currency names http://openexchangerates.org/api/currencies.json" url = "http://openexchangerates.org/api/currencies.json?app_id=%s" % OPENEXCHANGERATES_API_KEY print "Parsing names..." currencies = json.load(urllib.urlopen(url)) print "updating currencies" base = rates_result['base'] rates = rates_result['rates'] for code, rate in rates.iteritems(): try: name = currencies[code] except KeyError: name = code update_currency(code, name, rate, base) print "Finished"
def handle_noargs(self, **options): print "Downloading rates http://openexchangerates.org/latest.json" url = "http://openexchangerates.org/latest.json" print "Parsing rates..." rates_result = json.load(urllib.urlopen(url)) print "Downloading currency names http://openexchangerates.org/currencies.json" url = "http://openexchangerates.org/currencies.json" print "Parsing names..." currencies = json.load(urllib.urlopen(url)) print "updating currencies" base = rates_result['base'] rates = rates_result['rates'] for code, rate in rates.iteritems(): try: name = currencies[code] except KeyError: name = code print "Updating %s (%s) to: %s" % (name, code, rate) update_currency(code, name, rate, base) print "Finished"
def handle_noargs(self, **options): print "Downloading rates http://openexchangerates.org/latest.json" url = "http://openexchangerates.org/latest.json" print "Parsing rates..." rates_result = json.load(urllib.urlopen(url)) print "Downloading currency names http://openexchangerates.org/currencies.json" url = "http://openexchangerates.org/currencies.json" print "Parsing names..." currencies = json.load(urllib.urlopen(url)) print "updating currencies" base = rates_result['base'] rates = rates_result['rates'] for code, rate in rates.iteritems(): name = currencies[code] print "Updating %s (%s) to: %s" % (name, code, rate) update_currency(code, name, rate, base) print "Finished"