forked from premiere/premiere-libtorrent
more lgtm fixes
This commit is contained in:
parent
9463159e67
commit
c57b3be4cc
|
@ -571,7 +571,7 @@ def parse_enum(lno, lines, filename):
|
||||||
if '=' in v:
|
if '=' in v:
|
||||||
val = int(v.split('=')[1].strip(), 0)
|
val = int(v.split('=')[1].strip(), 0)
|
||||||
valstr = str(val)
|
valstr = str(val)
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
if '=' in v:
|
if '=' in v:
|
||||||
|
|
|
@ -70,7 +70,7 @@ test_duration = 200 # 700
|
||||||
try:
|
try:
|
||||||
if os.name == 'posix':
|
if os.name == 'posix':
|
||||||
resource.setrlimit(resource.RLIMIT_NOFILE, (4000, 5000))
|
resource.setrlimit(resource.RLIMIT_NOFILE, (4000, 5000))
|
||||||
except BaseException:
|
except Exception:
|
||||||
if resource.getrlimit(resource.RLIMIT_NOFILE)[0] < 4000:
|
if resource.getrlimit(resource.RLIMIT_NOFILE)[0] < 4000:
|
||||||
print('please set ulimit -n to at least 4000')
|
print('please set ulimit -n to at least 4000')
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
@ -131,7 +131,7 @@ def build_commandline(config, port):
|
||||||
if config['build'] == 'utorrent':
|
if config['build'] == 'utorrent':
|
||||||
try:
|
try:
|
||||||
os.mkdir('utorrent_session')
|
os.mkdir('utorrent_session')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
cfg = open('utorrent_session/settings.dat', 'w+')
|
cfg = open('utorrent_session/settings.dat', 'w+')
|
||||||
|
|
||||||
|
@ -158,11 +158,11 @@ def build_commandline(config, port):
|
||||||
cfg.close()
|
cfg.close()
|
||||||
try:
|
try:
|
||||||
os.mkdir('utorrent_session/autoload')
|
os.mkdir('utorrent_session/autoload')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
shutil.copy(torrent_path, 'utorrent_session/autoload/')
|
shutil.copy(torrent_path, 'utorrent_session/autoload/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return './utorrent-server-v3_0/utserver -logfile session_stats/alerts_log.txt -settingspath utorrent_session'
|
return './utorrent-server-v3_0/utserver -logfile session_stats/alerts_log.txt -settingspath utorrent_session'
|
||||||
|
|
||||||
|
@ -172,12 +172,12 @@ def build_commandline(config, port):
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
os.mkdir('rtorrent_session')
|
os.mkdir('rtorrent_session')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
# it seems rtorrent may delete the original torrent when it's being added
|
# it seems rtorrent may delete the original torrent when it's being added
|
||||||
try:
|
try:
|
||||||
shutil.copy(torrent_path, 'rtorrent_session/')
|
shutil.copy(torrent_path, 'rtorrent_session/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
add_command = '-O load_start_verbose=rtorrent_session/%s ' % torrent_path
|
add_command = '-O load_start_verbose=rtorrent_session/%s ' % torrent_path
|
||||||
|
|
||||||
|
@ -198,14 +198,14 @@ def delete_files(files):
|
||||||
for i in files:
|
for i in files:
|
||||||
try:
|
try:
|
||||||
os.remove(i)
|
os.remove(i)
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
shutil.rmtree(i)
|
shutil.rmtree(i)
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
if os.path.exists(i):
|
if os.path.exists(i):
|
||||||
print('failed to delete %s' % i)
|
print('failed to delete %s' % i)
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# typically the schedulers available are 'noop', 'deadline' and 'cfq'
|
# typically the schedulers available are 'noop', 'deadline' and 'cfq'
|
||||||
|
@ -284,7 +284,7 @@ def find_library(name):
|
||||||
try:
|
try:
|
||||||
if os.path.exists(p + name):
|
if os.path.exists(p + name):
|
||||||
return p + name
|
return p + name
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return name
|
return name
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ def find_binary(names):
|
||||||
try:
|
try:
|
||||||
if os.path.exists(p + n):
|
if os.path.exists(p + n):
|
||||||
return p + n
|
return p + n
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
return names[0]
|
return names[0]
|
||||||
|
|
||||||
|
@ -331,7 +331,7 @@ def run_test(config):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir('session_stats')
|
os.mkdir('session_stats')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# save off the command line for reference
|
# save off the command line for reference
|
||||||
|
@ -402,7 +402,7 @@ def run_test(config):
|
||||||
try:
|
try:
|
||||||
print('killing client')
|
print('killing client')
|
||||||
client.send_signal(signal.SIGINT)
|
client.send_signal(signal.SIGINT)
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
@ -420,16 +420,16 @@ def run_test(config):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.copy('asserts.log', 'session_stats/')
|
shutil.copy('asserts.log', 'session_stats/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
try:
|
try:
|
||||||
shutil.move('libtorrent_logs0', 'session_stats/')
|
shutil.move('libtorrent_logs0', 'session_stats/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
try:
|
try:
|
||||||
shutil.move('libtorrent_logs%s' % port, 'session_stats/')
|
shutil.move('libtorrent_logs%s' % port, 'session_stats/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
# run fragmentation test
|
# run fragmentation test
|
||||||
|
@ -437,13 +437,13 @@ def run_test(config):
|
||||||
os.system('./stage_aio/fragmentation_test test.torrent %s' % (config['save-path']))
|
os.system('./stage_aio/fragmentation_test test.torrent %s' % (config['save-path']))
|
||||||
try:
|
try:
|
||||||
shutil.copy('fragmentation.log', 'session_stats/')
|
shutil.copy('fragmentation.log', 'session_stats/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
shutil.copy('fragmentation.gnuplot', 'session_stats/')
|
shutil.copy('fragmentation.gnuplot', 'session_stats/')
|
||||||
try:
|
try:
|
||||||
shutil.copy('file_access.log', 'session_stats/')
|
shutil.copy('file_access.log', 'session_stats/')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
os.system('filefrag %s >session_stats/filefrag.out' % config['save-path'])
|
os.system('filefrag %s >session_stats/filefrag.out' % config['save-path'])
|
||||||
|
@ -468,7 +468,7 @@ def run_test(config):
|
||||||
profile = 'session_stats/heap_profile.prof.%04d.heap' % i
|
profile = 'session_stats/heap_profile.prof.%04d.heap' % i
|
||||||
try:
|
try:
|
||||||
os.stat(profile)
|
os.stat(profile)
|
||||||
except BaseException:
|
except Exception:
|
||||||
break
|
break
|
||||||
print('analyzing heap profile [%s] %d' % (binary, i))
|
print('analyzing heap profile [%s] %d' % (binary, i))
|
||||||
os.system('%s --pdf %s %s >session_stats/heap_profile_%d.pdf' %
|
os.system('%s --pdf %s %s >session_stats/heap_profile_%d.pdf' %
|
||||||
|
|
|
@ -91,7 +91,7 @@ import errno
|
||||||
# Python 3 renamed thread module to _thread
|
# Python 3 renamed thread module to _thread
|
||||||
try:
|
try:
|
||||||
import _thread as thread
|
import _thread as thread
|
||||||
except BaseException:
|
except Exception:
|
||||||
import thread
|
import thread
|
||||||
|
|
||||||
__version__ = '0.1.0 Draft 1'
|
__version__ = '0.1.0 Draft 1'
|
||||||
|
@ -125,7 +125,7 @@ class ConnectionHandler:
|
||||||
elif self.method in ('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT',
|
elif self.method in ('OPTIONS', 'GET', 'HEAD', 'POST', 'PUT',
|
||||||
'DELETE', 'TRACE'):
|
'DELETE', 'TRACE'):
|
||||||
self.method_others()
|
self.method_others()
|
||||||
except BaseException:
|
except Exception:
|
||||||
try:
|
try:
|
||||||
self.client.send(HTTPVER + ' 502 Connection failed\n' +
|
self.client.send(HTTPVER + ' 502 Connection failed\n' +
|
||||||
'Proxy-agent: %s\n\n' % VERSION)
|
'Proxy-agent: %s\n\n' % VERSION)
|
||||||
|
|
|
@ -11,7 +11,7 @@ import sys
|
||||||
# Python 3 renamed SocketServer to socketserver
|
# Python 3 renamed SocketServer to socketserver
|
||||||
try:
|
try:
|
||||||
from socketserver import StreamRequestHandler, ThreadingTCPServer
|
from socketserver import StreamRequestHandler, ThreadingTCPServer
|
||||||
except BaseException:
|
except Exception:
|
||||||
from SocketServer import StreamRequestHandler, ThreadingTCPServer
|
from SocketServer import StreamRequestHandler, ThreadingTCPServer
|
||||||
|
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ def send(dest, msg):
|
||||||
if msg == CLOSE:
|
if msg == CLOSE:
|
||||||
try:
|
try:
|
||||||
dest.shutdown(socket.SHUT_WR)
|
dest.shutdown(socket.SHUT_WR)
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
dest.close()
|
dest.close()
|
||||||
return 0
|
return 0
|
||||||
|
|
|
@ -25,7 +25,7 @@ try:
|
||||||
f.writelines(fin)
|
f.writelines(fin)
|
||||||
f.close()
|
f.close()
|
||||||
fin.close()
|
fin.close()
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ for line in f:
|
||||||
if (time < 0 or time > max_rtt - quantize):
|
if (time < 0 or time > max_rtt - quantize):
|
||||||
continue
|
continue
|
||||||
num_messages += 1
|
num_messages += 1
|
||||||
time /= quantize
|
time //= quantize
|
||||||
time *= quantize
|
time *= quantize
|
||||||
distribution[time] += 1
|
distribution[time] += 1
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ def plot_nodes(nodes, frame):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
os.mkdir('dht_frames')
|
os.mkdir('dht_frames')
|
||||||
except BaseException:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
out = open('dht_frames/plot-%02d.dot' % frame, 'w+')
|
out = open('dht_frames/plot-%02d.dot' % frame, 'w+')
|
||||||
|
|
|
@ -91,7 +91,7 @@ metrics = {
|
||||||
'recv_buffer': ['receive buffer size (B)', 'x1y1', 'lines']
|
'recv_buffer': ['receive buffer size (B)', 'x1y1', 'lines']
|
||||||
}
|
}
|
||||||
|
|
||||||
histogram_quantization = 1
|
histogram_quantization = 1.0
|
||||||
socket_index = None
|
socket_index = None
|
||||||
|
|
||||||
columns = []
|
columns = []
|
||||||
|
@ -202,7 +202,7 @@ out.close()
|
||||||
|
|
||||||
out = open('%s.histogram' % out_file, 'wb')
|
out = open('%s.histogram' % out_file, 'wb')
|
||||||
for d, f in delay_histogram.items():
|
for d, f in delay_histogram.items():
|
||||||
print(float(d * histogram_quantization) + histogram_quantization / 2, f, file=out)
|
print(float(d * histogram_quantization) + histogram_quantization / 2.0, f, file=out)
|
||||||
out.close()
|
out.close()
|
||||||
|
|
||||||
out = open('%s_packet_size.histogram' % out_file, 'wb')
|
out = open('%s_packet_size.histogram' % out_file, 'wb')
|
||||||
|
|
Loading…
Reference in New Issue