mirror of
https://github.com/krateng/maloja.git
synced 2023-08-10 21:12:55 +03:00
Fixing DB now creates individual patch files
This commit is contained in:
parent
0ceb70b27e
commit
b17060184b
@ -5,7 +5,7 @@ author = {
|
||||
"email":"maloja@krateng.dev",
|
||||
"github": "krateng"
|
||||
}
|
||||
version = 2,3,6
|
||||
version = 2,3,7
|
||||
versionstr = ".".join(str(n) for n in version)
|
||||
links = {
|
||||
"pypi":"malojaserver",
|
||||
|
@ -22,10 +22,11 @@ def fix():
|
||||
datestr = now.strftime("%Y/%m/%d")
|
||||
timestr = now.strftime("%H:%M:%S")
|
||||
|
||||
with open(datadir("logs","dbfix",nowstr + ".log"),"a") as logfile:
|
||||
patchfolder = datadir("logs","dbfix",nowstr)
|
||||
os.makedirs(patchfolder)
|
||||
|
||||
#with open(datadir("logs","dbfix",nowstr + ".log"),"a") as logfile:
|
||||
|
||||
logfile.write("Database fix initiated on " + datestr + " " + timestr + " UTC")
|
||||
logfile.write("\n\n")
|
||||
|
||||
for filename in os.listdir(datadir("scrobbles")):
|
||||
if filename.endswith(".tsv"):
|
||||
@ -47,16 +48,13 @@ def fix():
|
||||
|
||||
|
||||
#os.system("diff " + "scrobbles/" + fn + "_new" + " " + "scrobbles/" + fn)
|
||||
with open(datadir("scrobbles",filename_new),"r") as newfile:
|
||||
with open(datadir("scrobbles",filename),"r") as oldfile:
|
||||
with open(datadir("scrobbles",filename_new),"r") as newfile, open(datadir("scrobbles",filename),"r") as oldfile:
|
||||
|
||||
diff = difflib.unified_diff(oldfile.read().split("\n"),newfile.read().split("\n"),lineterm="")
|
||||
diff = list(diff)[2:]
|
||||
#log("Diff for scrobbles/" + filename + "".join("\n\t" + d for d in diff),module="fixer")
|
||||
output = "Diff for scrobbles/" + filename + "".join("\n\t" + d for d in diff)
|
||||
print(output)
|
||||
logfile.write(output)
|
||||
logfile.write("\n")
|
||||
diff = list(diff)
|
||||
|
||||
with open(os.path.join(patchfolder,filename + ".diff"),"w") as patchfile:
|
||||
patchfile.write("\n".join(diff))
|
||||
|
||||
os.rename(datadir("scrobbles",filename_new),datadir("scrobbles",filename))
|
||||
|
||||
|
@ -11,9 +11,9 @@ c = CleanerAgent()
|
||||
|
||||
def convert(input,output):
|
||||
|
||||
log = open(input,"r")
|
||||
outputlog = open(output,"w")
|
||||
checksumfile = open(output + ".rulestate","w") #this file stores an identifier for all rules that were in place when the corresponding file was created
|
||||
with open(input,"r",encoding="utf-8") as log:
|
||||
with open(output,"w") as outputlog:
|
||||
|
||||
|
||||
stamps = [99999999999999]
|
||||
|
||||
@ -62,8 +62,6 @@ def convert(input,output):
|
||||
outputlog.write(entry)
|
||||
outputlog.write("\n")
|
||||
|
||||
with open(output + ".rulestate","w") as checksumfile:
|
||||
#this file stores an identifier for all rules that were in place when the corresponding file was created
|
||||
checksumfile.write(c.checksums)
|
||||
|
||||
log.close()
|
||||
outputlog.close()
|
||||
checksumfile.close()
|
||||
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user