Onvif - This optional method is not implemented - python-3.x

I just bought an Imou Ranger 2C IP camera device.
I am interacting with the camera using the python-onvif-zeep python module.
I have this snippet:
from onvif import ONVIFCamera
mycam = ONVIFCamera("<camera_host>", 80, "admin", "<camera_password>")
ptz = mycam.create_ptz_service()
token = mycam.create_media_service().GetProfiles()[0].token
requesta = ptz.create_type('AbsoluteMove')
requesta.ProfileToken = token
if requesta.Position is None:
requesta.Position = ptz.GetStatus({'ProfileToken':token}).Position
requesta.Position.PanTilt.x = 0.5
requesta.Position.PanTilt.y = 0.5
ret = ptz.AbsoluteMove(requesta)
That raise the following exception:
Traceback (most recent call last):
File "/home/ricciolino/Downloads/onvif_ptz_absPosTest.py", line 15, in <module>
ret = ptz.AbsoluteMove(requesta)
File "/home/ricciolino/.local/lib/python3.10/site-packages/onvif/client.py", line 26, in wrapped
raise ONVIFError(err)
onvif.exceptions.ONVIFError: Unknown error: This optional method is not implemented
What does this mean?
My device camera Firmware is not able to handle the AbsoluteMove request? So the only option I have to move the Pan/Tilt of my device is through the ContinuousMove request?

Related

Is it possible to configure the Mindeo MP725 scanner programmatically?

