示例#1
0
def run_update(signum):
    if uwsgi.is_locked(signum):
        return
    uwsgi.lock(signum)
    try:
        while True:
            try:
                logging.info('Updating accounts..')
                scan.update_accounts()
                logging.info('Updating addresses..')
                scan.update_addresses()
                break
            except:
                logging.exception('Failed to update accounts/addresses, retrying')
                time.sleep(30)

        for i in range(100):
            try:
                for acc in scan.ACCOUNTS:
                    if hash(acc) % PARALLEL == signum-1:
                        for region in os.getenv('REGIONS').split(','):
                            for i in range(3):
                                try:
                                    scan.update_connections(acc, region)
                                    break
                                except botocore.exceptions.ClientError:
                                    logging.exception('Client error')
                                    # throttling
                                    time.sleep(60)
            except:
                logging.exception('Failed to update')
            time.sleep(60)
    finally:
        uwsgi.unlock(signum)
示例#2
0
def run_update(signum):
    if uwsgi.is_locked(signum):
        return
    uwsgi.lock(signum)
    try:
        while True:
            try:
                logging.info('Updating accounts..')
                scan.update_accounts()
                logging.info('Updating addresses..')
                scan.update_addresses()
                break
            except:
                logging.exception(
                    'Failed to update accounts/addresses, retrying')
                time.sleep(30)

        for i in range(100):
            try:
                for acc in scan.ACCOUNTS:
                    if hash(acc) % PARALLEL == signum - 1:
                        for region in os.getenv('REGIONS').split(','):
                            for i in range(3):
                                try:
                                    scan.update_connections(acc, region)
                                    break
                                except botocore.exceptions.ClientError:
                                    logging.exception('Client error')
                                    # throttling
                                    time.sleep(60)
            except:
                logging.exception('Failed to update')
            time.sleep(60)
    finally:
        uwsgi.unlock(signum)
示例#3
0
def get_accounts():
    scan.update_accounts()
    return {
        k: {
            'name': v['name'],
            'last_update': get_time(scan.get_last_update(k, v['regions'][0]))
        }
        for k, v in scan.ACCOUNTS.items()
    }
示例#4
0
def get_connections(date=None):
    scan.update_accounts()
    if not date:
        date = flask.request.args.get('date')
    res = {}
    for account_id, data in scan.ACCOUNTS.items():
        for region in data['regions']:
            res['/'.join((account_id, region))] = get_connections_by_account(account_id, region, date)
    return res
示例#5
0
def get_endpoints(date=None):
    scan.update_accounts()
    if not date:
        date = flask.request.args.get("date")
    res = {}
    for account_id, data in scan.ACCOUNTS.items():
        for region in data["regions"]:
            res["/".join((account_id, region))] = get_endpoints_by_account(account_id, region, date)
    return res
示例#6
0
def get_connections(date=None):
    scan.update_accounts()
    if not date:
        date = flask.request.args.get('date')
    res = {}
    for account_id, data in scan.ACCOUNTS.items():
        for region in data['regions']:
            res['/'.join((account_id, region))] = get_connections_by_account(
                account_id, region, date)
    return res
示例#7
0
    def run(self):
        logging.info('Updating accounts..')
        scan.update_accounts()
        logging.info('Updating addresses..')
        scan.update_addresses()
        account_ids = collections.defaultdict(list)
        for acc in scan.ACCOUNTS:
            account_ids[hash(acc) % 16].append(acc)

        for ids in account_ids.values():
            thread = BackgroundAccountThread(ids)
            thread.start()
示例#8
0
    def run(self):
        logging.info('Updating accounts..')
        scan.update_accounts()
        logging.info('Updating addresses..')
        scan.update_addresses()
        account_ids = collections.defaultdict(list)
        for acc in scan.ACCOUNTS:
            account_ids[hash(acc) % 16].append(acc)

        for ids in account_ids.values():
            thread = BackgroundAccountThread(ids)
            thread.start()
示例#9
0
    def run(self):
        while True:
            try:
                logging.info('Updating accounts..')
                scan.update_accounts()
                logging.info('Updating addresses..')
                scan.update_addresses()
                break
            except:
                logging.exception('Failed to update accounts/addresses, retrying')
                time.sleep(30)
        account_ids = collections.defaultdict(list)
        for acc in scan.ACCOUNTS:
            account_ids[hash(acc) % 16].append(acc)

        for ids in account_ids.values():
            thread = BackgroundAccountThread(ids)
            thread.start()
示例#10
0
    def run(self):
        while True:
            try:
                logging.info('Updating accounts..')
                scan.update_accounts()
                logging.info('Updating addresses..')
                scan.update_addresses()
                break
            except:
                logging.exception(
                    'Failed to update accounts/addresses, retrying')
                time.sleep(30)
        account_ids = collections.defaultdict(list)
        for acc in scan.ACCOUNTS:
            account_ids[hash(acc) % 16].append(acc)

        for ids in account_ids.values():
            thread = BackgroundAccountThread(ids)
            thread.start()
示例#11
0
def get_accounts():
    scan.update_accounts()
    return {k: {'name': v['name'], 'last_update': get_time(scan.get_last_update(k, v['regions'][0]))}
            for k, v in scan.ACCOUNTS.items()}
示例#12
0
def get_accounts():
    scan.update_accounts()
    return {
        k: {"name": v["name"], "last_update": get_time(scan.get_last_update(k, v["regions"][0]))}
        for k, v in scan.ACCOUNTS.items()
    }