peter-hst / psutil

Automatically exported from code.google.com/p/psutil
Other
0 stars 0 forks source link

Broken example code - top.py #279

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run downloaded top.py example

What is the expected output?
As per screenshot on documentation web-site

What do you see instead?
Traceback (most recent call last):
  File "./top.py", line 203, in <module>
    main()
  File "./top.py", line 196, in main
    args = poll(interval)
  File "./top.py", line 91, in poll
    p.dict = p.as_dict(['username', 'nice', 'get_memory_info',
AttributeError: 'Process' object has no attribute 'as_dict'

What version of psutil are you using? What Python version?
0.4.1

On what operating system? Is it 32bit or 64bit version?
Linux 64bit

Please provide any additional information below.
Looks like a new method, "as_dict", has been added to Process class and the 
example updated to use it. The available download doesn't appear to have this 
method yet.

Original issue reported on code.google.com by dave.flitney@gmail.com on 11 Jun 2012 at 4:41

GoogleCodeExporter commented 9 years ago
Of course, because as_dict() has been added to the trunk.
It appears you're using "new" top.py with 0.4.1 version installed, which is 
obviously "older" than the current development trunk.

Original comment by g.rodola on 11 Jun 2012 at 5:23

GoogleCodeExporter commented 9 years ago
Would it be possible to have the documentation and examples "match" the 
"current" release rather than the trunk?  It substantially lowers the bar for 
people learning an API if the documentation matches the version available.

Original comment by dave.flitney@gmail.com on 12 Jun 2012 at 8:40

GoogleCodeExporter commented 9 years ago
Documentation always matches the current release, never the trunk/development 
version.
I update it only at the time I release a new tarball version.

As for the example scripts, maybe you're referring to the links in the home 
page which point to example scripts in the trunk version, right?
In that case I can change that.

Original comment by g.rodola on 12 Jun 2012 at 10:15

GoogleCodeExporter commented 9 years ago
Closing out as invalid.

Original comment by g.rodola on 21 Jun 2012 at 4:35

GoogleCodeExporter commented 9 years ago
I am having the error: 
AttributeError: 'Process' object has no attribute 'as_dict'

I also can not find this function anywhere in this repository. Any idea?

Original comment by renatosa...@gmail.com on 30 Jun 2013 at 6:42

GoogleCodeExporter commented 9 years ago
I fix it by installing the latest version for this moment (0.7.1):

$ sudo pip install psutil --upgrade
Downloading/unpacking psutil
  Downloading psutil-0.7.1.tar.gz (140Kb): 140Kb downloaded
  Running setup.py egg_info for package psutil

Installing collected packages: psutil
  Found existing installation: psutil 0.4.1
    Uninstalling psutil:
      Successfully uninstalled psutil
  Running setup.py install for psutil
    building '_psutil_linux' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c psutil/_psutil_linux.c -o build/temp.linux-i686-2.7/psutil/_psutil_linux.o
    gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-i686-2.7/psutil/_psutil_linux.o -o build/lib.linux-i686-2.7/_psutil_linux.so
    building '_psutil_posix' extension
    gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c psutil/_psutil_posix.c -o build/temp.linux-i686-2.7/psutil/_psutil_posix.o
    gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-i686-2.7/psutil/_psutil_posix.o -o build/lib.linux-i686-2.7/_psutil_posix.so

Successfully installed psutil
Cleaning up...

Original comment by renatosa...@gmail.com on 30 Jun 2013 at 6:47