I'm trying to send/read data via USB, in Windows. Using the library hid\hidapi (python). It is the only one that sees\working with the Mindeo MP725 on the system.
QR Scanner Definition Example:
{'path': b'\\\\? \HID#VID_27DDD&PID_0103#6&269d9e14&1&0000#{4d1e55b2-f16f-11cf-88cb-00111111000030}\KBD', 'vendor_id': 10205, 'product_id': 259, 'serial_number': 'S/N:E608A04AB4151A4F9C8FA887B58B3D69 Rev: NBRMIAAX1', 'release_number': 259, 'manufacturer_string': '2D BarCode Scanner', 'product_string': '2D BarCode Scanner', 'usage_page': 1, 'usage': 6, 'interface_number': -1}
Example of my code:
import ctypes
import os
ctypes.CDLL(os.path.dirname(__file__) + '\hidapi.dll')
import hid
vid = 0
pid = 0
path = ''
list_device = hid.enumerate()
for i in list_device:
if i['product_string'] == '2D BarCode Scanner':
print(i)
vid = i['vendor_id']
pid = i['product_id']
path = i['path']
with hid.Device(path=path) as h:
h.nonblocking
# print(f'Device manufacturer: {h.manufacturer}')
# print(f'Product: {h.product}')
# print(f'Serial Number: {h.serial}')
while True:
d = h.read(255)
if d:
print(d)
I get an error every time:
Traceback (most recent call last):
File "c:\Users\user\Desktop\x64\MP725.py", line 62, in <module>
d = h.read(255)
^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\hid\init__.py", line 163, in read
size = self.__hidcall(hidapi.hid_read, self.__dev, data, size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\user\AppData\Local\Programs\Python\Python311\Lib\site-packages\hid\init__.py", line 148, in __hidcall
raise HIDException(err)
hid.HIDException: ReadFile: (0x00000005) Access denied.
Does anyone know how to fix this?
I examined the errors related to accessing the library itself (but I think there is no problem with this, since all other methods work fine)
There is an impression that Windows itself prohibits managing the QR-scanner, as the device and the driver identifies it in the group together with keyboards and other input devices which can't be managed.

Moviepy: add audio to a video

I am trying to run the following code:
from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")
new_audioclip = CompositeAudioClip([videoclip.audio, audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")
but when I run it I got the following error:
*
Traceback (most recent call last): File "C:/Users/arthu/PycharmProjects/Comprei da China/video.py", line 5, in
new_audioclip = CompositeAudioClip([videoclip.audio, audioclip]) File "C:\Users\arthu\PycharmProjects\Comprei da China\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 285, in
init
ends = [c.end for c in self.clips] File "C:\Users\arthu\PycharmProjects\Comprei da China\venv\lib\site-packages\moviepy\audio\AudioClip.py", line 285, in
ends = [c.end for c in self.clips] AttributeError: 'NoneType' object has no attribute 'end'
*
Does anybody know how can I solve that?
Pass only one parameter in CompositeAudioClip the built in class AudioClip.py has one parameter
from moviepy.editor import *
videoclip = VideoFileClip("filename.mp4")
audioclip = AudioFileClip("audioname.mp3")
new_audioclip = CompositeAudioClip([audioclip])
videoclip.audio = new_audioclip
videoclip.write_videofile("new_filename.mp4")

python3 UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

I am having some issues running my program. I have a "masterfile" that has a list of ips on a \n like so but I keep getting this error message:
68.x.0.56
68.x.0.53
I'm not sure what exactly the problem is, but I've been searching forums and other stackoverflow help, but can't seem to determine what the issue is.
def dns_resolver(subdomains):
print('\n\n########## Checking Subdomains for DNS Resolutions ##########\n')
queries = []
with open ('masterfile', 'r') as f:
domains = f.read().splitlines()
for i in domains:
try:
resp = socket.gethostbyname(i)
print(resp)
queries.append((i, resp))
except socket.error:
pass
return queries
Traceback (most recent call last):
File "/usr/lib/python3.6/encodings/idna.py", line 165, in encode
raise UnicodeError("label empty or too long")
UnicodeError: label empty or too long
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "subdomain-hunter.py", line 170, in <module>
main()
File "subdomain-hunter.py", line 59, in main
enumerate(DOMAIN)
File "subdomain-hunter.py", line 120, in enumerate
resolvediff = dns_resolver(diff)
File "subdomain-hunter.py", line 142, in dns_resolver
resp = socket.gethostbyname(i)
UnicodeError: encoding with 'idna' codec failed (UnicodeError: label empty or too long)

AttributeError: type object 'object' has no attribute '__getattr__' (Ubilinux)

I'm working on a project with the Intel Edison and Mini Breakout Board with Ubilinux and when trying commend: python uart.py I get:
root#ubilinux:~# python uart.py
Traceback (most recent call last):
File "uart.py", line 7, in <module>
u.setBaudRate(115200)
File "/usr/local/lib/i386-linux-gnu/python2.7/site-packages/mraa.py", line 1355, in <lambda>
__getattr__ = lambda self, name: _swig_getattr(self, Uart, name)
File "/usr/local/lib/i386-linux-gnu/python2.7/site-packages/mraa.py", line 78, in _swig_getattr
return _swig_getattr_nondynamic(self, class_type, name, 0)
File "/usr/local/lib/i386-linux-gnu/python2.7/site-packages/mraa.py", line 73, in _swig_getattr_nondynamic
return object.__getattr__(self, name)
AttributeError: type object 'object' has no attribute '__getattr__'
And here is the Python code:
import mraa
# Initialize UART
u=mraa.Uart(0)
# Set UART parameters
u.setBaudRate(115200)
u.setMode(8, mraa.UART_PARITY_NONE, 1)
u.setFlowcontrol(False, False)
# Start a neverending loop waiting for data to arrive.
# Press Ctrl+C to get out of it.
while True:
if u.dataAvailable():
# We are doing 1-byte reads here
data_byte = u.readStr(1)
print(data_byte)
# Just a two-way half-duplex communication example, "X" is a flag
if data_byte == "X":
u.writeStr("Yes, master!")
Can someone please help me fix this issue?
Thanks in advance

Unable to use print_control_identifiers() for my desktop application in pywinauto

Hi I am unable to use the "print_control_identifiers()" for my desktop application.
I am using a) Python 3.5.3 (32 bit since my application I am automating is 32 bit)
b) Pywinauto 0.6.2.
My simple code is as follows:
`from pywinauto import Application
app = Application(backend="uia")
app = Application().start(r"C:\Program Files (x86)\Trane\TRACE 3D Plus\TRACE™ 3D Plus.exe")
app['TRACE™ 3D Plus'].print_control_identifiers()`
When I run the above command, I got the following in command prompt:
Traceback (most recent call last):
File "D:\Python\lib\site-packages\pywinauto\application.py", line 243, in __re
solve_control
criteria)
File "D:\Python\lib\site-packages\pywinauto\timings.py", line 424, in wait_until_passes
raise err
pywinauto.timings.TimeoutError
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "inspect.py", line 4, in <module>
app['TRACE\u2122 3D Plus'].print_control_identifiers()
File "D:\Python\lib\site-packages\pywinauto\application.py", line 573, in prin
t_control_identifiers
this_ctrl = self.__resolve_control(self.criteria)[-1]
File "D:\Python\lib\site-packages\pywinauto\application.py", line 246, in __re
solve_control
raise e.original_exception
File "D:\Python\lib\site-packages\pywinauto\timings.py", line 402, in wait_unt
il_passes
func_val = func(*args)
File "D:\Python\lib\site-packages\pywinauto\application.py", line 188, in __ge
t_ctrl
dialog = self.backend.generic_wrapper_class(findwindows.find_element(**crite
ria[0]))
File "D:\Python\lib\site-packages\pywinauto\findwindows.py", line 84, in find_
element
elements = find_elements(**kwargs)
File "D:\Python\lib\site-packages\pywinauto\findwindows.py", line 294, in find
_elements
elements = findbestmatch.find_best_control_matches(best_match, wrapped_elems
)
File "D:\Python\lib\site-packages\pywinauto\findbestmatch.py", line 534, in fi
nd_best_control_matches
raise MatchError(items = name_control_map.keys(), tofind = search_text)
pywinauto.findbestmatch.MatchError: Could not find 'TRACE\u2122 3D Plus' in 'dic
t_keys([])'
Can anyone tell me what the problem is and what I could do to resolve it ?
Thanks in advance !
Replace these commands
app = Application(backend="uia")
app = Application().start(r"C:\Program Files (x86)\Trane\TRACE 3D Plus\TRACE™ 3D Plus.exe")
with this one:
app = Application(backend="uia").start(r'"C:\Program Files (x86)\Trane\TRACE 3D Plus\TRACE™ 3D Plus.exe"')
Because you re-create app object with default backend="win32" if not using any argument. If it's hard to understand, I'd recommend to get a Python course first. Basic Python programming skills is necessary here to understand what's going on.

Resources