mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-01-21 03:55:27 +00:00
hush a bunch of not-really-problems caught by the lgtm.com static analyzer
This is all minor stuff: unreachable debug code (that should be commented-out instead of in an 'if False:' block), unnecessary 'pass' and 'global' statements, redundantly-initialized variables. No behavior changes. Nothing here was actually broken, it just looked suspicious to the static analysis at https://lgtm.com/projects/g/tahoe-lafs/tahoe-lafs/alerts/?mode=list .
This commit is contained in:
parent
1dc129b15d
commit
da4e7dcfbe
@ -331,7 +331,7 @@ def alice_invite(reactor, alice, temp_dir, request):
|
||||
# fairly consistently fail if we don't hack in this pause...)
|
||||
import time ; time.sleep(5)
|
||||
proto = _CollectOutputProtocol()
|
||||
transport = reactor.spawnProcess(
|
||||
reactor.spawnProcess(
|
||||
proto,
|
||||
sys.executable,
|
||||
[
|
||||
@ -345,7 +345,7 @@ def alice_invite(reactor, alice, temp_dir, request):
|
||||
pytest.blockon(proto.done)
|
||||
|
||||
proto = _CollectOutputProtocol()
|
||||
transport = reactor.spawnProcess(
|
||||
reactor.spawnProcess(
|
||||
proto,
|
||||
sys.executable,
|
||||
[
|
||||
|
@ -21,7 +21,6 @@ def print_platform():
|
||||
sys.stderr.write("\nGot exception using 'platform'. Exception follows\n")
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
pass
|
||||
|
||||
def print_python_ver():
|
||||
print "python:", foldlines(sys.version)
|
||||
@ -50,7 +49,6 @@ def print_stdout(cmdlist, label=None, numlines=None):
|
||||
sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % (cmdlist[0],))
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
pass
|
||||
|
||||
def print_as_ver():
|
||||
if os.path.exists('a.out'):
|
||||
@ -66,7 +64,6 @@ def print_as_ver():
|
||||
sys.stderr.write("\nGot exception invoking '%s'. Exception follows.\n" % ('as',))
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
pass
|
||||
|
||||
def print_setuptools_ver():
|
||||
try:
|
||||
@ -77,10 +74,8 @@ def print_setuptools_ver():
|
||||
sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of setuptools. Exception follows\n")
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
pass
|
||||
except pkg_resources.DistributionNotFound:
|
||||
print 'setuptools: DistributionNotFound'
|
||||
pass
|
||||
|
||||
def print_py_pkg_ver(pkgname, modulename=None):
|
||||
if modulename is None:
|
||||
@ -94,10 +89,8 @@ def print_py_pkg_ver(pkgname, modulename=None):
|
||||
sys.stderr.write("\nGot exception using 'pkg_resources' to get the version of %s. Exception follows.\n" % (pkgname,))
|
||||
traceback.print_exc(file=sys.stderr)
|
||||
sys.stderr.flush()
|
||||
pass
|
||||
except pkg_resources.DistributionNotFound:
|
||||
print pkgname + ': DistributionNotFound'
|
||||
pass
|
||||
try:
|
||||
__import__(modulename)
|
||||
except ImportError:
|
||||
|
@ -38,12 +38,12 @@ def abbreviate_space(s, SI=True):
|
||||
|
||||
def make_up_a_file_size(seed):
|
||||
h = int(myhash(seed).hexdigest(),16)
|
||||
max=2**31
|
||||
if 1: # exponential distribution
|
||||
e = 8 + (h % (31-8))
|
||||
return 2 ** e
|
||||
# uniform distribution
|
||||
return h % max # avg 1GB
|
||||
#max=2**31
|
||||
#return h % max # avg 1GB
|
||||
|
||||
sizes = [make_up_a_file_size(str(i)) for i in range(10000)]
|
||||
avg_filesize = sum(sizes)/len(sizes)
|
||||
|
@ -268,7 +268,6 @@ class Simulator:
|
||||
avg_tried = sum(self.published_files) / len(self.published_files)
|
||||
print time, etype, self.added_data, self.failed_files, self.lost_data_bytes, avg_tried, len(self.introducer.living_files), self.introducer.utilization
|
||||
|
||||
global s
|
||||
s = None
|
||||
|
||||
def main():
|
||||
|
@ -166,7 +166,7 @@ def text():
|
||||
print " (bytes) (%)"
|
||||
print "------- ------- -------- -------- ---- -- --------"
|
||||
#sizes = [2 ** i for i in range(7, 41)]
|
||||
radix = math.sqrt(10); expstep = 2
|
||||
#radix = math.sqrt(10); expstep = 2
|
||||
radix = 2; expstep = 2
|
||||
#radix = 10; expstep = 1
|
||||
maxexp = int(math.ceil(math.log(1e12, radix)))+2
|
||||
|
@ -44,7 +44,6 @@ _release_cmdline_re = re.compile("(?:Release:)\s*(.*)", re.I)
|
||||
_distributor_id_file_re = re.compile("(?:DISTRIB_ID\s*=)\s*(.*)", re.I)
|
||||
_release_file_re = re.compile("(?:DISTRIB_RELEASE\s*=)\s*(.*)", re.I)
|
||||
|
||||
global _distname,_version
|
||||
_distname = None
|
||||
_version = None
|
||||
|
||||
@ -203,7 +202,7 @@ def get_package_versions_and_locations():
|
||||
pass
|
||||
finally:
|
||||
# Leave suppressions for UserWarnings and global_deprecation_messages active.
|
||||
for ign in runtime_warning_messages + deprecation_messages:
|
||||
for _ in runtime_warning_messages + deprecation_messages:
|
||||
warnings.filters.pop()
|
||||
|
||||
packages = []
|
||||
|
@ -892,11 +892,10 @@ class WriteFileMixin(object):
|
||||
self._log("_rename_conflicted_file(%r, %r)" % (abspath_u, replacement_path_u))
|
||||
|
||||
conflict_path_u = self._get_conflicted_filename(abspath_u)
|
||||
if False:
|
||||
if os.path.isfile(replacement_path_u):
|
||||
print "%r exists" % (replacement_path_u,)
|
||||
if os.path.isfile(conflict_path_u):
|
||||
print "%r exists" % (conflict_path_u,)
|
||||
#if os.path.isfile(replacement_path_u):
|
||||
# print "%r exists" % (replacement_path_u,)
|
||||
#if os.path.isfile(conflict_path_u):
|
||||
# print "%r exists" % (conflict_path_u,)
|
||||
|
||||
fileutil.rename_no_overwrite(replacement_path_u, conflict_path_u)
|
||||
return conflict_path_u
|
||||
|
@ -207,8 +207,6 @@ class DownloadStatus(object):
|
||||
return self.size
|
||||
def get_status(self):
|
||||
# mention all outstanding segment requests
|
||||
outstanding = set()
|
||||
errorful = set()
|
||||
outstanding = set([s_ev["segment_number"]
|
||||
for s_ev in self.segment_events
|
||||
if s_ev["finish_time"] is None])
|
||||
|
@ -329,10 +329,7 @@ def share_placement(peers, readonly_peers, shares, peers_to_shares):
|
||||
if not peers:
|
||||
return dict()
|
||||
|
||||
homeless_shares = set()
|
||||
|
||||
# First calculate share placement for the readonly servers.
|
||||
readonly_peers = readonly_peers
|
||||
readonly_shares = set()
|
||||
readonly_map = {}
|
||||
for peer in sorted(peers_to_shares.keys()):
|
||||
|
@ -76,7 +76,6 @@ class CHKCheckerAndUEBFetcher:
|
||||
if f.check(DeadReferenceError):
|
||||
return
|
||||
log.err(f, parent=self._logparent)
|
||||
pass
|
||||
|
||||
def _get_uri_extension(self, res):
|
||||
# assume that we can pull the UEB from any share. If we get an error,
|
||||
|
@ -1077,7 +1077,6 @@ class Publish:
|
||||
# of highest-replaceable-seqnum or lower, we're allowed
|
||||
# to replace it: send out a new writev (or rather add it
|
||||
# to self.goal and loop).
|
||||
pass
|
||||
|
||||
surprised = True
|
||||
|
||||
|
@ -413,6 +413,7 @@ class Node(service.MultiService):
|
||||
if cfg_location is None:
|
||||
cfg_location = "AUTO"
|
||||
|
||||
local_portnum = None # needed to hush lgtm.com static analyzer
|
||||
# Replace the location "AUTO", if present, with the detected local
|
||||
# addresses. Don't probe for local addresses unless necessary.
|
||||
split_location = cfg_location.split(",")
|
||||
|
@ -521,9 +521,9 @@ def status(options):
|
||||
downloads = [item for item in magic_data if item['kind'] == 'download']
|
||||
longest = max([len(item['path']) for item in magic_data])
|
||||
|
||||
if True: # maybe --show-completed option or something?
|
||||
uploads = [item for item in uploads if item['status'] != 'success']
|
||||
downloads = [item for item in downloads if item['status'] != 'success']
|
||||
# maybe gate this with --show-completed option or something?
|
||||
uploads = [item for item in uploads if item['status'] != 'success']
|
||||
downloads = [item for item in downloads if item['status'] != 'success']
|
||||
|
||||
if len(uploads):
|
||||
print
|
||||
|
@ -137,7 +137,6 @@ def do_status(options):
|
||||
)
|
||||
print(u"\u255f\u2500{}\u2500\u256b\u2500{}\u2500\u256b\u2500{}\u2500\u256b\u2500{}".format(u'\u2500' * 5, u'\u2500' * 26, u'\u2500' * 22, u'\u2500' * 20), file=options.stdout)
|
||||
for op in status_data['active']:
|
||||
op_type = 'UKN '
|
||||
if 'progress-hash' in op:
|
||||
op_type = ' put '
|
||||
total = (op['progress-hash'] + op['progress-ciphertext'] + op['progress-encode-push']) / 3.0
|
||||
|
@ -79,5 +79,4 @@ def stop(config):
|
||||
(pid, (time.time() - start))
|
||||
wait = 10
|
||||
time.sleep(1)
|
||||
# we define rc=1 to mean "I think something is still running, sorry"
|
||||
return 1
|
||||
# control never reaches here: no timeout
|
||||
|
@ -747,7 +747,6 @@ def from_string(u, deep_immutable=False, name=u"<unknown name>"):
|
||||
s = s[len(ALLEGED_READONLY_PREFIX):]
|
||||
|
||||
error = None
|
||||
kind = "cap"
|
||||
try:
|
||||
if s.startswith('URI:CHK:'):
|
||||
return CHKFileURI.init_from_string(s)
|
||||
|
@ -31,6 +31,7 @@ def from_foolscap_reconnector(rc, last_received):
|
||||
connected = False
|
||||
last_connected = None
|
||||
others = set(ci.connectorStatuses.keys())
|
||||
summary = None
|
||||
|
||||
if state == "connected":
|
||||
connected = True
|
||||
|
@ -21,7 +21,6 @@ def add_version_to_remote_reference(rref, default):
|
||||
|
||||
def trap_and_discard(f, *errorTypes):
|
||||
f.trap(*errorTypes)
|
||||
pass
|
||||
|
||||
def trap_deadref(f):
|
||||
return trap_and_discard(f, DeadReferenceError)
|
||||
|
@ -250,16 +250,16 @@ class CheckResultsRenderer(CheckerBase, rend.Page, ResultsBase):
|
||||
def render_repair(self, ctx, data):
|
||||
if data.is_healthy():
|
||||
return ""
|
||||
repair = T.form(action=".", method="post",
|
||||
enctype="multipart/form-data")[
|
||||
T.fieldset[
|
||||
T.input(type="hidden", name="t", value="check"),
|
||||
T.input(type="hidden", name="repair", value="true"),
|
||||
T.input(type="submit", value="Repair"),
|
||||
]]
|
||||
#repair = T.form(action=".", method="post",
|
||||
# enctype="multipart/form-data")[
|
||||
# T.fieldset[
|
||||
# T.input(type="hidden", name="t", value="check"),
|
||||
# T.input(type="hidden", name="repair", value="true"),
|
||||
# T.input(type="submit", value="Repair"),
|
||||
# ]]
|
||||
#return ctx.tag[repair]
|
||||
return "" # repair button disabled until we make it work correctly,
|
||||
# see #622 for details
|
||||
return ctx.tag[repair]
|
||||
|
||||
def render_results(self, ctx, data):
|
||||
cr = self._render_results(ctx, data)
|
||||
|
Loading…
Reference in New Issue
Block a user