py2docfx 0.1.20.dev2245319__py3-none-any.whl → 0.1.20.dev2245492__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. py2docfx/convert_prepare/get_source.py +1 -1
  2. py2docfx/convert_prepare/tests/test_get_source.py +3 -1
  3. py2docfx/docfx_yaml/build_finished.py +1 -1
  4. py2docfx/venv/venv1/Lib/site-packages/psutil/__init__.py +39 -19
  5. py2docfx/venv/venv1/Lib/site-packages/psutil/_common.py +3 -5
  6. py2docfx/venv/venv1/Lib/site-packages/psutil/_psaix.py +1 -2
  7. py2docfx/venv/venv1/Lib/site-packages/psutil/_psbsd.py +53 -78
  8. py2docfx/venv/venv1/Lib/site-packages/psutil/_pslinux.py +55 -38
  9. py2docfx/venv/venv1/Lib/site-packages/psutil/_psosx.py +40 -12
  10. py2docfx/venv/venv1/Lib/site-packages/psutil/_psposix.py +0 -1
  11. py2docfx/venv/venv1/Lib/site-packages/psutil/_pssunos.py +1 -2
  12. py2docfx/venv/venv1/Lib/site-packages/psutil/_pswindows.py +33 -13
  13. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__init__.py +185 -122
  14. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/__main__.py +2 -3
  15. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_bsd.py +5 -10
  16. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_connections.py +3 -4
  17. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_contracts.py +41 -45
  18. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_linux.py +35 -38
  19. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_memleaks.py +4 -8
  20. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_misc.py +6 -12
  21. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_osx.py +17 -8
  22. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_posix.py +29 -17
  23. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process.py +74 -75
  24. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_process_all.py +11 -13
  25. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_scripts.py +2 -3
  26. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_sudo.py +117 -0
  27. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_system.py +21 -31
  28. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_testutils.py +23 -23
  29. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_unicode.py +15 -8
  30. py2docfx/venv/venv1/Lib/site-packages/psutil/tests/test_windows.py +65 -33
  31. {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2245492.dist-info}/METADATA +1 -1
  32. {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2245492.dist-info}/RECORD +34 -33
  33. {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2245492.dist-info}/WHEEL +0 -0
  34. {py2docfx-0.1.20.dev2245319.dist-info → py2docfx-0.1.20.dev2245492.dist-info}/top_level.txt +0 -0
@@ -18,12 +18,12 @@ from ._common import NoSuchProcess
18
18
  from ._common import ZombieProcess
19
19
  from ._common import conn_tmap
20
20
  from ._common import conn_to_ntuple
21
+ from ._common import debug
21
22
  from ._common import isfile_strict
22
23
  from ._common import memoize_when_activated
23
24
  from ._common import parse_environ_block
24
25
  from ._common import usage_percent
25
26
 
26
-
27
27
  __extra__all__ = []
28
28
 
29
29
 
@@ -170,14 +170,16 @@ def cpu_stats():
170
170
  )
171
171
 
172
172
 
173
- def cpu_freq():
174
- """Return CPU frequency.
175
- On macOS per-cpu frequency is not supported.
176
- Also, the returned frequency never changes, see:
177
- https://arstechnica.com/civis/viewtopic.php?f=19&t=465002.
178
- """
179
- curr, min_, max_ = cext.cpu_freq()
180
- return [_common.scpufreq(curr, min_, max_)]
173
+ if cext.has_cpu_freq(): # not always available on ARM64
174
+
175
+ def cpu_freq():
176
+ """Return CPU frequency.
177
+ On macOS per-cpu frequency is not supported.
178
+ Also, the returned frequency never changes, see:
179
+ https://arstechnica.com/civis/viewtopic.php?f=19&t=465002.
180
+ """
181
+ curr, min_, max_ = cext.cpu_freq()
182
+ return [_common.scpufreq(curr, min_, max_)]
181
183
 
182
184
 
183
185
  # =====================================================================
@@ -288,10 +290,33 @@ def boot_time():
288
290
  return cext.boot_time()
289
291
 
290
292
 
293
+ try:
294
+ INIT_BOOT_TIME = boot_time()
295
+ except Exception as err: # noqa: BLE001
296
+ # Don't want to crash at import time.
297
+ debug(f"ignoring exception on import: {err!r}")
298
+ INIT_BOOT_TIME = 0
299
+
300
+
301
+ def adjust_proc_create_time(ctime):
302
+ """Account for system clock updates."""
303
+ if INIT_BOOT_TIME == 0:
304
+ return ctime
305
+
306
+ diff = INIT_BOOT_TIME - boot_time()
307
+ if diff == 0 or abs(diff) < 1:
308
+ return ctime
309
+
310
+ debug("system clock was updated; adjusting process create_time()")
311
+ if diff < 0:
312
+ return ctime - diff
313
+ return ctime + diff
314
+
315
+
291
316
  def users():
292
317
  """Return currently connected users as a list of namedtuples."""
293
318
  retlist = []
294
- rawlist = cext.users()
319
+ rawlist = cext_posix.users()
295
320
  for item in rawlist:
296
321
  user, tty, hostname, tstamp, pid = item
297
322
  if tty == '~':
@@ -470,8 +495,11 @@ class Process:
470
495
  )
471
496
 
472
497
  @wrap_exceptions
