donate-cpu-server.py: Recheck crashes more frequently
This commit is contained in:
parent
6b05f8e867
commit
e8ac45a5a7
|
@ -346,6 +346,41 @@ class HttpClientThread(Thread):
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
self.connection.close()
|
self.connection.close()
|
||||||
|
|
||||||
|
|
||||||
|
def getCrashUrls():
|
||||||
|
ret = []
|
||||||
|
for filename in sorted(glob.glob(os.path.expanduser('~/daca@home/donated-results/*'))):
|
||||||
|
if not os.path.isfile(filename):
|
||||||
|
continue
|
||||||
|
url = None
|
||||||
|
for line in open(filename, 'rt'):
|
||||||
|
if line.startswith('ftp://'):
|
||||||
|
url = line.strip()
|
||||||
|
if not line.startswith('count:'):
|
||||||
|
continue
|
||||||
|
if url and line.find('Crash') > 0:
|
||||||
|
ret.append(url)
|
||||||
|
break
|
||||||
|
return ret
|
||||||
|
|
||||||
|
|
||||||
|
def writeCrashUrls(crashUrls):
|
||||||
|
f = open(os.path.expanduser('crash-urls.txt'), 'wt')
|
||||||
|
for url in crashUrls:
|
||||||
|
f.write(url + '\n')
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
def readCrashUrls():
|
||||||
|
ret = []
|
||||||
|
filename = 'crash-urls.txt'
|
||||||
|
if os.path.isfile(filename):
|
||||||
|
f = open(filename, 'rt')
|
||||||
|
for url in f.read().split():
|
||||||
|
if len(url) > 10:
|
||||||
|
ret.append(url.strip())
|
||||||
|
f.close()
|
||||||
|
return ret
|
||||||
|
|
||||||
def server(server_address_port, packages, packageIndex, resultPath):
|
def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
socket.setdefaulttimeout(30)
|
socket.setdefaulttimeout(30)
|
||||||
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||||
|
@ -355,6 +390,8 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
|
|
||||||
sock.listen(1)
|
sock.listen(1)
|
||||||
|
|
||||||
|
crashUrls = readCrashUrls()
|
||||||
|
|
||||||
latestResults = []
|
latestResults = []
|
||||||
if os.path.isfile('latest.txt'):
|
if os.path.isfile('latest.txt'):
|
||||||
with open('latest.txt', 'rt') as f:
|
with open('latest.txt', 'rt') as f:
|
||||||
|
@ -379,15 +416,26 @@ def server(server_address_port, packages, packageIndex, resultPath):
|
||||||
newThread = HttpClientThread(connection, cmd, resultPath, latestResults)
|
newThread = HttpClientThread(connection, cmd, resultPath, latestResults)
|
||||||
newThread.start()
|
newThread.start()
|
||||||
elif cmd=='get\n':
|
elif cmd=='get\n':
|
||||||
packages[packageIndex] = packages[packageIndex].strip()
|
# Get crash package urls..
|
||||||
print('[' + strDateTime() + '] get:' + packages[packageIndex])
|
if (packageIndex % 500) == 0:
|
||||||
connection.send(packages[packageIndex])
|
crashUrls = getCrashUrls()
|
||||||
packageIndex += 1
|
writeCrashUrls(crashUrls)
|
||||||
if packageIndex >= len(packages):
|
if (packageIndex % 500) == 1 and len(crashUrls) > 0:
|
||||||
packageIndex = 0
|
pkg = crashUrls[0]
|
||||||
f = open('package-index.txt', 'wt')
|
crashUrls = crashUrls[1:]
|
||||||
f.write(str(packageIndex) + '\n')
|
writeCrashUrls(crashUrls)
|
||||||
f.close()
|
print('[' + strDateTime() + '] CRASH: ' + pkg)
|
||||||
|
else:
|
||||||
|
pkg = packages[packageIndex].strip()
|
||||||
|
packages[packageIndex] = pkg
|
||||||
|
packageIndex += 1
|
||||||
|
if packageIndex >= len(packages):
|
||||||
|
packageIndex = 0
|
||||||
|
f = open('package-index.txt', 'wt')
|
||||||
|
f.write(str(packageIndex) + '\n')
|
||||||
|
f.close()
|
||||||
|
print('[' + strDateTime() + '] get:' + pkg)
|
||||||
|
connection.send(pkg)
|
||||||
connection.close()
|
connection.close()
|
||||||
elif cmd.startswith('write\nftp://'):
|
elif cmd.startswith('write\nftp://'):
|
||||||
# read data
|
# read data
|
||||||
|
|
Loading…
Reference in New Issue