def __init__(self, start, goal): """Initialize the sensor.""" import schiene self.start = start self.goal = goal self.schiene = schiene.Schiene() self.connections = [{}]
def __init__(self, start, goal, offset, only_direct): """Initialize the sensor.""" self.start = start self.goal = goal self.offset = offset self.only_direct = only_direct self.schiene = schiene.Schiene() self.connections = [{}]
def get_railway_plan(self, new_date, new_hour, new_minute, from_station, to_station): railway = schiene.Schiene() new_time = datetime.time(new_hour, new_minute) new_date_time = datetime.datetime.combine(new_date, new_time) info_railway_plan=railway.connections(from_station, to_station, dt=new_date_time) return info_railway_plan # return type is list
def all_station(p, s_object=schiene.Schiene()): ''' creates a list object containing all stations gathered from p p: String input on which the schiene instance checks for station names available ''' slist = s_object.stations(p, limit=30) pre_list = [] for sl in slist: if p in sl["value"]: pre_list.append(sl["value"]) pre_list = list(set(pre_list)) return (pre_list)
def getConnection(self, stationStart, stationEnd, timeStart): ret = {} conSchiene = schiene.Schiene() connections = conSchiene.connections(stationStart, stationEnd, dt=timeStart) try: ret["stationStart"] = stationStart ret["stationEnd"] = stationEnd ret["products"] = connections[0]['products'] ret["departure"] = connections[0]['departure'] ret["duration"] = connections[0]['time'] ret["departure"] = connections[0]['departure'] except Exception as e: self.logger.error("Not able to create Connection for %s - %s at %s: %s", stationStart, stationEnd, timeStart, e) return False return ret
def load_train(start, end, s3key, s3skey, s=schiene.Schiene()): ''' loads connection details from a Schiene object start: start of the DB train connection, has to be a string and match a name of Schiene stations end: end of the DB train connection, has to be a string and match a name of Schiene stations s3key: AWS Access Key s3skey: AWS Secret Access Key, s: schiene instance ''' c = s.connections(start, end) for conn in c: conn["date"] = str(datetime.date.today()) conn["_id"] = (str(conn["date"]) + "_" + conn["departure"] + "_" + start + "_" + end) conn["timestamp"] = str( datetime.datetime.now(tz=pytz.timezone("Europe/Berlin"))) if "delay" in conn.keys(): conn["total_delay"] = (conn["delay"]["delay_departure"] + conn["delay"]["delay_arrival"]) else: conn["total_delay"] = 0 conn["start"] = start conn["end"] = end filename = "DB_" + conn["_id"] + ".json" filename = filename.replace(":", "_") filename = filename.replace(" ", "_") s3 = boto3.resource('s3', aws_access_key_id=s3key, aws_secret_access_key=s3skey) s3object = s3.Object("sbmd1db2", filename) s3object.put(Body=(bytes(json.dumps(conn)\ .encode('utf-8'))))
def __init__(self, refresh=30): self.schiene = schiene.Schiene() # initialize crawler self.trips = [] # Contains the trips we are interested in self.display = [] # Contains the strings to display self.refresh = refresh
def __init__(self, start, goal): import schiene self.start = start self.goal = goal self.schiene = schiene.Schiene() self.connections = [{}]
import datetime import time import schiene from django.http import HttpResponse from django.shortcuts import get_object_or_404, redirect, render from django.utils import timezone from . import models # Create your views here. s = schiene.Schiene() def set_today(dt): today = datetime.date.today() return dt.replace(year=today.year, month=today.month, day=today.day, tzinfo=None) def get_fahrten(segment, start, ziel, rueckweg=False): res = s.connections(start, ziel) for v in res: delay = 0 if 'delay' in v: delay = v['delay']['delay_departure'] # Prüfen ob Fahrt schon bekannt v_abfahrt = set_today(
def getRouteData(from_station, to_station): s = schiene.Schiene() route = s.connections(from_station, to_station) return route
def get_station_plan(self): railway = schiene.Schiene() return railway.stations('Ingolstadt Nord')
def _get_connection_data(self): db = schiene.Schiene() connections = db.connections(self.from_station, self.to_station, self.departure_time) return connections
def getRoute(self): s = schiene.Schiene() asd = s.stations('Hamburg') asd2 = s.connections("Stuttgart HbF", "Berlin HbF") return "Available Routes"
import threading import time import pygame import gaugette.rotary_encoder import gaugette.switch import pyttsx import speech_recognition as sr from most.voip.api import VoipLib import random import schiene bahn = schiene.Schiene() stt_engine = sr.Recognizer() voip_caller = None stop_call = False def make_call(number): global voip_caller if voip_caller is None: voip_caller = VoipLib() voip_params = { u'username': u'ziyapi', # a name describing the user u'sip_server_address': u'sip.linphone.org', # the ip of the remote sip server (default port: 5060)