diff options
author | vapier@chromium.org <vapier@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-14 18:41:06 +0000 |
---|---|---|
committer | vapier@chromium.org <vapier@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2014-04-14 18:41:06 +0000 |
commit | abcc9b3ca00e02a3d8bb5f781b60b4bb27626731 (patch) | |
tree | 02b8804744c8e7042ed50fac11d28674f10be6b2 /remoting/host | |
parent | be6b68333dc15c79c1f5b5b3bfff644fe2ad3edb (diff) | |
download | chromium_src-abcc9b3ca00e02a3d8bb5f781b60b4bb27626731.zip chromium_src-abcc9b3ca00e02a3d8bb5f781b60b4bb27626731.tar.gz chromium_src-abcc9b3ca00e02a3d8bb5f781b60b4bb27626731.tar.bz2 |
chromote: linux: fix running w/psutil-2.x
The newer python psutil-2.x release has reworked the API in backwards
incompatible ways. Add some glue to handle both series.
BUG=None
TEST=ran script w/psutil-2.1.x and it worked again
Review URL: https://codereview.chromium.org/235883005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@263682 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/host')
-rwxr-xr-x | remoting/host/linux/linux_me2me_host.py | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/remoting/host/linux/linux_me2me_host.py b/remoting/host/linux/linux_me2me_host.py index 8c0cee0..42a9547 100755 --- a/remoting/host/linux/linux_me2me_host.py +++ b/remoting/host/linux/linux_me2me_host.py @@ -488,12 +488,21 @@ def get_daemon_pid(): uid = os.getuid() this_pid = os.getpid() + # Support new & old psutil API. + if 'error' in dir(psutil): + # Old API (0.x & 1.x). + psutil.Error = psutil.error.Error + psget = lambda x: x + else: + # New API (2.x+). + psget = lambda x: x() + for process in psutil.process_iter(): # Skip any processes that raise an exception, as processes may terminate # during iteration over the list. try: # Skip other users' processes. - if process.uids.real != uid: + if psget(process.uids).real != uid: continue # Skip the process for this instance. @@ -501,12 +510,12 @@ def get_daemon_pid(): continue # |cmdline| will be [python-interpreter, script-file, other arguments...] - cmdline = process.cmdline + cmdline = psget(process.cmdline) if len(cmdline) < 2: continue if cmdline[0] == sys.executable and cmdline[1] == sys.argv[0]: return process.pid - except psutil.error.Error: + except psutil.Error: continue return 0 |