本文整理汇总了Python中ext.getException函数的典型用法代码示例。如果您正苦于以下问题:Python getException函数的具体用法?Python getException怎么用?Python getException使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getException函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _setProperties
def _setProperties (self):
try:
self.indent = 0
self.isRunning = False
self.isPaused = False
self.activeZone = 0
self.pausedZone = 0
self.scheduleStartTime = None
self.scheduleEndTime = None
self.scheduleRunTime = 0
self.scheduleMinutesRemaining = 0
self.scheduleMinutesComplete = 0
self.schedulePercentCompleted = 0
self.schedulePercentRemaining = 0
self.scheduleZonesComplete = 0
self.scheduleZonesRemaining = 0
self.zoneStartTime = None
self.zoneEndTime = None
self.zoneRunTime = 0
self.zoneMinutesRemaining = 0
self.zoneMinutesComplete = 0
self.zonePercentCompleted = 0
self.zonePercentRemaining = 0
self.pauseStartTime = None
self.pauseEndTime = None
self.isResuming = False
except Exception as e:
self.logger.error (ext.getException(e))
示例2: removeDevice
def removeDevice (self, obj):
try:
self.logger.threaddebug ("Removing '{0}' and any references from cache".format(obj.name))
self.items.remove(obj)
except Exception as e:
self.logger.error (ext.getException(e))
示例3: deviceUpdated
def deviceUpdated (self, origDev, newDev):
try:
if self.isFinishedLoading():
pass
else:
return
if newDev.pluginId == self.factory.plugin.pluginId:
if len(origDev.pluginProps) > 0:
self.pluginDeviceUpdated (origDev, newDev)
elif len(origDev.pluginProps) == 0 and len(newDev.pluginProps) == 0 and newDev.deviceTypeId != "":
self.pluginDeviceBegun (newDev)
elif len(origDev.pluginProps) == 0 and len(newDev.pluginProps) > 0:
self.pluginDeviceCreated (newDev)
else:
# It's not a plugin device, see if it's a cache device
if "cache" in dir(self.factory):
ret = self.factory.cache.watchedItemChanges (origDev, newDev)
for change in ret:
self.logger.debug ("'{0}' {1} '{2}' has changed".format(newDev.name, change.type, change.name))
if change.itemType == "Device":
if change.type == "state": self._callBack (NOTHING, [origDev, newDev, change], "onWatchedStateChanged")
if change.type == "property": self._callBack (NOTHING, [origDev, newDev, change], "onWatchedPropertyChanged")
if change.type == "attribute": self._callBack (NOTHING, [origDev, newDev, change], "onWatchedAttributeChanged")
except Exception as e:
self.logger.error (ext.getException(e))
示例4: deviceStartComm
def deviceStartComm (self, dev):
try:
self.logger.threaddebug ("Starting communications on '{0}'".format(dev.name))
self._callBack (BEFORE, [dev])
self.deviceStateUpgrade (dev) # Do this before committing state changes in case we need to upgrade or migrate
dev.stateListOrDisplayStateIdChanged() # Commit any state changes
if ext.valueValid (dev.states, "lastreset"):
if ext.valueValid (dev.states, "lastreset", True) == False: dev.updateStateOnServer("lastreset", indigo.server.getTime().strftime("%Y-%m-%d"))
self.addPluginDeviceToCache (dev)
# If the name has "copy" as the last word in the name, check if this might have been copied from another device,
# but this can only happen after we are already up and running
#i = string.find (dev.name, "copy")
#if i > -1:
# if self.isFinishedLoading():
# indigo.server.log("copy")
self._callBack (AFTER, [dev])
if self.lastDeviceLoaded: self.lastDeviceLoaded = indigo.server.getTime().strftime("%Y-%m-%d %H:%M:%S")
except Exception as e:
self.logger.error (ext.getException(e))
示例5: getWatchList
def getWatchList (self):
ret = {}
ret["states"] = []
ret["attribs"] = []
try:
ret["states"].append ("activeZone")
ret["states"].append ("zone1")
ret["states"].append ("zone2")
ret["states"].append ("zone3")
ret["states"].append ("zone4")
ret["states"].append ("zone5")
ret["states"].append ("zone6")
ret["states"].append ("zone7")
ret["states"].append ("zone8")
ret["attribs"].append ("displayStateValRaw")
ret["attribs"].append ("displayStateValUi")
ret["attribs"].append ("enabled")
ret["attribs"].append ("pausedScheduleRemainingZoneDuration")
ret["attribs"].append ("pausedScheduleZone")
ret["attribs"].append ("zoneCount")
ret["attribs"].append ("zoneEnableList")
ret["attribs"].append ("zoneMaxDurations")
ret["attribs"].append ("zoneNames")
ret["attribs"].append ("zoneScheduledDurations")
except Exception as e:
self.logger.error (ext.getException(e))
return ret
示例6: pluginMenuSupportInfo
def pluginMenuSupportInfo (self, returnString = False):
try:
ret = ""
ret += self.factory.ui.debugHeader (self.factory.plugin.pluginDisplayName)
ret += self.factory.ui.debugLine (" ")
ret += self.factory.ui.debugLine ("Plugin Version : {0}".format(self.factory.plugin.pluginVersion))
ret += self.factory.ui.debugLine ("Template Version : {0}".format(self.factory.plugin.TVERSION))
ret += self.factory.ui.debugLine ("Core Engine Version : {0}".format(self.factory.VERSION))
ret += self.factory.ui.debugLine ("Indigo Version : {0}".format(indigo.server.version))
ret += self.factory.ui.debugLine ("Indigo API Version : {0}".format(indigo.server.apiVersion))
ret += self.factory.ui.debugLine (" ")
if returnString: return ret
ret += self.factory.ui.debugLine ("Alphas, Betas and Pre-Releases can be downloaded from:")
ret += self.factory.ui.debugLine (" https://github.com/Colorado4Wheeler")
ret += self.factory.ui.debugLine (" ")
ret += self.factory.ui.debugLine ("All support inquiries, questions or comments go to:")
ret += self.factory.ui.debugLine (" http://forums.indigodomo.com/viewforum.php?f=192")
ret += self.factory.ui.debugLine (" ")
ret += self.factory.ui.debugLine ("Copyright (c) 2017 - Colorado4Wheeler & EPS")
ret += self.factory.ui.debugLine (" ")
ret += self.factory.ui.debugHeaderEx ()
self.logger.info (ret)
except Exception as e:
self.logger.error (ext.getException(e))
示例7: _updateFromSchedule
def _updateFromSchedule (self):
try:
scheduledTimes = []
if len(self.dev.zoneScheduledDurations) > 0:
scheduledTimes = self.dev.zoneScheduledDurations
else:
scheduledTimes = self.dev.zoneMaxDurations
totalTime = 0
zoneTime = 0
zoneIdx = 1 # 1 based since activeZone is 1 based
for i in scheduledTimes:
if zoneIdx < self.dev.activeZone:
zoneIdx = zoneIdx + 1
continue
totalTime = totalTime + i
if zoneIdx == self.dev.activeZone: zoneTime = i
zoneIdx = zoneIdx + 1
self.scheduleStartTime = indigo.server.getTime()
self.zoneStartTime = indigo.server.getTime()
self.scheduleRunTime = totalTime
self.zoneRunTime = zoneTime
self.scheduleEndTime = dtutil.dateAdd ("minutes", totalTime, self.scheduleStartTime)
self.zoneEndTime = dtutil.dateAdd ("minutes", zoneTime, self.zoneStartTime)
except Exception as e:
self.logger.error (ext.getException(e))
示例8: remove
def remove (self, obj):
removeItems = []
try:
for id, objinfo in self.items.iteritems():
if id == obj.id:
removeItems.append(obj.id) # This parent device will be removed
# Go through all items that we are watching
for winfo in objinfo.watching:
newChildWatchedBy = []
child = self.items[winfo.id] # This record should be there if we are watching something
#indigo.server.log(unicode(child.id) + " - " + child.name)
for cinfo in child.watchedBy:
if cinfo.id != obj.id: newChildWatchedBy.append(cinfo)
child.watchedBy = newChildWatchedBy
if len(child.watching) == 0 and len(child.watchedBy) == 0:
removeItems.append(child.id) # Remove child if watched by if it's not watching or being watched
for id in removeItems:
self.logger.threaddebug ("Cache item '{0}' is no longer referenced by anything, removing from cache".format(self.items[id].name))
del self.items[id]
except Exception as e:
self.logger.error (ext.getException(e))
示例9: _callBack
def _callBack (self, type, args, funcname = None):
retval = None
try:
caller = sys._getframe(1).f_code.co_name
if funcname is None:
prefix = "onBefore_"
if type == AFTER: prefix = "onAfter_"
funcname = prefix + caller
if funcname in dir(self.factory.plugin):
if caller != "runConcurrentThread":
self.logger.threaddebug ("Raising {0} in plugin.py from call to {1}".format(funcname, caller))
func = getattr(self.factory.plugin, funcname)
if len(args) > 0:
retval = func(*args)
else:
retval = func()
return retval
except Exception as e:
self.logger.error (ext.getException(e))
return retval
示例10: closedActionConfigUi
def closedActionConfigUi(self, valuesDict, userCancelled, typeId, deviceId):
try:
# We don't get the action information here, only the device ID if a device was selected
if deviceId != 0:
dev = indigo.devices[deviceId]
if userCancelled:
self.logger.threaddebug ("Action group referencing '{0}' dialog cancelled".format(dev.name))
else:
self.logger.threaddebug ("Action group referencing '{0}' dialog closed".format(dev.name))
else:
if userCancelled:
self.logger.threaddebug ("Action group configuration dialog cancelled")
else:
self.logger.threaddebug ("Action group configuration dialog closed")
self._callBack (BEFORE, [valuesDict, userCancelled, typeId, deviceId])
# Make sure we've flushed the cache for this device
self.factory.ui.flushCache (deviceId)
if ext.valueValid (valuesDict, "uniqueIdentifier", True): self.factory.ui.flushCache (int(valuesDict["uniqueIdentifier"]))
self._callBack (AFTER, [valuesDict, userCancelled, typeId, deviceId])
except Exception as e:
self.logger.error (ext.getException(e))
示例11: validatePrefsConfigUi
def validatePrefsConfigUi(self, valuesDict):
errorDict = indigo.Dict()
success = True
try:
self.logger.threaddebug ("Validating plugin configuration")
retval = self._callBack (BEFORE, [valuesDict])
if retval is not None:
if "success" in retval: success = retval["success"]
if "valuesDict" in retval: valuesDict = retval["valuesDict"]
if "errorDict" in retval: errorDict = retval["errorDict"]
retval = self._callBack (AFTER, [valuesDict])
if retval is not None:
if "success" in retval: success = retval["success"]
if "valuesDict" in retval: valuesDict = retval["valuesDict"]
if "errorDict" in retval: errorDict = retval["errorDict"]
except Exception as e:
self.logger.error (ext.getException(e))
return (success, valuesDict, errorDict)
示例12: _cleanReturnList
def _cleanReturnList (self, dirtyList):
ret = []
try:
lastRetItem = ""
for i in range (0, len(dirtyList)):
try:
if lastRetItem != "":
if lastRetItem == dirtyList[i]: continue # don't add successive duplicates (mostly lines)
if dirtyList[i] != "": lastRetItem = dirtyList[i]
if dirtyList[i] is not None and dirtyList[i] != "": ret.append(dirtyList[i])
except:
continue
if len(ret) > 0:
# Make sure we don't start on a line
if ret[0] == ("-line-", self.factory.ui.getSeparator()):
del ret[0]
# Make sure we don't end on a line
if len(ret) > 0 and ret[len(ret) - 1] == ("-line-", self.factory.ui.getSeparator()):
del ret[len(ret) - 1]
return ret
except Exception as e:
self.logger.error (ext.getException(e))
return dirtyList
示例13: runConcurrentThread
def runConcurrentThread(self):
try:
if self.isRunning or self.isPaused:
update = None
self._refresh()
# Do our calculations
self.scheduleMinutesRemaining = round (dtutil.dateDiff ("minutes", self.scheduleEndTime, indigo.server.getTime()), 2)
self.zoneMinutesRemaining = round (dtutil.dateDiff ("minutes", self.zoneEndTime, indigo.server.getTime()), 2)
self.scheduleMinutesComplete = round (self.scheduleRunTime - self.scheduleMinutesRemaining, 2)
self.zoneMinutesComplete = round (self.zoneRunTime - self.zoneMinutesRemaining, 2)
self.schedulePercentRemaining = int(round(self.scheduleMinutesRemaining / self.scheduleRunTime, 2) * 100)
if self.zoneRunTime > 0:
self.zonePercentRemaining = int(round(self.zoneMinutesRemaining / self.zoneRunTime, 2) * 100)
else:
self.logger.info ("The zone run time is zero, unable to calculate time remaining. This is not a critical problem and may only indicate that you stopped a sprinkler that wasn't running.")
self.schedulePercentComplete = 100 - self.schedulePercentRemaining
self.zonePercentComplete = 100 - self.zonePercentRemaining
# Raise the event on the plugin
update = self.parent.factory.raiseEvent ("onSprinklerProgressChanged", [self, self.SprinklerDeviceExUpdate()])
update = self.parent.factory.raiseEvent ("onZoneProgressChanged", [self, self.SprinklerDeviceExUpdate()])
self._processUpdateRecord (update)
except Exception as e:
self.logger.error (ext.getException(e))
示例14: getActionUIList
def getActionUIList (self, obj, showUIConfig = False):
ret = []
try:
data = self._resolveObject (obj)
if len(data[0]) == 0: return ret
plugInfo = data[0]
deviceTypeId = data[1]
if "xml" in plugInfo == False: return ret
#if "actions" in plugInfo["xml"] == False: return ret
if "actions" in plugInfo["xml"]:
pass
else:
return ret
if deviceTypeId[0:7] == "indigo.":
ret = self._getActionUIList (plugInfo, deviceTypeId, showUIConfig, "indigo_")
else:
ret = self._getActionUIList (plugInfo, deviceTypeId, showUIConfig)
# Add Indigo actions as long as this was not already done above
if deviceTypeId[0:7] != "indigo.":
data = self._resolveIndigoDevice (obj)
retEx = self._getActionUIList (data[0], data[1], showUIConfig, "indigo_")
retEx.append (("-line-", self.factory.ui.getSeparator()))
ret = retEx + ret
except Exception as e:
self.logger.error (ext.getException(e))
return self._cleanReturnList (ret)
示例15: _getActionUIList
def _getActionUIList (self, plugInfo, deviceTypeId, showUIConfig, prefix = "plugin_"):
ret = []
try:
# Run through every device action and add a placeholder, we'll clean up after
for id, action in plugInfo["xml"]["actions"].iteritems():
ret.append ("")
for id, action in plugInfo["xml"]["actions"].iteritems():
isOk = True
if "DeviceFilter" in action:
isOk = self._isForDevice (plugInfo, deviceTypeId, action["DeviceFilter"])
if "ConfigUI" in action:
if showUIConfig == False and len(action["ConfigUI"]) > 0: isOk = False
if isOk:
if action["Name"] == " - ":
option = ("-line-", self.factory.ui.getSeparator())
ret[action["SortOrder"]] = option
else:
option = (prefix + id, action["Name"])
ret[action["SortOrder"]] = option
except Exception as e:
self.logger.error (ext.getException(e))
return ret