def handle(self, *args, **options): import json import requests from time import sleep from custom import the_champions_of_decentralized_commerce from ob.util import get_exchange_rates get_exchange_rates() qs = Profile.objects.filter(network='mainnet', online=True).exclude(name='') try: known_pks = [p['peerID'] for p in qs.values('peerID')] for peerID in the_champions_of_decentralized_commerce: if peerID not in known_pks: print(peerID) p, profile_created = Profile.objects.get_or_create( pk=peerID) if profile_created or p.should_update(): p.sync(testnet=False) else: print('skipping profile') except ReadTimeout: pass print("Successfully bootstraped peers") from django.utils.timezone import now Profile.objects.filter().update(was_online=now())
def handle(self, *args, **options): from custom import good_nodes from ob.util import get_exchange_rates, update_price_values, \ update_verified get_exchange_rates() qs = Profile.objects.filter(network='mainnet', online=True).exclude(name='') try: known_pks = [p['peerID'] for p in qs.values('peerID')] for peerID in good_nodes: if peerID not in known_pks: logger.debug(peerID) p, profile_created = Profile.objects.get_or_create( pk=peerID) sync_profile(p) except ReadTimeout: pass logger.debug("Successfully bootstraped peers") update_verified() update_price_values() from django.utils.timezone import now Profile.objects.filter().update(was_online=now())
def get_price(price_data): price, pricing_currency, price_value = 0, 0, 0 if price_data: price = price_data.get('amount') pricing_currency = price_data.get('currencyCode') c, fx_created = ExchangeRate.objects.get_or_create( symbol=pricing_currency) if fx_created: from ob.util import get_exchange_rates get_exchange_rates() price_value = get_price_value(price, c) return price, pricing_currency, price_value
def update_price_values(): get_exchange_rates() sleep(3) update_price_values()
def handle(self, *args, **options): get_exchange_rates() update_price_values()