473
- def create_time(self):
474
- return self._get_kinfo_proc()[kinfo_proc_map['ctime']]
498
+ def create_time(self, monotonic=False):
499
+ ctime = self._get_kinfo_proc()[kinfo_proc_map['ctime']]
500
+ if not monotonic:
501
+ ctime = adjust_proc_create_time(ctime)
502
+ return ctime
475
503
 
476
504
  @wrap_exceptions
477
505
  def num_ctx_switches(self):
@@ -16,7 +16,6 @@ from ._common import memoize
16
16
  from ._common import sdiskusage
17
17
  from ._common import usage_percent
18
18
 
19
-
20
19
  if MACOS:
21
20
  from . import _psutil_osx
22
21
 
@@ -30,7 +30,6 @@ from ._common import sockfam_to_enum
30
30
  from ._common import socktype_to_enum
31
31
  from ._common import usage_percent
32
32
 
33
-
34
33
  __extra__all__ = ["CONN_IDLE", "CONN_BOUND", "PROCFS_PATH"]
35
34
 
36
35
 
@@ -311,7 +310,7 @@ def boot_time():
311
310
  def users():
312
311
  """Return currently connected users as a list of namedtuples."""
313
312
  retlist = []
314
- rawlist = cext.users()
313
+ rawlist = cext_posix.users()
315
314
  localhost = (':0.0', ':0')
316
315
  for item in rawlist:
317
316
  user, tty, hostname, tstamp, user_process, pid = item
@@ -10,6 +10,7 @@ import functools
10
10
  import os
11
11
  import signal
12
12
  import sys
13
+ import threading
13
14
  import time
14
15
  from collections import namedtuple
15
16
 
@@ -33,7 +34,6 @@ from ._psutil_windows import IDLE_PRIORITY_CLASS
33
34
  from ._psutil_windows import NORMAL_PRIORITY_CLASS
34
35
  from ._psutil_windows import REALTIME_PRIORITY_CLASS
35
36
 
36
-
37
37
  try:
38
38
  from . import _psutil_windows as cext
39
39
  except ImportError as err:
@@ -184,12 +184,21 @@ pio = namedtuple('pio', ['read_count', 'write_count',
184
184
  @functools.lru_cache(maxsize=512)
185
185
  def convert_dos_path(s):
186
186
  r"""Convert paths using native DOS format like:
187
- "\Device\HarddiskVolume1\Windows\systemew\file.txt"
187
+ "\Device\HarddiskVolume1\Windows\systemew\file.txt" or
188
+ "\??\C:\Windows\systemew\file.txt"
188
189
  into:
189
190
  "C:\Windows\systemew\file.txt".
190
191
  """
192
+ if s.startswith('\\\\'):
193
+ return s
191
194
  rawdrive = '\\'.join(s.split('\\')[:3])
192
- driveletter = cext.QueryDosDevice(rawdrive)
195
+ if rawdrive in {"\\??\\UNC", "\\Device\\Mup"}:
196
+ rawdrive = '\\'.join(s.split('\\')[:5])
197
+ driveletter = '\\\\' + '\\'.join(s.split('\\')[3:5])
198
+ elif rawdrive.startswith('\\??\\'):
199
+ driveletter = s.split('\\')[2]
200
+ else:
201
+ driveletter = cext.QueryDosDevice(rawdrive)
193
202
  remainder = s[len(rawdrive) :]
194
203
  return os.path.join(driveletter, remainder)
195
204
 
@@ -322,22 +331,31 @@ def cpu_freq():
322
331
  return [_common.scpufreq(float(curr), min_, float(max_))]
323
332
 
324
333
 
325
- _loadavg_inititialized = False
334
+ _loadavg_initialized = False
335
+ _lock = threading.Lock()
336
+
337
+
338
+ def _getloadavg_impl():
339
+ # Drop to 2 decimal points which is what Linux does
340
+ raw_loads = cext.getloadavg()
341
+ return tuple(round(load, 2) for load in raw_loads)
326
342
 
327
343
 
328
344
  def getloadavg():
329
345
  """Return the number of processes in the system run queue averaged
330
346
  over the last 1, 5, and 15 minutes respectively as a tuple.
331
347
  """
332
- global _loadavg_inititialized
348
+ global _loadavg_initialized
333
349
 
334
- if not _loadavg_inititialized:
335
- cext.init_loadavg_counter()
336
- _loadavg_inititialized = True
350
+ if _loadavg_initialized:
351
+ return _getloadavg_impl()
337
352
 
338
- # Drop to 2 decimal points which is what Linux does
339
- raw_loads = cext.getloadavg()
340
- return tuple(round(load, 2) for load in raw_loads)
353
+ with _lock:
354
+ if not _loadavg_initialized:
355
+ cext.init_loadavg_counter()
356
+ _loadavg_initialized = True
357
+
358
+ return _getloadavg_impl()
341
359
 
342
360
 
343
361
  # =====================================================================
@@ -426,12 +444,14 @@ _last_btime = 0
426
444
 
427
445
 
428
446
  def boot_time():
429
- """The system boot time expressed in seconds since the epoch."""
447
+ """The system boot time expressed in seconds since the epoch. This
448
+ also includes the time spent during hybernate / suspend.
449
+ """
430
450
  # This dirty hack is to adjust the precision of the returned
431
451
  # value which may have a 1 second fluctuation, see:
432
452
  # https://github.com/giampaolo/psutil/issues/1007
433
453
  global _last_btime
434
- ret = float(cext.boot_time())
454
+ ret = time.time() - cext.uptime()
435
455
  if abs(ret - _last_btime) <= 1:
436
456
  return _last_btime
437
457
  else: