PySNMP exceptions - python

I am trying to make an SNMP agent following this tutorial:
http://www.nealc.com/blog/blog/2013/02/23/writing-an-snmp-agent-with-a-custom-mib-using-pysnmp/
I am using the exact code in the tutorial, but when I run the code it ends in this:
DBG: [19:13:54.964]: file SNMPv2-SMI.pyc mtime 1379957443
DBG: [19:13:54.964]: file SNMPv2-SMI.py mtime 1402947591
DBG: [19:13:54.965]: loadModules: evaluating /usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py
Traceback (most recent call last):
File "snmpAgentTest.py", line 163, in <module>
agent = SNMPAgent(objects)
File "snmpAgentTest.py", line 59, in __init__
self._snmpEngine = engine.SnmpEngine()
File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 18, in __init__
self.msgAndPduDsp = MsgAndPduDispatcher()
File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 24, in __init__
'SNMP-TARGET-MIB', 'SNMP-USER-BASED-SM-MIB'
File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 259, in loadModules
'MIB module \"%s\" load error: %s' % (modPath, traceback.format_exception(*sys.exc_info()))
pysnmp.smi.error.SmiError: MIB module "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2
-MIB.pyc" load error: ['Traceback (most recent call last):\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 255, in loadModules\n exec(modData, g)\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-MIB.py", line 10, in <module>\n ( Module
Compliance, NotificationGroup, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup")\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 299, in importSymbols\n self.loadModules(modName, **userCtx)\n', ' File
"/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 259, in loadModules\n \'MIB module \\"%s\\" load error: %s\' % (modPath, traceback.format_exception(*sys.exc_info()))\n', 'SmiError: MIB module "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-CONF.pyc" load error: [\'Traceback (most recent call last):\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 255, in loadModules\\n exec(modData, g)\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-CONF.py", line 2, in <module>\\n MibNode, = mibBuilder.importSymbols(\\\'SNMPv2-SMI\\\', \\\'MibNode\\\')\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 299, in importSymbols\\n self.loadModules(modName, **userCtx)\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 259, in loadModules\\n \\\'MIB module \\\\"%s\\\\" load error: %s\\\' % (modPath, traceback.format_exception(*sys.exc_info()))\\n\', \'SmiError: MIB module "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py" load error: [\\\'Traceback (most recent call last):\\\\n\\\', \\\' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 255, in loadModules\\\\n exec(modData, g)\\\\n\\\', \\\' File "<string>", line 2\\\\n\\\', \\\' -- WinAgents MIB Extraction Wizard\\\\n\\\', \\\' ^\\\\n\\\', \\\'SyntaxError: invalid syntax\\\\n\\\']\\n\']\n']
The MY-MIB.py that gets generated by build-pysnmp-mib looks like this:
# PySNMP SMI module. Autogenerated from smidump -f python MY-MIB
# by libsmi2pysnmp-0.1.3 at Thu Jun 26 19:03:31 2014,
# Python version sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
# Imports
( Integer, ObjectIdentifier, OctetString, ) = mibBuilder.importSymbols("ASN1", "Integer", "ObjectIdentifier", "OctetString")
( NamedValues, ) = mibBuilder.importSymbols("ASN1-ENUMERATION", "NamedValues")
( ConstraintsIntersection, ConstraintsUnion, SingleValueConstraint, ValueRangeConstraint, ValueSizeConstraint, ) = mibBuilder.importSymbols("ASN1-REFINEMENT", "ConstraintsIntersection", "ConstraintsUnion", "SingleValueConstraint", "ValueRangeConstraint", "ValueSizeConstraint")
( Bits, Integer32, Integer32, MibIdentifier, NotificationType, MibScalar, MibTable, MibTableRow, MibTableColumn, TimeTicks, enterprises, ) = mibBuilder.importSymbols("SNMPv2-SMI", "Bits", "Integer32", "Integer32", "MibIdentifier", "NotificationType", "MibScalar", "MibTable", "MibTableRow", "MibTableColumn", "TimeTicks", "enterprises")
# Objects
myCompany = MibIdentifier((1, 3, 6, 1, 4, 1, 42))
testCount = MibScalar((1, 3, 6, 1, 4, 1, 42, 1), Integer32()).setMaxAccess("readonly")
if mibBuilder.loadTexts: testCount.setDescription("A sample count of something.")
testDescription = MibScalar((1, 3, 6, 1, 4, 1, 42, 2), OctetString()).setMaxAccess("readonly")
if mibBuilder.loadTexts: testDescription.setDescription("A description of something")
# Augmentions
# Notifications
testTrap = NotificationType((1, 3, 6, 1, 4, 1, 42, 3)).setObjects(*() )
if mibBuilder.loadTexts: testTrap.setDescription("Test notification")
# Exports
# Objects
mibBuilder.exportSymbols("MY-MIB", myCompany=myCompany, testCount=testCount, testDescription=testDescription)
# Notifications
mibBuilder.exportSymbols("MY-MIB", testTrap=testTrap)
Does anyone have an idea what could have caused that exception? I've been on Google for the last few hours searching but didn't find anything valuable.
Edit: Also when using the code from http://pysnmp.sourceforge.net/examples/current/v3arch/agent/cmdrsp/v2c-custom-scalar-mib-objects.html I get a similar error:
Traceback (most recent call last):
File "agentTest2.py", line 8, in <module>
snmpEngine = engine.SnmpEngine()
File "/usr/local/lib/python2.7/dist-packages/pysnmp/entity/engine.py", line 18, in __init__
self.msgAndPduDsp = MsgAndPduDispatcher()
File "/usr/local/lib/python2.7/dist-packages/pysnmp/proto/rfc3412.py", line 24, in __init__
'SNMP-TARGET-MIB', 'SNMP-USER-BASED-SM-MIB'
File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 259, in loadModules
'MIB module \"%s\" load error: %s' % (modPath, traceback.format_exception(*sys.exc_info()))
pysnmp.smi.error.SmiError: MIB module "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-MIB.pyc" load error: ['Traceback (most recent call last):\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 255, in loadModules\n exec(modData, g)\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-MIB.py", line 10, in <module>\n ( ModuleCompliance, NotificationGroup, ObjectGroup, ) = mibBuilder.importSymbols("SNMPv2-CONF", "ModuleCompliance", "NotificationGroup", "ObjectGroup")\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 299, in importSymbols\n self.loadModules(modName, **userCtx)\n', ' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 259, in loadModules\n \'MIB module \\"%s\\" load error: %s\' % (modPath, traceback.format_exception(*sys.exc_info()))\n', 'SmiError: MIB module "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-CONF.pyc" load error: [\'Traceback (most recent call last):\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 255, in loadModules\\n exec(modData, g)\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-CONF.py", line 2, in <module>\\n MibNode, = mibBuilder.importSymbols(\\\'SNMPv2-SMI\\\', \\\'MibNode\\\')\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 299, in importSymbols\\n self.loadModules(modName, **userCtx)\\n\', \' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 259, in loadModules\\n \\\'MIB module \\\\"%s\\\\" load error: %s\\\' % (modPath, traceback.format_exception(*sys.exc_info()))\\n\', \'SmiError: MIB module "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/mibs/SNMPv2-SMI.py" load error: [\\\'Traceback (most recent call last):\\\\n\\\', \\\' File "/usr/local/lib/python2.7/dist-packages/pysnmp/smi/builder.py", line 255, in loadModules\\\\n exec(modData, g)\\\\n\\\', \\\' File "<string>", line 2\\\\n\\\', \\\' -- WinAgents MIB Extraction Wizard\\\\n\\\', \\\' ^\\\\n\\\', \\\'SyntaxError: invalid syntax\\\\n\\\']\\n\']\n']

Related

How to solve pywhatkit KeyError in pyrhon?

import pywhatkit as pwt
number=input("Enter the number: ")
msg=input("Msg: ")
pwt.sendwhatmsg_instantly(number,msg)
And then I got this error:
Traceback (most recent call last):
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 31, in
start(fakepyfile,mainpyfile)
File "/data/user/0/ru.iiec.pydroid3/files/accomp_files/iiec_run/iiec_run.py", line 30, in start
exec(open(mainpyfile).read(), main.dict)
File "", line 1, in
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/pywhatkit/init.py", line 16, in
from pywhatkit.whats import (
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/pywhatkit/whats.py", line 7, in import pyautogui as pg
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/pyautogui/init.py", line 249, in
import mouseinfo
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/site-packages/mouseinfo/init.py", line 223, in
_display = Display(os.environ['DISPLAY'])
File "/data/user/0/ru.iiec.pydroid3/files/arm-linux-androideabi/lib/python3.9/os.py", line 679, in getitem
raise KeyError(key) from None
KeyError: 'DISPLAY'
[Program finished]

i have a error in pysnmp:caused by <class 'IndexError'>: pop from empty list

i have a error in pysnmp:caused by <class 'IndexError'>: pop from empty list
I am confused. I didn't do anything,But sometimes my code doesn't work
but sometimes
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "../conpot/protocols/snmp/conpot_cmdrsp.py", line 170, in handleMgmtOperation
rspVarBinds = self.proxy.getRequest(snmp_version, oid, **user_info)
File "../conpot/protocols/snmp/snmp_proxy.py", line 65, in getRequest
ObjectIdentity(*args)
File "/usr/local/lib/python3.6/site-packages/pysnmp/entity/rfc3413/oneliner/cmdgen.py", line 183, in getCmd
**kwargs):
File "/usr/local/lib/python3.6/site-packages/pysnmp/hlapi/asyncore/sync/cmdgen.py", line 113, in getCmd
snmpEngine.transportDispatcher.runDispatcher()
File "/usr/local/lib/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 50, in runDispatcher
raise PySnmpError('poll error: %s' % ';'.join(format_exception(*exc_info())))
pysnmp.error.PySnmpError: poll error: Traceback (most recent call last):
; File "/usr/local/lib/python3.6/site-packages/pysnmp/carrier/asyncore/dispatch.py", line 46, in runDispatcher
use_poll=True, map=self.__sockMap, count=1)
; File "/usr/lib64/python3.6/asyncore.py", line 207, in loop
poll_fun(timeout, map)
; File "/usr/lib64/python3.6/asyncore.py", line 188, in poll2
readwrite(obj, flags)
; File "/usr/lib64/python3.6/asyncore.py", line 123, in readwrite
obj.handle_error()
; File "/usr/lib64/python3.6/asyncore.py", line 110, in readwrite
obj.handle_write_event()
; File "/usr/lib64/python3.6/asyncore.py", line 442, in handle_write_event
self.handle_write()
; File "/usr/local/lib/python3.6/site-packages/pysnmp/carrier/asyncore/dgram/base.py", line 142, in handle_write
outgoingMessage, transportAddress = self.__outQueue.pop()
;IndexError: pop from empty list
caused by <class 'IndexError'>: pop from empty list

