diff options
author | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-11-26 14:29:51 +0100 |
---|---|---|
committer | Giampaolo Rodola' <g.rodola@gmail.com> | 2013-11-26 14:29:51 +0100 |
commit | 2fa537cfe2b99423e10927477e374455232e7fa3 (patch) | |
tree | d771f72d5f05132309069c800c266d980636635f | |
parent | 2a49f21826400ac6d02da39a5edf49730b67d119 (diff) | |
download | psutil-2fa537cfe2b99423e10927477e374455232e7fa3.tar.gz |
pep8ify
-rw-r--r-- | psutil/__init__.py | 5 | ||||
-rw-r--r-- | psutil/_compat.py | 16 | ||||
-rw-r--r-- | psutil/_pslinux.py | 6 | ||||
-rw-r--r-- | psutil/error.py | 5 | ||||
-rwxr-xr-x | test/_posix.py | 8 | ||||
-rw-r--r-- | test/_windows.py | 12 | ||||
-rw-r--r-- | test/test_psutil.py | 6 |
7 files changed, 31 insertions, 27 deletions
diff --git a/psutil/__init__.py b/psutil/__init__.py index 786d47d8..0b6c2f60 100644 --- a/psutil/__init__.py +++ b/psutil/__init__.py @@ -373,8 +373,9 @@ class Process(object): # Attempt to guess only in case of an absolute path. # It is not safe otherwise as the process might have # changed cwd. - if os.path.isabs(exe) and os.path.isfile(exe) \ - and os.access(exe, os.X_OK): + if (os.path.isabs(exe) + and os.path.isfile(exe) + and os.access(exe, os.X_OK)): return exe if isinstance(fallback, AccessDenied): raise fallback diff --git a/psutil/_compat.py b/psutil/_compat.py index 282c05af..5c68f745 100644 --- a/psutil/_compat.py +++ b/psutil/_compat.py @@ -87,9 +87,11 @@ except ImportError: names = list(field_names) seen = set() for i, name in enumerate(names): - if (not min(c.isalnum() or c == '_' for c in name) or _iskeyword(name) - or not name or name[0].isdigit() or name.startswith('_') - or name in seen): + if ((not min(c.isalnum() or c == '_' for c in name) + or _iskeyword(name) + or not name or name[0].isdigit() + or name.startswith('_') + or name in seen)): names[i] = '_%d' % i seen.add(name) field_names = tuple(names) @@ -99,8 +101,8 @@ except ImportError: 'alphanumeric characters and underscores: %r' % name) if _iskeyword(name): - raise ValueError('Type names and field names cannot be a keyword: %r' - % name) + raise ValueError( + 'Type names and field names cannot be a keyword: %r' % name) if name[0].isdigit(): raise ValueError('Type names and field names cannot start with a ' 'number: %r' % name) @@ -207,8 +209,8 @@ except ImportError: class defaultdict(dict): def __init__(self, default_factory=None, *a, **kw): - if (default_factory is not None and \ - not hasattr(default_factory, '__call__')): + if ((default_factory is not None and + not hasattr(default_factory, '__call__'))): raise TypeError('first argument must be callable') dict.__init__(self, *a, **kw) self.default_factory = default_factory diff --git a/psutil/_pslinux.py b/psutil/_pslinux.py index b5f413c3..f619b5dd 100644 --- a/psutil/_pslinux.py +++ b/psutil/_pslinux.py @@ -178,9 +178,9 @@ def virtual_memory(): active = int(line.split()[1]) * 1024 elif line.startswith('Inactive:'): inactive = int(line.split()[1]) * 1024 - if cached is not None \ - and active is not None \ - and inactive is not None: + if (cached is not None + and active is not None + and inactive is not None): break else: # we might get here when dealing with exotic Linux flavors, see: diff --git a/psutil/error.py b/psutil/error.py index 4c48c783..b97190c7 100644 --- a/psutil/error.py +++ b/psutil/error.py @@ -14,6 +14,7 @@ and are supposed to be accessed from 'psutil' namespace as in: import warnings from psutil._error import * -warnings.warn("psutil.error module is deprecated and scheduled for removal; " \ + +warnings.warn("psutil.error module is deprecated and scheduled for removal; " "use psutil namespace instead", category=DeprecationWarning, - stacklevel=2) + stacklevel=2) diff --git a/test/_posix.py b/test/_posix.py index 5492e8c1..b82e20c0 100755 --- a/test/_posix.py +++ b/test/_posix.py @@ -207,10 +207,10 @@ class PosixSpecificTestCase(unittest.TestCase): p = psutil.Process(os.getpid()) failures = [] for name in dir(psutil.Process): - if name.startswith('_') \ - or name.startswith('set_') \ - or name in ('terminate', 'kill', 'suspend', 'resume', 'nice', - 'send_signal', 'wait', 'get_children', 'as_dict'): + if (name.startswith('_') + or name.startswith('set_') + or name in ('terminate', 'kill', 'suspend', 'resume', 'nice', + 'send_signal', 'wait', 'get_children', 'as_dict')): continue else: try: diff --git a/test/_windows.py b/test/_windows.py index 3e014b65..97e5adc1 100644 --- a/test/_windows.py +++ b/test/_windows.py @@ -272,12 +272,12 @@ class WindowsSpecificTestCase(unittest.TestCase): class TestDualProcessImplementation(unittest.TestCase): fun_names = [ - # function name tolerance - ('get_process_cpu_times', 0.2), - ('get_process_create_time', 0.5), - ('get_process_num_handles', 1), # 1 because impl #1 opens a handle - ('get_process_io_counters', 0), - ('get_process_memory_info', 1024), # KB + # function name, tolerance + ('get_process_cpu_times', 0.2), + ('get_process_create_time', 0.5), + ('get_process_num_handles', 1), # 1 because impl #1 opens a handle + ('get_process_io_counters', 0), + ('get_process_memory_info', 1024), # KB ] def test_compare_values(self): diff --git a/test/test_psutil.py b/test/test_psutil.py index a3079e45..f22dbe6e 100644 --- a/test/test_psutil.py +++ b/test/test_psutil.py @@ -355,7 +355,7 @@ def retry_before_failing(ntimes=None): try: return fun(*args, **kwargs) except AssertionError: - err = sys.exc_info()[1] + pass raise return wrapper return decorator @@ -2040,8 +2040,8 @@ class TestProcess(unittest.TestCase): call_until(lambda: zproc.status, "ret == psutil.STATUS_ZOMBIE") self.assertTrue(psutil.pid_exists(zpid)) zproc = psutil.Process(zpid) - descendants = [x.pid for x in - psutil.Process(os.getpid()).get_children(recursive=True)] + descendants = [x.pid for x in psutil.Process( + os.getpid()).get_children(recursive=True)] self.assertIn(zpid, descendants) finally: if sock is not None: |