Пример #1
0
    def __init__(self, domain=None, **attrs):
        domain = domain or attrs.get('name', None)
        if not isinstance(domain, str):
            raise ValueError('Invalid {0}/{1}.'.format(domain, type(domain)))
        domain = domain.lower()
        if 'www.' in domain:
            domain = domain.split('www.')[-1]
        self.name = domain
        self.dom = self._get_dom_()

        # Is it a valid domain?
        try:
            getattr(regex_map, self.dom)
            self.allowed = True
        except AttributeError:
            self.allowed = False

        # Initialize not available
        self.available = False

        # Mongo Cursor
        self.db = get_db_conn(config)

        # Initialize Domain attrs
        for field in self.fields[1:]:
            setattr(self, field, attrs.get(field, None))
Пример #2
0
 def __init__(self, *args, **kwargs):
     super().__init__(*args, **kwargs)
     self.db = get_db_conn(config)
Пример #3
0
#! /usr/bin/python3.5
from configparser import ConfigParser
import asyncio

from collector.whois import DomainExpiration
from server.conn import get_db_conn

config = ConfigParser()
config.read('config.conf')

db = get_db_conn(config)


@asyncio.coroutine
def get_domains():
    """
    Coroutine - Get all domains from db `DomainExpiration`
    """
    for domain in db.domains.find():
        domain = DomainExpiration(**domain)
        yield from domain.run()

if __name__ == '__main__':

    # Get event loop
    loop = asyncio.get_event_loop()

    loop.run_until_complete(get_domains())

    loop.close()