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