ZoneMinder / pyzm

Python API, Log, Event Server and Memory wrapper for ZoneMinder
GNU General Public License v2.0
31 stars 20 forks source link

Unable to add a monitor #8

Closed tranzmatt closed 4 years ago

tranzmatt commented 4 years ago

I'm trying to test your pyzm functionality, but when I try to add a monitor using the example program with a basic call, eg:

print ("--------| Getting Monitors |-----------")
ms = zmapi.monitors()
for m in ms.list():
    print ('Name:{} Enabled:{} Type:{} Dims:{}'.format(m.name(), m.enabled(), m.type(), m.dimensions()))
    print (m.status())

zmapi.monitors().add()

I'm getting the following error. I don't see anything in the docs about an 'api_url' field in the docs, but it seems to reference it in the code.

Running examples on http://192.168.1.247/zm/api
Try monitor shared memory tests? [y/N]n
Test the Event Server? [y/N]n
[INFO] Using simple log output (default)
[DEBUG 1] Not using auth
[DEBUG 1] make_request called with url=http://192.168.1.247/zm/api/host/gettimezone.json payload={} type=get query={}
[INFO] Using simple log output (default)
[DEBUG 1] Retrieving monitors via API
[DEBUG 1] make_request called with url=http://192.168.1.247/zm/api/monitors.json payload={} type=get query={}
[INFO] Using simple log output (default)
[DEBUG 1] Retrieving config via API
[DEBUG 1] make_request called with url=http://192.168.1.247/zm/api/configs.json payload={} type=get query={}
--------| Getting Monitors |-----------
Name:CAM1 Enabled:True Type:Remote Dims:{'width': 1920, 'height': 1080}
[DEBUG 1] make_request called with url=http://192.168.1.247/zm/api/monitors/daemonStatus/id:1/daemon:zmc.json payload={} type=get query={}
{'status': True, 'statustext': "'zmc -m 1' running since 20/07/01 14:10:28, pid = 776"}
Traceback (most recent call last):
  File "my-example.py", line 142, in <module>
    zmapi.monitors().add()
  File "/export/home/mclark/Code/Zoneminder/pyzm/pyzm/helpers/Monitors.py", line 60, in add
    url = self.api_url+'/monitors/.json'
AttributeError: 'Monitors' object has no attribute 'api_url'
tranzmatt commented 4 years ago

The offending line seems to be fixed at line 60 with:

url = self.api.api_url+'/monitors/.json'

pliablepixels commented 4 years ago

Thanks. Fixed via https://github.com/pliablepixels/pyzm/commit/e2a7467949e83abcb58ec09f2804cfc28559b828#diff-6b0988019b573b33c90e3563a61988a4

tranzmatt commented 4 years ago

The bug remains...

Line 60 needs to be:

url = self.api.api_url+'/monitors.json'

Line 22 has it correct.

pliablepixels commented 4 years ago

fixed