mirror of
https://github.com/krateng/maloja.git
synced 2025-07-09 03:04:07 -04:00
More logging
This commit is contained in:
parent
52cf14de7e
commit
709f3c129c
@ -35,6 +35,7 @@ def loadAPIkeys():
|
|||||||
global clients
|
global clients
|
||||||
createTSV("clients/authenticated_machines.tsv")
|
createTSV("clients/authenticated_machines.tsv")
|
||||||
clients = parseTSV("clients/authenticated_machines.tsv","string","string")
|
clients = parseTSV("clients/authenticated_machines.tsv","string","string")
|
||||||
|
log(str(len(clients)) + " Authenticated Machines " + ", ".join([m[1] for m in clients]))
|
||||||
|
|
||||||
def checkAPIkey(k):
|
def checkAPIkey(k):
|
||||||
return (k in [k for [k,d] in clients])
|
return (k in [k for [k,d] in clients])
|
||||||
@ -621,9 +622,11 @@ def issues():
|
|||||||
|
|
||||||
@dbserver.post("/rebuild")
|
@dbserver.post("/rebuild")
|
||||||
def rebuild():
|
def rebuild():
|
||||||
|
|
||||||
keys = FormsDict.decode(request.forms)
|
keys = FormsDict.decode(request.forms)
|
||||||
apikey = keys.pop("key",None)
|
apikey = keys.pop("key",None)
|
||||||
if (checkAPIkey(apikey)):
|
if (checkAPIkey(apikey)):
|
||||||
|
log("Database rebuild initiated!")
|
||||||
global db_rulestate
|
global db_rulestate
|
||||||
db_rulestate = False
|
db_rulestate = False
|
||||||
sync()
|
sync()
|
||||||
@ -660,6 +663,7 @@ def search():
|
|||||||
|
|
||||||
# Starts the server
|
# Starts the server
|
||||||
def runserver(PORT):
|
def runserver(PORT):
|
||||||
|
log("Starting database server...")
|
||||||
global lastsync
|
global lastsync
|
||||||
lastsync = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
lastsync = int(datetime.datetime.now(tz=datetime.timezone.utc).timestamp())
|
||||||
build_db()
|
build_db()
|
||||||
@ -668,11 +672,12 @@ def runserver(PORT):
|
|||||||
loadAPIkeys()
|
loadAPIkeys()
|
||||||
|
|
||||||
run(dbserver, host='::', port=PORT, server='waitress')
|
run(dbserver, host='::', port=PORT, server='waitress')
|
||||||
|
log("Database server reachable!")
|
||||||
|
|
||||||
def build_db():
|
def build_db():
|
||||||
|
|
||||||
|
|
||||||
|
log("Building database...")
|
||||||
|
|
||||||
global SCROBBLES, ARTISTS, TRACKS
|
global SCROBBLES, ARTISTS, TRACKS
|
||||||
|
|
||||||
@ -706,6 +711,8 @@ def build_db():
|
|||||||
# load cached images
|
# load cached images
|
||||||
loadCache()
|
loadCache()
|
||||||
|
|
||||||
|
log("Database fully built!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
from cleanup import CleanerAgent
|
from cleanup import CleanerAgent
|
||||||
|
from utilities import log
|
||||||
|
import difflib
|
||||||
|
|
||||||
wendigo = CleanerAgent()
|
wendigo = CleanerAgent()
|
||||||
|
|
||||||
@ -20,6 +22,7 @@ for fn in os.listdir("scrobbles/"):
|
|||||||
(al,t) = wendigo.fullclean(a,t)
|
(al,t) = wendigo.fullclean(a,t)
|
||||||
a = "␟".join(al)
|
a = "␟".join(al)
|
||||||
fnew.write(r1 + a + r2 + t + r3 + "\n")
|
fnew.write(r1 + a + r2 + t + r3 + "\n")
|
||||||
|
|
||||||
#print("Artists: " + a)
|
#print("Artists: " + a)
|
||||||
#print("Title: " + t)
|
#print("Title: " + t)
|
||||||
#print("1: " + r1)
|
#print("1: " + r1)
|
||||||
@ -29,7 +32,12 @@ for fn in os.listdir("scrobbles/"):
|
|||||||
f.close()
|
f.close()
|
||||||
fnew.close()
|
fnew.close()
|
||||||
|
|
||||||
os.system("diff " + "scrobbles/" + fn + "_new" + " " + "scrobbles/" + fn)
|
#os.system("diff " + "scrobbles/" + fn + "_new" + " " + "scrobbles/" + fn)
|
||||||
|
with open("scrobbles/" + fn + "_new","r") as newfile:
|
||||||
|
with open("scrobbles/" + fn,"r") as oldfile:
|
||||||
|
diff = difflib.unified_diff(oldfile.read().split("\n"),newfile.read().split("\n"),lineterm="")
|
||||||
|
diff = list(diff)[2:]
|
||||||
|
log("Diff for scrobbles/" + fn + "".join("\n\t" + d for d in diff),module="fixer")
|
||||||
|
|
||||||
os.rename("scrobbles/" + fn + "_new","scrobbles/" + fn)
|
os.rename("scrobbles/" + fn + "_new","scrobbles/" + fn)
|
||||||
|
|
||||||
|
@ -159,11 +159,12 @@ def cleandict(d):
|
|||||||
|
|
||||||
### Logging
|
### Logging
|
||||||
|
|
||||||
def log(msg):
|
def log(msg,module=None):
|
||||||
import inspect
|
|
||||||
now = datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S")
|
now = datetime.datetime.utcnow().strftime("%Y/%m/%d %H:%M:%S")
|
||||||
module = inspect.getmodule(inspect.stack()[1][0]).__name__
|
if module is None:
|
||||||
if module == "__main__": module = "mainserver"
|
import inspect
|
||||||
|
module = inspect.getmodule(inspect.stack()[1][0]).__name__
|
||||||
|
if module == "__main__": module = "mainserver"
|
||||||
print("[" + module + "] " + msg)
|
print("[" + module + "] " + msg)
|
||||||
with open("logs/" + module + ".log","a") as logfile:
|
with open("logs/" + module + ".log","a") as logfile:
|
||||||
logfile.write(now + " " + msg + "\n")
|
logfile.write(now + " " + msg + "\n")
|
||||||
|
@ -5,6 +5,7 @@ body {
|
|||||||
color:beige;
|
color:beige;
|
||||||
font-family:"Ubuntu";
|
font-family:"Ubuntu";
|
||||||
padding:15px;
|
padding:15px;
|
||||||
|
padding-bottom:35px;
|
||||||
/**
|
/**
|
||||||
padding-top:45px;
|
padding-top:45px;
|
||||||
padding-bottom:25px;
|
padding-bottom:25px;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user