item = ItemDatabase.getItemByName("old coin purse") use_request = UseItemRequest(session, item["id"]) print "Got %s meat from old coin purse" % use_request.responseData["meat"] except Error.Error, e: if e.code == Error.NOT_ENOUGH_ITEMS: print "Whoops! You didn't have an old coin purse to use...", e.message else: #we can raise the error again to stop the script: raise e print "Smashing a titanium assault umbrella:" try: item = ItemDatabase.getItemByName("titanium assault umbrella") pulverize = PulverizeRequest(session, item["id"]) print "After smashing the item you have received the following:" for result in pulverize.responseData["results"]: print "%s (%s)" % (result["name"], result["quantity"]) except Error.Error, e: if e.code == Error.ITEM_NOT_FOUND: print "You don't have a hammer" elif e.code == Error.SKILL_NOT_FOUND: print "You don't know how to pulverize" elif e.code == Error.NOT_ENOUGH_ITEMS: print "You don't have an umbrella to pulverize" else: print "Unexpected error smashing umbrella:", e.msg #since this time we don't raise, it will just keep going print "All done!" session.logout()
config = ConfigParser.RawConfigParser(allow_no_value=True) config.readfp(args.c) guser = config.get('google','user') gpwd = config.get('google','passwd') gsheet = config.get('google','sheet') client, curr_key, curr_wksht_id = google_login(guser,gpwd,gsheet) nrl = get_names(client, curr_key, curr_wksht_id) #get names and thier row names = nrl.keys() # list of names fastest = {} # Login to the KoL servers. s = Session() s.login(config.get('kol','user'), config.get('kol','passwd')) uids = get_uids(s,names) # lookup uids from names #for each users grab their fastest ascensions and update the spreadsheet with them #for name, uid in uids.items(): pnames = uids.keys() pnames.sort() for name in pnames: uid = uids[name] fastest[name] = get_hist(s, uid, starts, ends) print name, fastest[name].keys() update_spread(client, curr_key, curr_wksht_id, nrl[name],fastest[name]) s.logout()