from web3 import Web3, HTTPProvider, IPCProvider from config import CASTLE_ABI, CASTLE_ADDRESS from pymemcache.client.base import Client as MemcacheClient from django.db import IntegrityError from common.daemon import Daemon from common.logger import log from common import dbmodel from etheremon_lib import config as etheremon_config from etheremon_lib.config import DATABASES from common import config as common_config from common import context common_config.init_config(etheremon_config) context.init_django('../', 'etheremon_lib.config') from etheremon_lib.models import EtheremonDB import time import json import traceback web3 = None memcache = None def update_battle(): castle_class = web3.eth.contract(abi=CASTLE_ABI) castle_contract = castle_class(CASTLE_ADDRESS) total_battle = castle_contract.call().totalBattle() # print "total_battle: ", total_battle log.info('update_battle|total_battle=%s', total_battle)
import os import sys import time curr_dir = os.path.dirname(os.path.abspath(__file__)) os.chdir(curr_dir) sys.path.append(os.path.join(curr_dir, '../../')) from common import context from django.core.wsgi import get_wsgi_application context.init_django('../', 'settings') application = get_wsgi_application() from common.logger import log from etheremon_lib.config import * from etheremon_lib.infura_client import InfuraClient from etheremon_lib.ladder_manager import * from etheremon_lib.utils import get_level INFURA_API_URL = INFURA_API_URLS["general"] def crawl_rank_data(): start_time = time.time() infura_client = InfuraClient(INFURA_API_URL) rank_data_contract = infura_client.getRankDataContract() rank_reward_contract = infura_client.getRankRewardContract() ladder_contract = infura_client.getLadderContract()
import os import sys import time import json from datetime import datetime from django.core.wsgi import get_wsgi_application curr_dir = os.path.dirname(os.path.abspath(__file__)) os.chdir(curr_dir) sys.path.append(os.path.join(curr_dir, '../')) from common import context context.init_django('../etheremon_api', 'settings') application = get_wsgi_application() from etheremon_lib.models import EtheremonDB from etheremon_lib.monster_config import MONSTER_CLASS_STATS from etheremon_lib.utils import get_new_monster_price from etheremon_lib.contract_manager import EtheremonLadderPracticeContract, EtheremonTradeContract from etheremon_lib.config import ETHERSCAN_API_KEYS from collections import OrderedDict init_time = datetime(1970, 1, 1) months = OrderedDict([ ('before', { 'start': 0, 'end': int((datetime(2018, 1, 1) - init_time).total_seconds())