You are not logged in.

#1 2014-03-14 10:04:07

hwa
Member
Registered: 2014-03-12
Posts: 10

Where is python object "role"?

I'n unable to find the "role"-object for a script I'm adapting from debian to arch. In debian that object seems to be in module pysnmp, in arch it is not, or so it seems. Where might that object be in arch?

The original script says:

from pysnmp import role

Offline

#2 2014-03-14 10:08:44

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: Where is python object "role"?

pysnmp is in the AUR, did you try installing that?

Offline

#3 2014-03-14 13:09:52

hwa
Member
Registered: 2014-03-12
Posts: 10

Re: Where is python object "role"?

I had installed it from AUR. I tried to say above that python-pysnmp -packet does not include object "role".  Or at least I can't find it :-(

Offline

#4 2014-03-14 13:21:51

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,614

Re: Where is python object "role"?

Any chance we are mixing Python 2 and Python 3?


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#5 2014-03-14 13:49:23

hwa
Member
Registered: 2014-03-12
Posts: 10

Re: Where is python object "role"?

I've tried to search both. Can you show that either has role-object?

Offline

#6 2014-03-14 17:28:51

jakobcreutzfeldt
Member
Registered: 2011-05-12
Posts: 1,042

Re: Where is python object "role"?

hwa wrote:

I've tried to search both. Can you show that either has role-object?

He means you should try running the script with python2 if you've only tried it with python (which is a symlink to python3, unlike on other distros).

Last edited by jakobcreutzfeldt (2014-03-14 17:29:09)

Offline

#7 2014-03-17 07:06:05

hwa
Member
Registered: 2014-03-12
Posts: 10

Re: Where is python object "role"?

Yes, tried python2, too. No success.

Offline

#8 2014-03-20 11:03:04

nvteighen
Member
Registered: 2014-03-13
Posts: 31

Re: Where is python object "role"?

Here I read that the PySNMP API has changed in the 3.x versions and that the role object was affected, it seems... If that was the case, I guess the AUR package you installed is just the Python 3.x one (python-pysnmp), not the Python 2.x one. Try installing python2-pysnmp from the AUR to get PySNMP 2.x and then running your script with python2.

Last edited by nvteighen (2014-03-20 11:04:29)

Offline

#9 2014-03-21 12:34:41

hwa
Member
Registered: 2014-03-12
Posts: 10

Re: Where is python object "role"?

Thanks for your suggestion. The main problem is, I think, that I'm totally newbie with python and even if python2-pysnmp includes the role-object, I'm unable to find the correct way to load it :-(
I may have made a mistake not for presenting information enough in the beginning, but I thought my question would be a trivial one.

My environment

$ pacman -Q python2 python2-pysnmp
python2 2.7.6-3
python2-pysnmp 4.2.3-2

http://pysnmp.sourceforge.net/examples/2.x/snmpget.html  says you should do:

>>> from pysnmp import asn1, v1, v2c
>>> from pysnmp import role

but in reality(?) that won't work and you have to do

>>>  from pysnmp.proto.api import v1, v2c

But for loading role, I have not found a working way

>>> from pysnmp import role
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: cannot import name role
>>> from pysnmp.mapping.udp import role
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named mapping.udp

Offline

#10 2014-03-21 13:01:13

progandy
Member
Registered: 2012-05-17
Posts: 5,307

Re: Where is python object "role"?

You have pysnmp v 4.2.5, not 2.x so it probably has different classes.
Edit: I guess using snmp should have vecome easier: http://pysnmp.sourceforge.net/examples/ … t-v2c.html

Last edited by progandy (2014-03-21 13:15:55)


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

Board footer

Powered by FluxBB