From 6a33fe58e15f2b823fafac034d59137f70e46424 Mon Sep 17 00:00:00 2001 From: anand-skss <160696255+anand-skss@users.noreply.github.com> Date: Mon, 4 Mar 2024 15:37:03 +0000 Subject: [PATCH] Code Quality --- src/class_singleWorker.py | 2 +- src/depends.py | 4 ++-- src/network/bmproto.py | 2 +- src/network/invthread.py | 2 +- src/network/networkthread.py | 6 +++--- src/openclpow.py | 2 +- src/plugins/sound_playfile.py | 4 ++-- src/proofofwork.py | 12 ++++++------ src/pyelliptic/openssl.py | 2 +- src/shared.py | 2 +- src/upnp.py | 4 ++-- 11 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/class_singleWorker.py b/src/class_singleWorker.py index ff9c0492..d71dfc3b 100644 --- a/src/class_singleWorker.py +++ b/src/class_singleWorker.py @@ -1372,7 +1372,7 @@ class singleWorker(StoppableThread): if apiNotifyPath: # There is no additional risk of remote exploitation or # privilege escalation - call([apiNotifyPath, "newMessage"]) # nosec:B603 + call([apiNotifyPath, "newMessage"]) # nosec B603 def requestPubKey(self, toAddress): """Send a getpubkey object""" diff --git a/src/depends.py b/src/depends.py index b3521411..d966d5fe 100755 --- a/src/depends.py +++ b/src/depends.py @@ -287,7 +287,7 @@ def check_openssl(): path = ctypes.util.find_library('ssl') if path not in paths: paths.append(path) - except: # nosec:B110 # pylint:disable=bare-except + except: # nosec B110 # pylint:disable=bare-except pass openssl_version = None @@ -361,7 +361,7 @@ def check_curses(): return False try: - subprocess.check_call(['which', 'dialog']) # nosec:B603, B607 + subprocess.check_call(['which', 'dialog']) # nosec B603, B607 except subprocess.CalledProcessError: logger.error( 'Curses requires the `dialog` command to be installed as well as' diff --git a/src/network/bmproto.py b/src/network/bmproto.py index b1b04703..c8f298b7 100644 --- a/src/network/bmproto.py +++ b/src/network/bmproto.py @@ -610,7 +610,7 @@ class BMProto(AdvancedDispatcher, ObjectTracker): 'Closed connection to %s because we are already' ' connected to that IP.', self.destination) return False - except Exception: # nosec:B110 # pylint:disable=broad-exception-caught + except Exception: # nosec B110 # pylint:disable=broad-exception-caught pass if not self.isOutbound: # incoming from a peer we're connected to as outbound, diff --git a/src/network/invthread.py b/src/network/invthread.py index e7d11f86..14217041 100644 --- a/src/network/invthread.py +++ b/src/network/invthread.py @@ -78,7 +78,7 @@ class InvThread(StoppableThread): if connection == Dandelion().objectChildStem(inv[1]): # Fluff trigger by RNG # auto-ignore if config set to 0, i.e. dandelion is off - if random.randint(1, 100) >= state.dandelion: # nosec:B311 + if random.randint(1, 100) >= state.dandelion: # nosec B311 fluffs.append(inv[1]) # send a dinv only if the stem node supports dandelion elif connection.services & protocol.NODE_DANDELION > 0: diff --git a/src/network/networkthread.py b/src/network/networkthread.py index accf50d9..ef4f92ba 100644 --- a/src/network/networkthread.py +++ b/src/network/networkthread.py @@ -25,17 +25,17 @@ class BMNetworkThread(StoppableThread): for i in BMConnectionPool().listeningSockets.values(): try: i.close() - except: # nosec:B110 # pylint:disable=bare-except + except: # nosec B110 # pylint:disable=bare-except pass for i in BMConnectionPool().outboundConnections.values(): try: i.close() - except: # nosec:B110 # pylint:disable=bare-except + except: # nosec B110 # pylint:disable=bare-except pass for i in BMConnectionPool().inboundConnections.values(): try: i.close() - except: # nosec:B110 # pylint:disable=bare-except + except: # nosec B110 # pylint:disable=bare-except pass # just in case diff --git a/src/openclpow.py b/src/openclpow.py index 9834be5e..5391590c 100644 --- a/src/openclpow.py +++ b/src/openclpow.py @@ -47,7 +47,7 @@ def initCL(): device_type=cl.device_type.GPU)) if platform.vendor not in vendors: vendors.append(platform.vendor) - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except pass if enabledGpus: ctx = cl.Context(devices=enabledGpus) diff --git a/src/plugins/sound_playfile.py b/src/plugins/sound_playfile.py index 7962c3d3..c6b70f66 100644 --- a/src/plugins/sound_playfile.py +++ b/src/plugins/sound_playfile.py @@ -11,14 +11,14 @@ try: winsound.PlaySound(sound_file, winsound.SND_FILENAME) except ImportError: import os - import subprocess # nosec:B404 + import subprocess # nosec B404 play_cmd = {} def _subprocess(*args): FNULL = open(os.devnull, 'wb') subprocess.call( - args, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True) # nosec:B603 + args, stdout=FNULL, stderr=subprocess.STDOUT, close_fds=True) # nosec B603 def connect_plugin(sound_file): """This function implements the entry point.""" diff --git a/src/proofofwork.py b/src/proofofwork.py index fccd5951..5b3e3fb6 100644 --- a/src/proofofwork.py +++ b/src/proofofwork.py @@ -10,7 +10,7 @@ import sys import tempfile import time from struct import pack, unpack -from subprocess import call # nosec:B404 +from subprocess import call # nosec B404 import openclpow import paths @@ -82,7 +82,7 @@ def _set_idle(): pid = win32api.GetCurrentProcessId() handle = win32api.OpenProcess(win32con.PROCESS_ALL_ACCESS, True, pid) win32process.SetPriorityClass(handle, win32process.IDLE_PRIORITY_CLASS) - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except # Windows 64-bit pass @@ -135,7 +135,7 @@ def _doFastPoW(target, initialHash): try: pool.terminate() pool.join() - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except pass raise StopIteration("Interrupted") for i in range(pool_size): @@ -298,14 +298,14 @@ def run(target, initialHash): return _doGPUPoW(target, initialHash) except StopIteration: raise - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except pass # fallback if bmpow: try: return _doCPoW(target, initialHash) except StopIteration: raise - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except pass # fallback if paths.frozen == "macosx_app" or not paths.frozen: # on my (Peter Surda) Windows 10, Windows Defender @@ -323,7 +323,7 @@ def run(target, initialHash): return _doSafePoW(target, initialHash) except StopIteration: raise - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except pass # fallback diff --git a/src/pyelliptic/openssl.py b/src/pyelliptic/openssl.py index fda1b13e..deb81644 100644 --- a/src/pyelliptic/openssl.py +++ b/src/pyelliptic/openssl.py @@ -819,7 +819,7 @@ def loadOpenSSL(): try: OpenSSL = _OpenSSL(library) return - except Exception: # nosec:B110 + except Exception: # nosec B110 pass raise Exception( "Couldn't find and load the OpenSSL library. You must install it.") diff --git a/src/shared.py b/src/shared.py index b23dbd67..cb7968f6 100644 --- a/src/shared.py +++ b/src/shared.py @@ -11,7 +11,7 @@ from __future__ import division import hashlib import os import stat -import subprocess # nosec:B404 +import subprocess # nosec B404 import sys from binascii import hexlify diff --git a/src/upnp.py b/src/upnp.py index c4a33392..aa04a556 100644 --- a/src/upnp.py +++ b/src/upnp.py @@ -11,7 +11,7 @@ import time import urllib2 from random import randint from urlparse import urlparse -from xml.dom.minidom import Document # nosec:B408 +from xml.dom.minidom import Document # nosec B408 from defusedxml.minidom import parseString import queues @@ -241,7 +241,7 @@ class uPnPThread(StoppableThread): if time.time() - lastSent > self.sendSleep and not self.routers: try: self.sendSearchRouter() - except: # nosec:B110 # noqa:E722 # pylint:disable=bare-except + except: # nosec B110 # noqa:E722 # pylint:disable=bare-except pass lastSent = time.time() try: -- 2.45.1