donate-cpu-server: save crash history
This commit is contained in:
parent
13c6489571
commit
af60b6f125
|
@ -364,20 +364,19 @@ def getCrashUrls():
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
|
||||||
def writeCrashUrls(crashUrls):
|
def writeStringList(filename, stringList):
|
||||||
f = open(os.path.expanduser('crash-urls.txt'), 'wt')
|
f = open(os.path.expanduser(filename), 'wt')
|
||||||
for url in crashUrls:
|
for s in stringList:
|
||||||
f.write(url + '\n')
|
f.write(s + '\n')
|
||||||
f.close()
|
f.close()
|
||||||
|
|
||||||
def readCrashUrls():
|
def readStringList(filename):
|
||||||
ret = []
|
ret = []
|
||||||
filename = 'crash-urls.txt'
|
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
f = open(filename, 'rt')
|
f = open(filename, 'rt')
|
||||||
for url in f.read().split():
|
for line in f.read().split():
|
||||||
if len(url) > 10:
|
if len(line) > 10:
|
||||||
ret.append(url.strip())
|
ret.append(line.strip())
|
||||||
f.close()
|
f.close()
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
@ -390,7 +389,10 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
|
|
||||||
sock.listen(1)
|
sock.listen(1)
|
||||||
|
|
||||||
crashUrls = readCrashUrls()
|
FILENAME_CRASH_URLS = 'crash-urls.txt'
|
||||||
|
FILENAME_CRASH_HISTORY = 'crash-history.txt'
|
||||||
|
crashUrls = readStringList(FILENAME_CRASH_URLS)
|
||||||
|
crashHistory = readStringList(FILENAME_CRASH_HISTORY)
|
||||||
|
|
||||||
latestResults = []
|
latestResults = []
|
||||||
if os.path.isfile('latest.txt'):
|
if os.path.isfile('latest.txt'):
|
||||||
|
@ -419,11 +421,11 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
# Get crash package urls..
|
# Get crash package urls..
|
||||||
if (packageIndex % 500) == 0:
|
if (packageIndex % 500) == 0:
|
||||||
crashUrls = getCrashUrls()
|
crashUrls = getCrashUrls()
|
||||||
writeCrashUrls(crashUrls)
|
writeStringList(FILENAME_CRASH_URLS, crashUrls)
|
||||||
if (packageIndex % 500) == 1 and len(crashUrls) > 0:
|
if (packageIndex % 500) == 1 and len(crashUrls) > 0:
|
||||||
pkg = crashUrls[0]
|
pkg = crashUrls[0]
|
||||||
crashUrls = crashUrls[1:]
|
crashUrls = crashUrls[1:]
|
||||||
writeCrashUrls(crashUrls)
|
writeStringList(FILENAME_CRASH_URLS, crashUrls)
|
||||||
print('[' + strDateTime() + '] CRASH: ' + pkg)
|
print('[' + strDateTime() + '] CRASH: ' + pkg)
|
||||||
else:
|
else:
|
||||||
pkg = packages[packageIndex].strip()
|
pkg = packages[packageIndex].strip()
|
||||||
|
@ -480,6 +482,12 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
latestResults.append(filename)
|
latestResults.append(filename)
|
||||||
with open('latest.txt', 'wt') as f:
|
with open('latest.txt', 'wt') as f:
|
||||||
f.write(' '.join(latestResults))
|
f.write(' '.join(latestResults))
|
||||||
|
pos = data.find('\ncount:')
|
||||||
|
if pos > 0:
|
||||||
|
count = data[pos+1:data.find('\n', pos+1)]
|
||||||
|
if count.find('CRASH') > 0:
|
||||||
|
crashHistory.append(strDateTime() + ' ' + res.group(1) + ' ' + count)
|
||||||
|
writeStringList(FILENAME_CRASH_HISTORY, crashHistory)
|
||||||
else:
|
else:
|
||||||
print('[' + strDateTime() + '] invalid command: ' + firstLine)
|
print('[' + strDateTime() + '] invalid command: ' + firstLine)
|
||||||
connection.close()
|
connection.close()
|
||||||
|
|
Loading…
Reference in New Issue