Пример #1
0
def init_regions_and_items():
    crest_connection = CrestConnection()
    sql_connection = SqlConnection(CONNECTION_STRING)
    sql_connection.create_tables()
    sql_connection.start_connection()
    get_regions(sql_connection.session, crest_connection)
    get_items(sql_connection.session, crest_connection)
Пример #2
0
 def setUpClass(cls):
     cls.eve = CrestConnection()
     cls._connection = SqlConnection()
     cls._connection.create_tables()
     cls._connection.start_connection()
     cls.item = Item.get_from_db_or_crest_by_name(cls._connection.session, cls.eve, cls.ITEM_NAME)
     cls.region = Region.get_from_db_or_crest_by_name(cls._connection.session, cls.eve, cls.REGION_NAME)
     Scraper.update_market_day_data(cls._connection.session, cls.region, cls.item)
Пример #3
0
def once_per_minute():
    _sql_connection = SqlConnection(CONNECTION_STRING)
    _sql_connection.create_tables()
    _sql_connection.start_connection()
    crest_connection = CrestConnection()
    regions = get_regions(_sql_connection.session, crest_connection)
    for region in regions:
        Scraper.update_market_order_data(_sql_connection.session, region)
    print("Minute")
Пример #4
0
def get_stations_from_yaml(file_name, db_location="sqlite:///:memory:"):
    sql_connection = SqlConnection(db_location)
    sql_connection.create_tables()
    sql_connection.start_connection()
    eve = CrestConnection()
    with open(file_name) as file:
        data = yaml.load(file)
    for entry in data:
        if Station.get_from_db_by_id(sql_connection.session, entry['stationID']) is None:
            Station.new_object_from_dict(sql_connection.session, eve, entry, write=True)
Пример #5
0
def once_per_hour():
    _sql_connection = SqlConnection(CONNECTION_STRING)
    _sql_connection.create_tables()
    _sql_connection.start_connection()
    crest_connection = CrestConnection()
    regions = get_regions(_sql_connection.session, crest_connection)
    items = get_items(_sql_connection.session, crest_connection)
    for region in regions:
        for item in items:
            Scraper.update_market_day_data(_sql_connection.session, region, item)
    print("Hour")
Пример #6
0
 def update_market_day_data(sql_session, region, item):
     eve = CrestConnection()
     crest_items = MarketDay.get_objects_from_crest(eve,
                                                    region=region,
                                                    item=item).items
     for crest_item in crest_items:
         if not MarketDay.is_crest_item_in_db(
                 sql_session, crest_item, region=region, item=item):
             MarketDay.create_from_crest_data(sql_session,
                                              crest_item,
                                              region=region,
                                              item=item,
                                              write=True)
Пример #7
0
 def update_market_order_data(sql_session, region):
     eve = CrestConnection()
     crest_items = MarketOrder.get_objects_from_crest(eve, region=region)
     for item in crest_items:
         i = True
         if Item.get_from_db_by_id(sql_session, item.type) is None:
             try:
                 i = Item.get_crest_item_by_attr(eve, 'id', item.type)
                 Item.create_from_crest_data(sql_session, i, write=True)
                 i = True
             except ValueError:
                 i = False
         if i:
             MarketOrder.create_from_crest_data(sql_session,
                                                item,
                                                write=True)
Пример #8
0
 def setUpClass(cls):
     cls.eve = CrestConnection()
Пример #9
0
 def setUpClass(cls):
     cls.eve = CrestConnection()
     super().setUpClass()
Пример #10
0
 def setUpClass(cls):
     cls.eve = CrestConnection()
     cls._connection = SqlConnection()
     cls._connection.create_tables()
Пример #11
0
 def test_crest_connection(self):
     eve = CrestConnection()
     self.assertIsNotNone(eve._data)
Пример #12
0
 def setUpClass(cls):
     cls._connection = CrestConnection()