148def detect_platform_string():
149 try:
150 return subprocess.check_output(['lsb_release', '-sd']).strip().decode()
151 except subprocess.CalledProcessError as e:152 return subprocess.check_output(['uname', '-mrs']).strip().decode()
153 except FileNotFoundError:
154 logging.warning('Please install lsb_release to detect the platform!')
132 if dist == '':
133 try:
134 dist = subprocess.check_output(['strings', '-4', '/etc/issue']).split()[0].strip().decode()
135 except subprocess.CalledProcessError as e:136 dist = 'unknown'
137
138 res = dist.strip(' \'"\t\n\r').lower()
132 ])
133 child.sendline(password)
134 result = child.expect(['su: .*', 'SUCCESS'])
135 except pexpect.exceptions.EOF as err:136 logging.error(f'Login error: {child.before.decode().strip()}')
137 if child and child.isalive():
138 child.close()
20 self.message = message or str(inner)
21 try:
22 self.traceback_str = traceback.format_exc()
23 except Exception as e: 24 self.traceback_str = None
25
26 def __str__(self):
26 else:
27 # Trying with default paths
28 subprocess.check_output(['ajenti-upgrade'])
29 except FileNotFoundError as e:30 subprocess.check_output(['/usr/local/bin/ajenti-upgrade'])
31
32
An unused variable takes up space in the code, and can lead to confusion, and it should be removed. If this variable is necessary, name the variable _
to indicate that it will be unused, or start the name with unused
or _unused
.
def update():
for i in range(10): # Usused variable `i`
time.sleep(0.01)
display_result()
def update():
for _ in range(10):
time.sleep(0.01)
display_result()