def test_logger_factory(self): __logger = logger_factory.create_logger('hahahihi') __logger.info('test')
from prod_config import config as __prod_config class ConfigRecord(ModelBase): __tablename__ = "ConfigTable" key = Column(String, primary_key=True) value = Column(String) def __init__(self, key, value): self.key = key self.value = value database_url = os.environ['MELOENTJOER_REMOTE_DATABASE_URL'] __config_session = PostgresAccessorBase(ConfigRecord, database_url) __logger = logger_factory.create_logger(__name__) def get_integer(key): try: return int(get_string(key)) except Exception, e: __logger.error(e) def get_string(key): try: config_record = __config_session.query(ConfigRecord). \ filter(ConfigRecord.key == key). \ first() """ :type :ConfigRecord"""
import logging import datetime from accessors import geo_data_accessor, bus_state_accessor, bus_estimation_accessor, \ next_bus_accessor from accessors.routes import bus_route_accessor from accessors.entity.NextBus import NextBus from common import general_scheduler from common.logging import logger_factory from config import general_config as __general_config from fetcher.entity.BusTrackData import BusTrackData from accessors.entity.BusState import BusState from fetcher.util import helper as __helper import numpy as np __logger = logger_factory.create_logger('busway_track_fetcher') def __is_in(stop_list, station_list): if len(station_list) < 2 or len(stop_list) < 2: return False if stop_list[0] == station_list[0]: if stop_list[-1] == station_list[-1]: return True else: return __is_in(stop_list, station_list[:-1]) else: return __is_in(stop_list, station_list[1:]) def __locate_bus(bus_coordinates, threshold, coordinates_mapper):
from common import general_scheduler from common.logging import logger_factory from config import general_config from fetcher.util import helper as __helper from accessors.routes import train_route_accessor as __train_route_accessor __logger = logger_factory.create_logger(__name__) def __update(): route_list = __helper.get_train_routes() for train_route in route_list: __train_route_accessor.upset_train_route(train_route) __logger.info('Updated') __update_period = general_config.get_train_info_refresh_period() __scheduler = general_scheduler.schedule(__update_period, __update) def start(): __update() __scheduler.start() __logger.info('Started') def stop(): __logger.info('Stopped') __scheduler.stop()
from accessors.entity.BuswayTransfer import BuswayTransfer from accessors.entity.TrainRoute import TrainRoute from accessors.entity.WalkRoute import WalkRoute from fetcher.entity.BusTrackData import BusTrackData __author__ = 'traveloka' from common.logging import logger_factory import urllib2 import xml.etree.ElementTree as Et from bs4 import BeautifulSoup from common.util.LinkedHash import LinkedHash import re __logger = logger_factory.create_logger('helper') def scrap(link): """ :type link: str :param link: string :return: """ html = urllib2.urlopen(link) scrapper = BeautifulSoup(html, 'html.parser') return scrapper def row_parser(text): innertext = re.findall('[a-zA-Z0-9 ]+[a-zA-Z0-9]', text)
from accessors import bus_estimation_accessor, next_bus_accessor from accessors.routes import bus_route_accessor, train_route_accessor, walk_route_accessor, \ busway_transfer_accessor from accessors.entity.NextBus import NextBus from common.logging import logger_factory from common.util.ConnectedGraph import ConnectedGraph from config import general_config from services.entity.BuswayMode import BuswayMode from services.entity.SearchResult import SearchResult from services.entity.TransportationMode import TransportationMode from copy import deepcopy __logger = logger_factory.create_logger('search_service') def __generate_busway_mode(): """ :rtype list[BuswayMode] :return: """ mode_list = [] bus_route_list = bus_route_accessor.get_all_bus_routes() """:type :list[BusRoute]""" for bus_route in bus_route_list: station_list = bus_route.stations corridor_name = bus_route.corridor_name origin_list = station_list[:-1] destination_list = station_list[1:] for origin, destination in zip(origin_list, destination_list): eta = bus_estimation_accessor.predict_eta(origin, destination) eta = eta if eta else general_config.get_default_eta()
from accessors.routes import bus_route_accessor, train_route_accessor, walk_route_accessor, \ busway_transfer_accessor from common import general_scheduler from common.logging import logger_factory from common.util.TrieNode import TrieNode from config import general_config __logger = logger_factory.create_logger('autocomplete_service') __trie = TrieNode() def __update(): try: bus_route_list = bus_route_accessor.get_all_bus_routes() word_pool = set() for route in bus_route_list: stations = route.stations for station in stations: word_pool.add(station) train_route_list = train_route_accessor.get_all_train_routes() """:type :list[TrainRoute]""" for route in train_route_list: for station in route.stations: word_pool.add(station) walk_route_list = walk_route_accessor.get_all_walk_routes() """:type :list[WalkRoute]""" for route in walk_route_list: word_pool.add(route.walk_from) word_pool.add(route.walk_to) busway_transfer_list = busway_transfer_accessor.get_all_busway_transfers() """:type :list[BuswayTransfer]"""
from accessors.routes import bus_route_accessor, train_route_accessor, walk_route_accessor, \ busway_transfer_accessor from common import general_scheduler from common.logging import logger_factory from common.util.TrieNode import TrieNode from config import general_config __logger = logger_factory.create_logger('autocomplete_service') __trie = TrieNode() def __update(): try: bus_route_list = bus_route_accessor.get_all_bus_routes() word_pool = set() for route in bus_route_list: stations = route.stations for station in stations: word_pool.add(station) train_route_list = train_route_accessor.get_all_train_routes() """:type :list[TrainRoute]""" for route in train_route_list: for station in route.stations: word_pool.add(station) walk_route_list = walk_route_accessor.get_all_walk_routes() """:type :list[WalkRoute]""" for route in walk_route_list: word_pool.add(route.walk_from) word_pool.add(route.walk_to) busway_transfer_list = busway_transfer_accessor.get_all_busway_transfers( )