Why the TypeError in the tempfile.py?

I'm importing the pltlib on Python3.7.5 by from imview.lib import pltlib.
Then I get this error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/bowen/.local/lib/python3.7/site-packages/imview/lib/pltlib.py", line 15, in <module>
cpt_rainbow = gmtColormap.get_rainbow()
File "/home/bowen/.local/lib/python3.7/site-packages/imview/lib/gmtColormap.py", line 21, in get_rainbow
fn = write_rainbow_cpt()
File "/home/bowen/.local/lib/python3.7/site-packages/imview/lib/gmtColormap.py", line 375, in write_rainbow_cpt
N 255 0 0""")
File "/usr/lib/python3.7/tempfile.py", line 620, in func_wrapper
return func(*args, **kwargs)
TypeError: a bytes-like object is required, not 'str'
I also check the source code here: github.com/python/cpython/blob/3.7/Lib/tempfile.py
But it seems that my tempfile.py is correct, so why this error happen?

evdev cannot simulate touch input

I am trying to use evdev to simulate touch input.
from evdev import UInput, AbsInfo, ecodes as e
cap = {
e.EV_KEY : [e.KEY_A, e.KEY_B],
e.EV_ABS : [
(e.ABS_X, AbsInfo(value=0, min=0, max=255,
fuzz=0, flat=0, resolution=0)),
(e.ABS_Y, AbsInfo(0, 0, 255, 0, 0, 0)),
(e.ABS_MT_POSITION_X, (0, 255, 128, 0)) ]
}
ui = UInput(cap, name='example-device', version=0x3)
Adding myself to the input group, the error is:
Traceback (most recent call last):
File "mouse.py", line 12, in <module>
ui = UInput(cap, name='example-device', version=0x3)
File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 125, in __init__
self._verify()
File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 221, in _verify
raise UInputError(msg.format(self.devnode))
evdev.uinput.UInputError: "/dev/uinput" cannot be opened for writing
After running chmod +0666 /dev/uinput the error changes to:
Traceback (most recent call last):
File "mouse.py", line 12, in <module>
ui = UInput(cap, name='example-device', version=0x3)
File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 147, in __init__
_uinput.create(self.fd, name, vendor, product, version, bustype, absinfo)
SystemError: /builddir/build/BUILD/Python-3.6.2/Objects/longobject.c:404: bad argument to internal function
Removing (e.ABS_MT_POSITION_X, (0, 255, 128, 0)):
Traceback (most recent call last):
File "mouse.py", line 12, in <module>
print(ui)
File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 171, in __str__
evtypes = [i[0] for i in self.capabilities(True).keys()]
File "/home/user/.virtualenvs/venv/lib/python3.6/site-packages/evdev/uinput.py", line 200, in capabilities
raise UInputError('input device not opened - cannot read capabilites')
evdev.uinput.UInputError: input device not opened - cannot read capabilites

I am getting assertion errors when using PYPJLINK , how could I fix them?

Pypjlink is a universal projector control API to be able to control projectors over a network. Here is a link that will contain all of the information about it: https://pypi.python.org/pypi/pypjlink. There is also a link to the repository that contains all of the files. I have been trying to get past all of the assertion errors, but I have not been having too much success. As soon as I fix one, another one is still in my way. I am simply querying the projector for the power status. Here is the code in my file:
from pypjlink import Projector
projector = Projector.from_address('10.21.24.7')
power = projector.get('POWR')
print power
This is all of my outputs from testing over the last hour or two:
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get_errors()
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 172, in get_errors
param = self.get('ERST')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 71, in send_command
resp_body, resp_param = parse_response(f)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 30, in parse_response
assert header == '%'
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('Power?')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 67, in send_command
data = to_binary(req_body, req_param)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 18, in to_binary
assert body.isupper()
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('Power')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 67, in send_command
data = to_binary(req_body, req_param)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 18, in to_binary
assert body.isupper()
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('POWER')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 67, in send_command
data = to_binary(req_body, req_param)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 20, in to_binary
assert len(body) == 4
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('POW')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 67, in send_command
data = to_binary(req_body, req_param)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 20, in to_binary
assert len(body) == 4
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('POWE')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 71, in send_command
resp_body, resp_param = parse_response(f)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 30, in parse_response
assert header == '%'
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('%POW')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 71, in send_command
resp_body, resp_param = parse_response(f)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 30, in parse_response
assert header == '%'
AssertionError
>>> -m unittest discover pypjlink.tests
SyntaxError: invalid syntax
>>> unittest discover pypjlink.tests
SyntaxError: invalid syntax
>>> discover pypjlink.tests
SyntaxError: invalid syntax
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('%POW')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 71, in send_command
resp_body, resp_param = parse_response(f)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 30, in parse_response
assert header == '%'
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('POW')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 67, in send_command
data = to_binary(req_body, req_param)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 20, in to_binary
assert len(body) == 4
AssertionError
>>>
=== RESTART: /Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py ===
Traceback (most recent call last):
File "/Users/Dustin/OneDrive/School Work/Work Study/pjlink_test.py", line 4, in <module>
power = projector.get('POWR')
File "/Library/Python/2.7/site-packages/pypjlink/projector.py", line 119, in get
success, response = protocol.send_command(self.f, body, '?')
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 71, in send_command
resp_body, resp_param = parse_response(f)
File "/Library/Python/2.7/site-packages/pypjlink/protocol.py", line 30, in parse_response
assert header == '%'
AssertionError
>>>
Some extra information: I am connecting the projector over a network with a static IP. It is a BenQ projector, and I do have a pjlink command list. If I try to send a command, it will work, but I still get that error. The program just has a hard time receiving responses.
try calling projector.authenticate('some_auth') after creating the projector object (just use a dummy name if you do not have auth.)
I would also use get_power() rather get('POWR') but you might have reasons.
With our new asyncio pjlink library (https://github.com/HEInventions/aiopjlink) you can do this within a context manager:
async with PJLink(address="10.21.24.7", password="secretpassword") as link:
print("power =", await link.power.get())

Categories