donate-cpu-server: tweaks for package http://cppcheck.sf.net/tortoisesvn.tgz

This commit is contained in:
Daniel Marjamäki 2019-11-09 19:29:47 +01:00
parent b93321e038
commit 8c9b717773
1 changed files with 16 additions and 5 deletions

View File

@ -888,9 +888,9 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
print('[' + strDateTime() + '] get:' + pkg) print('[' + strDateTime() + '] get:' + pkg)
connection.send(pkg.encode('utf-8', 'ignore')) connection.send(pkg.encode('utf-8', 'ignore'))
connection.close() connection.close()
elif cmd.startswith('write\nftp://'): elif cmd.startswith('write\nftp://') or cmd.startswith('write\nhttp://'):
# read data # read data
data = cmd[cmd.find('ftp'):] data = cmd[cmd.find('\n')+1:]
try: try:
t = 0.0 t = 0.0
max_data_size = 2 * 1024 * 1024 max_data_size = 2 * 1024 * 1024
@ -920,6 +920,8 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
# save data # save data
res = re.match(r'ftp://.*pool/main/[^/]+/([^/]+)/[^/]*tar.(gz|bz2)', url) res = re.match(r'ftp://.*pool/main/[^/]+/([^/]+)/[^/]*tar.(gz|bz2)', url)
if res is None:
res = re.match(r'http://cppcheck.sf.net/([a-z]+).tgz', url)
if res is None: if res is None:
print('results not written. res is None.') print('results not written. res is None.')
continue continue
@ -955,9 +957,9 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
f.write(' '.join(latestResults)) f.write(' '.join(latestResults))
# generate package.diff.. # generate package.diff..
generate_package_diff_statistics(filename) generate_package_diff_statistics(filename)
elif cmd.startswith('write_info\nftp://'): elif cmd.startswith('write_info\nftp://') or cmd.startswith('write_info\nhttp://'):
# read data # read data
data = cmd[11:] data = cmd[cmd.find('\n') + 1:]
try: try:
t = 0.0 t = 0.0
max_data_size = 1024 * 1024 max_data_size = 1024 * 1024
@ -987,6 +989,8 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
# save data # save data
res = re.match(r'ftp://.*pool/main/[^/]+/([^/]+)/[^/]*tar.(gz|bz2)', url) res = re.match(r'ftp://.*pool/main/[^/]+/([^/]+)/[^/]*tar.(gz|bz2)', url)
if res is None:
res = re.match(r'http://cppcheck.sf.net/([a-z]+).tgz', url)
if res is None: if res is None:
print('info output not written. res is None.') print('info output not written. res is None.')
continue continue
@ -1018,7 +1022,14 @@ def server(server_address_port: int, packages: list, packageIndex: int, resultPa
print('[' + strDateTime() + '] getPackageIdx: index is out of range') print('[' + strDateTime() + '] getPackageIdx: index is out of range')
continue continue
else: else:
print('[' + strDateTime() + '] invalid command: ' + firstLine) if cmd.find('\n') < 0:
print('[' + strDateTime() + '] invalid command: "' + firstLine + '"')
else:
lines = cmd.split('\n')
s = '\\n'.join(lines[:2])
if len(lines) > 2:
s += '...'
print('[' + strDateTime() + '] invalid command: "' + s + '"')
connection.close() connection.close()