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)
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)
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")
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)
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")
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)
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)
def setUpClass(cls): cls.eve = CrestConnection()
def setUpClass(cls): cls.eve = CrestConnection() super().setUpClass()
def setUpClass(cls): cls.eve = CrestConnection() cls._connection = SqlConnection() cls._connection.create_tables()
def test_crest_connection(self): eve = CrestConnection() self.assertIsNotNone(eve._data)
def setUpClass(cls): cls._connection = CrestConnection()