def init(params=None): global _haltEvent # Create the event which can be used to halt all bots. _haltEvent = threading.Event() # Initialize the databases. ItemDatabase.init() SkillDatabase.init() # Force HTTP requests to timeout after 5 minutes. socket.setdefaulttimeout(300)
def init(params=None): global _haltEvent # Create the event which can be used to halt all bots. _haltEvent = threading.Event() # Initialize the databases. ItemDatabase.init() SkillDatabase.init() # Force HTTP requests to timeout after 5 minutes. socket.setdefaulttimeout(300) # Seed the pseudo-random number generator. random.seed()
def mergeItems(): ItemDatabase.init() for i in range(len(_items)): item = _items[i] try: savedItem = ItemDatabase.getItemFromId(item["id"]) for k,v in item.iteritems(): if k != "enchantments" and k != "type": savedItem[k] = v if "enchantments" in item and len(item["enchantments"]) > 0: if "enchantments" not in savedItem: savedItem["enchantments"] = {} for k,v in item["enchantments"].iteritems(): savedItem["enchantments"][k] = v _items[i] = savedItem except ItemNotFoundError: r = ItemDescriptionRequest(_session, item["descId"]) itemInfo = r.doRequest() for k,v in itemInfo.iteritems(): item[k] = v
def mergeItems(): ItemDatabase.init() for i in range(len(_items)): item = _items[i] try: savedItem = ItemDatabase.getItemFromId(item["id"]) for k,v in item.iteritems(): if k != "enchantments" and k != "type": savedItem[k] = v if "enchantments" in item and len(item["enchantments"]) > 0: if "enchantments" not in savedItem: savedItem["enchantments"] = {} for k,v in item["enchantments"].iteritems(): savedItem["enchantments"][k] = v _items[i] = savedItem except Error.Error, inst: if inst.code == Error.ITEM_NOT_FOUND: r = ItemDescriptionRequest(_session, item["descId"]) itemInfo = r.doRequest() for k,v in itemInfo.iteritems(): item[k] = v else: raise inst
def runTest(self): ItemDatabase.init()