OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # $Id: _psposix.py 1142 2011-10-05 18:45:49Z g.rodola $ | 3 # $Id: _psposix.py 1162 2011-10-14 20:41:07Z g.rodola $ |
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 """Routines common to all posix systems.""" | 9 """Routines common to all posix systems.""" |
10 | 10 |
11 import os | 11 import os |
12 import errno | 12 import errno |
13 import subprocess | 13 import subprocess |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 'IPv4' : socket.AF_INET, | 121 'IPv4' : socket.AF_INET, |
122 'IPv6' : socket.AF_INET6} | 122 'IPv6' : socket.AF_INET6} |
123 _openfile_ntuple = namedtuple('openfile', 'path fd') | 123 _openfile_ntuple = namedtuple('openfile', 'path fd') |
124 _connection_ntuple = namedtuple('connection', 'fd family type local_address
' | 124 _connection_ntuple = namedtuple('connection', 'fd family type local_address
' |
125 'remote_address status') | 125 'remote_address status') |
126 | 126 |
127 def __init__(self, pid, name): | 127 def __init__(self, pid, name): |
128 self.pid = pid | 128 self.pid = pid |
129 self.process_name = name | 129 self.process_name = name |
130 | 130 |
| 131 # XXX - this is no longer used |
131 def get_process_open_files(self): | 132 def get_process_open_files(self): |
132 """Return files opened by process by parsing lsof output.""" | 133 """Return files opened by process by parsing lsof output.""" |
133 # Options: | 134 # Options: |
134 # -i == network files only | 135 # -i == network files only |
135 # -a == ANDing of all options | 136 # -a == ANDing of all options |
136 # -p == process with given PID only | 137 # -p == process with given PID only |
137 # -n == do not resolve IP addresses | 138 # -n == do not resolve IP addresses |
138 # -P == do not resolve port numbers | 139 # -P == do not resolve port numbers |
139 # -w == suppresses warnings | 140 # -w == suppresses warnings |
140 # -F0nPt == (0) separate lines with "\x00" | 141 # -F0nPt == (0) separate lines with "\x00" |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 elif family == socket.AF_INET6: | 310 elif family == socket.AF_INET6: |
310 ip = "::" | 311 ip = "::" |
311 # OS X can have some procs e.g. SystemUIServer listening on *:* | 312 # OS X can have some procs e.g. SystemUIServer listening on *:* |
312 else: | 313 else: |
313 raise ValueError("invalid IP %s" %addr) | 314 raise ValueError("invalid IP %s" %addr) |
314 if port == "*": | 315 if port == "*": |
315 return 0 | 316 return 0 |
316 return (ip, int(port)) | 317 return (ip, int(port)) |
317 | 318 |
318 | 319 |
OLD | NEW |