python 的异常和错误推送通知
Exception & Error push notification with python
我是运行一个不同电子设备的实验。我有用于远程收集数据的脚本(以后命名为“MyScript”,Python3.7 和 W10)。重点是需要几个小时,有时会出现ExceptionError、SysError或KeyboardInterrupt,脚本明显停止。
我的想法是使用推送通知,如果发生任何错误和异常,到我的手机 phone 这样我就可以重新启动脚本而不是浪费时间。但是我不知道如何编码...我想应该是这样的:
SendPushNotification():
"This function sends the notification"
if "any Exception, Error or TimeOut occurs":
#MyScript
SendPushNotification():
非常感谢你,我会很感激你的想法!
我使用以下方法解决了它:
try:
MainScript()
except (RuntimeError, TypeError, NameError):
PushNotification("An ERROR has occured!!!")
DoSomething1()
DoAnotherThing()
我是运行一个不同电子设备的实验。我有用于远程收集数据的脚本(以后命名为“MyScript”,Python3.7 和 W10)。重点是需要几个小时,有时会出现ExceptionError、SysError或KeyboardInterrupt,脚本明显停止。
我的想法是使用推送通知,如果发生任何错误和异常,到我的手机 phone 这样我就可以重新启动脚本而不是浪费时间。但是我不知道如何编码...我想应该是这样的:
SendPushNotification():
"This function sends the notification"
if "any Exception, Error or TimeOut occurs":
#MyScript
SendPushNotification():
非常感谢你,我会很感激你的想法!
我使用以下方法解决了它:
try:
MainScript()
except (RuntimeError, TypeError, NameError):
PushNotification("An ERROR has occured!!!")
DoSomething1()
DoAnotherThing()