From 7def8b8b75a27f826359f8ed371e3d14d4b55ea2 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Sun, 14 Sep 2025 10:48:16 +0200 Subject: [PATCH] A little cleanup --- dump.sh | 17 ++++++++++------- dvr-managedb | 23 ++++++++++++----------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/dump.sh b/dump.sh index 2bf9710..4532e47 100755 --- a/dump.sh +++ b/dump.sh @@ -1,9 +1,9 @@ -#!/bin/sh +#!/bin/bash -FROM=54696 +FROM=1 #FROM=190000 -UNTIL=55060 +UNTIL=1000000 #UNTIL=200000 cat < "${FN}" # Do not stress server too much diff --git a/dvr-managedb b/dvr-managedb index aaf68e2..fbe9766 100755 --- a/dvr-managedb +++ b/dvr-managedb @@ -76,9 +76,9 @@ class GeolocationProviders(object): """Manages a list of geolocation providers.""" providers = [ - GoogleGeolocation(), - BingGeolocation() - ] + GoogleGeolocation(), + BingGeolocation() + ] @staticmethod def isNameValid(name): @@ -93,15 +93,16 @@ class GeolocationProviders(object): @staticmethod def getByIndex(idx): """Get provider by index""" - assert(GeolocationProviders.isIndexValid(idx)) + assert (GeolocationProviders.isIndexValid(idx)) return GeolocationProviders.providers[idx] @staticmethod def getIndexByName(name): """Get provider by its name""" - assert(GeolocationProviders.isNameValid(name)) + assert (GeolocationProviders.isNameValid(name)) return [p.name().lower() for p in GeolocationProviders.providers].index(name.lower()) + class Database: """Encapsualtes a DVR database.""" @@ -239,10 +240,10 @@ class Database: def get_geolocation(self, dvrid, provider): """Return geolocation of given DVR-ID and provider.""" - assert(GeolocationProviders.isIndexValid(provider)) + assert (GeolocationProviders.isIndexValid(provider)) c = self.conn.cursor() - c.execute("SELECT * FROM geolocations WHERE dvrid=? AND provider=?", \ + c.execute("SELECT * FROM geolocations WHERE dvrid=? AND provider=?", (dvrid, provider)) res = c.fetchone() if res is None: @@ -251,10 +252,10 @@ class Database: def add_geolocation(self, dvrid, provider, lat, lon): """Add a geolocatoin for a given DVR-ID.""" - assert(GeolocationProviders.isIndexValid(provider)) + assert (GeolocationProviders.isIndexValid(provider)) c = self.conn.cursor() - c.execute("INSERT INTO geolocations VALUES (?, ?, ?, ?)", \ + c.execute("INSERT INTO geolocations VALUES (?, ?, ?, ?)", (dvrid, provider, lat, lon)) c.close() self.conn.commit() @@ -436,7 +437,7 @@ def processAdd(db, source): for (dirpath, dirnames, filenames) in os.walk(source): for f in filenames: if f.endswith(".html") or f.endswith(".html.gz"): - p = os.path.join(dirpath,f) + p = os.path.join(dirpath, f) processAdd(db, p) else: print("What the hell is '%s'?" % source, file=sys.stderr) @@ -561,7 +562,7 @@ if __name__ == "__main__": maptemplatefn = arg else: print("Unknown option '", opt, "'.", file=sys.stderr) - assert(False) + assert (False) except getopt.GetoptError as e: print("Error parsing arguments:", e, file=sys.stderr) -- 2.39.5