OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # $Id: _psosx.py 1142 2011-10-05 18:45:49Z g.rodola $ | 3 # $Id: _psosx.py 1159 2011-10-14 18:42:54Z g.rodola@gmail.com $ |
4 # | 4 # |
5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. | 5 # Copyright (c) 2009, Jay Loden, Giampaolo Rodola'. All rights reserved. |
6 # Use of this source code is governed by a BSD-style license that can be | 6 # Use of this source code is governed by a BSD-style license that can be |
7 # found in the LICENSE file. | 7 # found in the LICENSE file. |
8 | 8 |
9 """OSX platform implementation.""" | 9 """OSX platform implementation.""" |
10 | 10 |
11 import errno | 11 import errno |
12 import os | 12 import os |
13 | 13 |
(...skipping 173 matching lines...) Loading... |
187 raise AccessDenied(self.pid, self._process_name) | 187 raise AccessDenied(self.pid, self._process_name) |
188 files = [] | 188 files = [] |
189 rawlist = _psutil_osx.get_process_open_files(self.pid) | 189 rawlist = _psutil_osx.get_process_open_files(self.pid) |
190 for path, fd in rawlist: | 190 for path, fd in rawlist: |
191 if os.path.isfile(path): | 191 if os.path.isfile(path): |
192 ntuple = ntuple_openfile(path, fd) | 192 ntuple = ntuple_openfile(path, fd) |
193 files.append(ntuple) | 193 files.append(ntuple) |
194 return files | 194 return files |
195 | 195 |
196 @wrap_exceptions | 196 @wrap_exceptions |
197 def get_connections(self): | 197 def get_connections(self, kind='inet'): |
198 """Return etwork connections opened by a process as a list of | 198 """Return etwork connections opened by a process as a list of |
199 namedtuples.""" | 199 namedtuples. |
200 retlist = _psutil_osx.get_process_connections(self.pid) | 200 """ |
201 return [ntuple_connection(*conn) for conn in retlist] | 201 if kind not in conn_tmap: |
| 202 raise ValueError("invalid %r kind argument; choose between %s" |
| 203 % (kind, ', '.join([repr(x) for x in conn_tmap]))) |
| 204 families, types = conn_tmap[kind] |
| 205 ret = _psutil_osx.get_process_connections(self.pid, families, types) |
| 206 return [ntuple_connection(*conn) for conn in ret] |
202 | 207 |
203 @wrap_exceptions | 208 @wrap_exceptions |
204 def process_wait(self, timeout=None): | 209 def process_wait(self, timeout=None): |
205 try: | 210 try: |
206 return _psposix.wait_pid(self.pid, timeout) | 211 return _psposix.wait_pid(self.pid, timeout) |
207 except TimeoutExpired: | 212 except TimeoutExpired: |
208 raise TimeoutExpired(self.pid, self._process_name) | 213 raise TimeoutExpired(self.pid, self._process_name) |
209 | 214 |
210 @wrap_exceptions | 215 @wrap_exceptions |
211 def get_process_nice(self): | 216 def get_process_nice(self): |
(...skipping 12 matching lines...) Loading... |
224 | 229 |
225 @wrap_exceptions | 230 @wrap_exceptions |
226 def get_process_threads(self): | 231 def get_process_threads(self): |
227 """Return the number of threads belonging to the process.""" | 232 """Return the number of threads belonging to the process.""" |
228 rawlist = _psutil_osx.get_process_threads(self.pid) | 233 rawlist = _psutil_osx.get_process_threads(self.pid) |
229 retlist = [] | 234 retlist = [] |
230 for thread_id, utime, stime in rawlist: | 235 for thread_id, utime, stime in rawlist: |
231 ntuple = ntuple_thread(thread_id, utime, stime) | 236 ntuple = ntuple_thread(thread_id, utime, stime) |
232 retlist.append(ntuple) | 237 retlist.append(ntuple) |
233 return retlist | 238 return retlist |
OLD | NEW |