mirror of
https://github.com/xcat2/confluent.git
synced 2026-09-21 16:39:32 +00:00
Tidy comparisons, statement layout and a redundant alias (E711, E712, E701, PLC0414)
Hand written rather than autofixed, since three of the four need the surrounding code read to be sure they are equivalent: - confetty: `powerstate == None` -> `is None`. - nodeconfig: `setmode != True` / `!= False` -> `not setmode` / `setmode`. Safe because setmode only ever holds None, True or False, and the two lines above each test normalise None away first. - pam: split two `if cond: stmt` one-liners. - imgutil: `from shutil import copytree as copytree`, an alias that renames nothing. Not a re-export marker, this is a script.
This commit is contained in:
@@ -1042,7 +1042,7 @@ def main():
|
||||
except IOError:
|
||||
pass
|
||||
if powerstate is None or powertime < time.time() - 10: # Check powerstate every 10 seconds
|
||||
if powerstate == None:
|
||||
if powerstate is None:
|
||||
powerstate = True
|
||||
powertime = time.time()
|
||||
check_power_state()
|
||||
|
||||
@@ -170,7 +170,7 @@ def parse_config_line(arguments, single=False):
|
||||
if '=' in param or param[-1] == ':' or forceset:
|
||||
if setmode is None:
|
||||
setmode = True
|
||||
if setmode != True:
|
||||
if not setmode:
|
||||
bailout('Cannot do set and query in same command: Query detected but "{0}" appears to be set'.format(param))
|
||||
if '=' in param:
|
||||
key, _, value = param.partition('=')
|
||||
@@ -182,7 +182,7 @@ def parse_config_line(arguments, single=False):
|
||||
else:
|
||||
if setmode is None:
|
||||
setmode = False
|
||||
if setmode != False:
|
||||
if setmode:
|
||||
bailout('Cannot do set and query in same command: Set mode detected but "{0}" appears to be a query'.format(param))
|
||||
if '.' not in param:
|
||||
if param == 'bmc':
|
||||
|
||||
@@ -178,8 +178,10 @@ class pam():
|
||||
return 0
|
||||
|
||||
# python3 ctypes prefers bytes
|
||||
if isinstance(username, str): username = username.encode(encoding)
|
||||
if isinstance(service, str): service = service.encode(encoding)
|
||||
if isinstance(username, str):
|
||||
username = username.encode(encoding)
|
||||
if isinstance(service, str):
|
||||
service = service.encode(encoding)
|
||||
|
||||
if b'\x00' in username or b'\x00' in service:
|
||||
self.code = 4 # PAM_SYSTEM_ERR in Linux-PAM
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ import ctypes
|
||||
import ctypes.util
|
||||
import datetime
|
||||
import inspect
|
||||
from shutil import copytree as copytree
|
||||
from shutil import copytree
|
||||
if hasattr(inspect, 'getfullargspec') and 'dirs_exist_ok' in inspect.getfullargspec(copytree).args:
|
||||
def copy_tree(src, dst):
|
||||
copytree(src, dst, dirs_exist_ok=True)
|
||||
|
||||
Reference in New Issue
Block a user