Closed GoogleCodeExporter closed 9 years ago
What steps will reproduce the problem? import psutil p = psutil.Process(6557) p.as_dict() {'cmdline': ['/bin/bash'], 'connections': [], 'cpu_affinity': [0, 1, 2, 3], 'cpu_percent': 0.0, 'cpu_times': cputimes(user=1.6, system=0.68), 'create_time': 1347961537.51, 'cwd': '/home/nicolargo/Dropbox/dev/glances/glances', 'exe': '/bin/bash', 'ext_memory_info': meminfo(rss=8134656, vms=32305152, shared=1126400, text=917504, lib=0, data=7045120, dirty=0), 'gids': group(real=1000, effective=1000, saved=1000), 'io_counters': io(read_count=13761556602, write_count=30243095766, read_bytes=555057152, write_bytes=30019190784), 'ionice': ionice(ioclass=0, value=0), 'memory_info': meminfo(rss=8134656, vms=32305152), 'memory_maps': [mmap(path='/lib/x86_64-linux-gnu/libnss_nis-2.15.so', rss=8192, size=2146304, pss=8192, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=8192, referenced=8192, anonymous=8192, swap=0), mmap(path='/lib/x86_64-linux-gnu/libnsl-2.15.so', rss=8192, size=2195456, pss=8192, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=8192, referenced=8192, anonymous=8192, swap=0), mmap(path='/usr/lib/locale/locale-archive', rss=40960, size=7225344, pss=4096, shared_clean=40960, shared_dirty=40960, private_clean=0, private_dirty=0, referenced=40960, anonymous=0, swap=0), mmap(path='/bin/bash', rss=552960, size=958464, pss=172032, shared_clean=512000, shared_dirty=512000, private_clean=0, private_dirty=40960, referenced=552960, anonymous=40960, swap=0), mmap(path='[stack]', rss=32768, size=139264, pss=32768, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=32768, referenced=32768, anonymous=32768, swap=0), mmap(path='[anon]', rss=65536, size=73728, pss=65536, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=65536, referenced=65536, anonymous=65536, swap=0), mmap(path='/lib/x86_64-linux-gnu/libnss_compat-2.15.so', rss=8192, size=2134016, pss=8192, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=8192, referenced=8192, anonymous=8192, swap=0), mmap(path='/lib/x86_64-linux-gnu/ld-2.15.so', rss=53248, size=151552, pss=12288, shared_clean=40960, shared_dirty=40960, private_clean=0, private_dirty=12288, referenced=53248, anonymous=12288, swap=0), mmap(path='/lib/x86_64-linux-gnu/libnss_files-2.15.so', rss=8192, size=2150400, pss=8192, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=8192, referenced=8192, anonymous=8192, swap=0), mmap(path='/lib/x86_64-linux-gnu/libdl-2.15.so', rss=16384, size=2113536, pss=8192, shared_clean=8192, shared_dirty=8192, private_clean=0, private_dirty=8192, referenced=16384, anonymous=8192, swap=0), mmap(path='[heap]', rss=6770688, size=6828032, pss=6770688, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=6770688, referenced=6770688, anonymous=6770688, swap=0), mmap(path='/lib/x86_64-linux-gnu/libtinfo.so.5.9', rss=61440, size=2256896, pss=27648, shared_clean=40960, shared_dirty=40960, private_clean=0, private_dirty=20480, referenced=61440, anonymous=20480, swap=0), mmap(path='[vdso]', rss=4096, size=4096, pss=0, shared_clean=4096, shared_dirty=4096, private_clean=0, private_dirty=0, referenced=4096, anonymous=0, swap=0), mmap(path='/usr/lib/x86_64-linux-gnu/gconv/gconv-modules.cache', rss=0, size=28672, pss=0, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=0, referenced=0, anonymous=0, swap=0), mmap(path='/lib/x86_64-linux-gnu/libc-2.15.so', rss=503808, size=3899392, pss=32768, shared_clean=479232, shared_dirty=479232, private_clean=0, private_dirty=24576, referenced=503808, anonymous=24576, swap=0), mmap(path='[vsyscall]', rss=0, size=4096, pss=0, shared_clean=0, shared_dirty=0, private_clean=0, private_dirty=0, referenced=0, anonymous=0, swap=0)], 'memory_percent': 0.09766974544392276, 'name': 'bash', 'nice': 0, 'num_ctx_switches': amount(voluntary=5898, involuntary=8701), 'num_fds': 4, 'num_threads': 1, 'open_files': [], 'pid': 6557, 'ppid': 5864, 'status': 1, 'terminal': '/dev/pts/1', 'threads': [thread(id=6557, user_time=1.6, system_time=0.68)], 'uids': user(real=1000, effective=1000, saved=1000), 'username': 'nicolargo'} => OK p.as_dict(['name']) Out[35]: {'name': 'bash'} => OK p.as_dict(['memory_percent']) --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) /home/nicolargo/Dropbox/dev/glances/<ipython-input-34-90c421d38171> in <module>() ----> 1 p.as_dict(['memory_percent']) /usr/local/lib/python2.7/dist-packages/psutil/__init__.pyc in as_dict(self, attrs, ad_value) 160 continue 161 try: --> 162 attr = getattr(self, name) 163 if callable(attr): 164 if name == 'get_cpu_percent': AttributeError: 'Process' object has no attribute 'memory_percent' => NOK What is the expected output? {'memory_percent': 0.0} What do you see instead? AttributeError: 'Process' object has no attribute 'memory_percent' What version of psutil are you using? What Python version? psutil.__version__ Out[36]: '0.6.1' On what operating system? Is it 32bit or 64bit version? Ubuntu 12.04 64bit Please provide any additional information below.
Original issue reported on code.google.com by nicolash...@gmail.com on 21 Sep 2012 at 12:18
nicolash...@gmail.com
You are supposed to use the attribute/method name, hence "get_memory_percent" instead of "memory_percent".
Original comment by g.rodola on 24 Sep 2012 at 6:00
g.rodola
Original issue reported on code.google.com by
nicolash...@gmail.com
on 21 Sep 2012 at 12:18