Skip to content

Commit

Permalink
merge from master
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Dec 19, 2024
2 parents b438d68 + 4ba6ad0 commit 0ad0b4b
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 20 deletions.
7 changes: 3 additions & 4 deletions psutil/_pslinux.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,11 +641,10 @@ def cpu_count_cores():
except KeyError:
pass
current_info = {}
else:
elif line.startswith((b'physical id', b'cpu cores')):
# ongoing section
if line.startswith((b'physical id', b'cpu cores')):
key, value = line.split(b'\t:', 1)
current_info[key] = int(value)
key, value = line.split(b'\t:', 1)
current_info[key] = int(value)

result = sum(mapping.values())
return result or None # mimic os.cpu_count()
Expand Down
7 changes: 3 additions & 4 deletions psutil/tests/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,10 @@ def ps(fmt, pid=None):

if pid is not None:
cmd.extend(['-p', str(pid)])
elif SUNOS or AIX:
cmd.append('-A')
else:
if SUNOS or AIX:
cmd.append('-A')
else:
cmd.append('ax')
cmd.append('ax')

if SUNOS:
fmt = fmt.replace("start", "stime")
Expand Down
15 changes: 7 additions & 8 deletions psutil/tests/test_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -660,17 +660,16 @@ def test_memory_maps(self):
data = f.read()
if "%s (deleted)" % nt.path not in data:
raise
else:
elif '64' not in os.path.basename(nt.path):
# XXX - On Windows we have this strange behavior with
# 64 bit dlls: they are visible via explorer but cannot
# be accessed via os.stat() (wtf?).
if '64' not in os.path.basename(nt.path):
try:
st = os.stat(nt.path)
except FileNotFoundError:
pass
else:
assert stat.S_ISREG(st.st_mode), nt.path
try:
st = os.stat(nt.path)
except FileNotFoundError:
pass
else:
assert stat.S_ISREG(st.st_mode), nt.path
for nt in ext_maps:
for fname in nt._fields:
value = getattr(nt, fname)
Expand Down
5 changes: 2 additions & 3 deletions psutil/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -963,9 +963,8 @@ def test_sensors_battery(self):
psutil.POWER_TIME_UNLIMITED,
}:
assert ret.secsleft >= 0
else:
if ret.secsleft == psutil.POWER_TIME_UNLIMITED:
assert ret.power_plugged
elif ret.secsleft == psutil.POWER_TIME_UNLIMITED:
assert ret.power_plugged
assert isinstance(ret.power_plugged, bool)

@pytest.mark.skipif(not HAS_SENSORS_FANS, reason="not supported")
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ ignore = [
"PLR1702", # Too many nested blocks (x > y)
"PLR1704", # Redefining argument with the local name `type_`
"PLR2004", # Magic value used in comparison, consider replacing X with a constant variable
"PLR5501", # Use `elif` instead of `else` then `if`, to reduce indentation
"PLR6301", # Method `x` could be a function, class method, or static method
"PLW0603", # Using the global statement to update `lineno` is discouraged
"PLW1514", # `open` in text mode without explicit `encoding` argument
Expand Down

0 comments on commit 0ad0b4b

Please sign in to comment.