Пример #1
0
                        modifs = {
                            'gems': [None] * len(item_infos['gems']),
                            'enchant': None,
                        }

                        for index, gem in enumerate(item_infos['gems']):
                            if gem == 0:
                                continue

                            gem_id = amr_gems[gem]['id']

                            if gem_id != item.gems[index]:
                                if not (json_data['items']).has_key(
                                        str(gem_id)):
                                    print "    Retrieving gem #%d..." % gem_id
                                    connection = Connection()
                                    json_gem = connection.get_item(
                                        region, gem_id)
                                    if json_gem is not None:
                                        json_data['items'][str(
                                            gem_id)] = json_gem
                                        print "        %s" % json_gem[
                                            'name'].encode('utf-8')
                                    else:
                                        json_data['items'][str(gem_id)] = None
                                        print "        FAILED"

                                modifs['gems'][index] = gem_id

                        if (item_infos['enchant'] is not None) and (
                                item_infos['enchant'] != item.enchant):
Пример #2
0
# -*- coding: utf-8 -*-

import battlenet
from battlenet import Connection

if __name__ == "__main__":

    connection = Connection(public_key='7a09ed83ea0740e0bf284e903c8a029f',
                            private_key='6HNxhgBdt92TrO7bUFj0bByKWywOzAtw',
                            locale='cn')
    realms = connection.get_all_realms(battlenet.CHINA)
    print(realms)

    # import hmac

    # secret_key1 = b'This is my secret key'
    # message1 = b'Hello world'
    # hex_res1 = hmac.new(secret_key1, message1, digestmod="MD5").hexdigest()
    # print(hex_res1)  # b8908a20bd70f465330b434e18441d3b