FalkTannhaeuser / python-onvif-zeep

ONVIF Client Implementation in Python 2+3 (using https://github.com/mvantellingen/python-zeep instead of suds as SOAP client)
MIT License
424 stars 138 forks source link

time_params.TimeZone.TZ = 'CST-8:00:00' AttributeError: 'NoneType' object has no attribute 'TZ' #40

Open ZENGjunxian opened 5 years ago

ZENGjunxian commented 5 years ago

time_params = mycam.devicemgmt.create_type('SetSystemDateAndTime') time_params.DateTimeType = 'Manual' time_params.DaylightSavings = True time_params.TimeZone.TZ = 'CST-8:00:00'

time_params.UTCDateTime.Date.Year = 2014

time_params.UTCDateTime.Date.Month = 12

time_params.UTCDateTime.Date.Day = 3

time_params.UTCDateTime.Time.Hour = 9

time_params.UTCDateTime.Time.Minute = 36

time_params.UTCDateTime.Time.Second = 11

mycam.devicemgmt.SetSystemDateAndTime(time_params)

Traceback (most recent call last): File "/home/zjx1/tool/pycharm-community-2018.3.5/helpers/pydev/pydevd.py", line 1741, in main() File "/home/zjx1/tool/pycharm-community-2018.3.5/helpers/pydev/pydevd.py", line 1735, in main globals = debugger.run(setup['file'], None, None, is_module) File "/home/zjx1/tool/pycharm-community-2018.3.5/helpers/pydev/pydevd.py", line 1135, in run pydev_imports.execfile(file, globals, locals) # execute the script File "/home/zjx1/tool/pycharm-community-2018.3.5/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/zjx1/PycharmProjects/zjx_test/camera_test.py", line 27, in time_params.TimeZone.TZ = 'CST-8:00:00' AttributeError: 'NoneType' object has no attribute 'TZ'

wxwisgood commented 5 years ago

I have same question?how do you solve it?thanks

OptimusGREEN commented 3 years ago

yup same here.

Phyks commented 2 years ago

Fwiw, I managed to work around this with the following snippet:

time_params = mycam.devicemgmt.create_type('SetSystemDateAndTime')
time_params.DateTimeType = 'Manual'
time_params.DaylightSavings = False
time_params.TimeZone = 'GMT+01:00'
time_params.UTCDateTime = mycam.devicemgmt.GetSystemDateAndTime().UTCDateTime
# Adjust UTCDateTime if required
mycam.devicemgmt.SetSystemDateAndTime(time_params)
SYM-TCM commented 1 year ago
time_params = mycam.devicemgmt.create_type('SetSystemDateAndTime')
time_params.DateTimeType = 'Manual'
time_params.DaylightSavings = True

TZ = {'TZ':'CST-8:00:00'}
time_params.TimeZone = TZ

Data = {'Year':2022,'Month':8,'Day':18}
Time = {'Hour':8,'Minute':8,'Second':8}
UTC = {'Date':Data,'Time':Time}

time_params.UTCDateTime = UTC
t1 = mycam.devicemgmt.SetSystemDateAndTime(time_params)

这是可以的