Example #1
0
        raise (e)
    try:
        cur.execute("""
            INSERT INTO public."SimRaAPI_ride" (geom, timestamps, legs, filename, "start", "end") VALUES (%s, %s, %s, %s, %s, %s) RETURNING id;
        """, [ls, timestamps, [i[0] for i in legs], filename, start, end])
        ride_id = cur.fetchone()[0]
        incidents.update_ride_ids([i[2] for i in incident_locs], ride_id, cur)

    except:
        print(f"Problem parsing {filename}")
        raise Exception("Can not parse ride!")


if __name__ == '__main__':
    filepath = "../csvdata/Berlin/Rides/VM2_-351907452"
    with DatabaseConnection() as cur:
        handle_ride_file(filepath, cur)


def is_teleportation(timestamps):
    for i, t in enumerate(timestamps):
        if i + 1 < len(timestamps):
            if (timestamps[i + 1] - timestamps[i]).seconds > 20:
                return True
    return False


class Ride:
    def __init__(self, raw_coords, accuracies, timestamps):
        self.raw_coords = raw_coords
        self.raw_coords_filtered = None
Example #2
0
import tqdm

import profile, rides

if __name__ == '__main__':
    files = []
    for r, d, f in os.walk(IMPORT_DIRECTORY, followlinks=True):
        for file in f:
            if '.' not in file:
                files.append(os.path.join(r, file))
    for file in tqdm.tqdm(files):
        if "Profiles" in file:
            continue
        filename = file.split("/")[-1]
        region = file.split("/")[-3]
        with DatabaseConnection() as cur:
            cur.execute(
                """
                SELECT * FROM public."SimRaAPI_parsedfiles" WHERE "fileName" LIKE %s
            """, (f'%{filename}%', ))
            if cur.fetchone() is not None:
                continue
        try:
            with DatabaseConnection(
            ) as cur:  # new database connection for the whole transaction
                if "Profiles" in file:
                    profile.handle_profile(file, cur)
                    continue
                else:
                    print(file)
                    rides.handle_ride_file(file, cur)
Example #3
0
import argparse
import re
import time

from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.common.exceptions import StaleElementReferenceException
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait

from db_connection import DatabaseConnection
from model import Match, TableEntry, Season, TeamStats, League

main_url = 'https://www.flashscore.com'
db = DatabaseConnection('test.db')

countries_leagues = {'England': 'Premier League', 'Spain': 'LaLiga', 'Italy': 'Serie A', 'Germany': 'Bundesliga',
                     'France': 'Ligue 1', 'Portugal': 'Primeira Liga', 'Russia': 'Premier League',
                     'Netherlands': 'Eredivisie', 'Turkey': 'Super Lig'}


def execute_script_click(button):
    browser.execute_script('arguments[0].click();', button)


def click_league(country, league_name):
    left_panel = browser.find_element_by_id('lc')
    countries_menus = left_panel.find_elements_by_class_name('mbox0px')
    countries_lists = [menu.find_element_by_class_name('menu') for menu in countries_menus]
    countries_lists = [countries_list for countries_list in countries_lists]