###################################################
opc = OpenOPC.client()
servers = opc.servers()
opc.connect("Owen.OPCNet.DA.1")
print("Удачное подключение к " + servers[0])
#--------------------------------------------------------------------------------------------------------#
tagsValue = [];
# Тр-ра Верх
tagsValue.append(opc.list("COM4.TRM_202(adr=104)T_слой_Ср_р-ра.Оперативные параметры")[3])
while True:
print("-----------------------------------------------------------------------------------------")
try:
############################################################
# Проверка температур слоя реактора
val = opc.read(tagsValue, update=1, include_error=True)
if int(val[0][1]) > (react_temp + r_tmp_lim) or int(val[1][1]) > (react_temp + r_tmp_lim) or int(val[2][1]) > (react_temp + r_tmp_lim):
try:
#print("here")
send_telegram("Слой реактора перегрет до {0:.2f} {1:.2f} {2:.2f} С".format(val[0][1], val[1][1], val[2][1]))
except:
print("Включите VPN (test 1)")
if int(val[0][1]) < (react_temp - r_tmp_lim) or int(val[1][1]) < (react_temp - r_tmp_lim) or int(val[2][1]) < (react_temp - r_tmp_lim):
except:
print("error read item")
time.sleep(20)
opc.close()
#---------------------------#
if __name__ == '__main__':
while True:
try:
bot.polling(none_stop=True)
except Exception as e:
time.sleep(3)
print(e)
photo = open('путь_к_фото', 'rb')
bot.send_photo(chat_id, photo)
@bot.message_handler(content_types=['photo'])
r = sr.Recognizer()
with sr.Microphone() as source:
print('Можна говорити')
r.pause_threshold = 1
r.adjust_for_ambient_noise(source, duration=1)
audio = r.listen(source)
try:
result = r.recognize_google(audio, language="uk-UA").lower()
print("Ви сказали: " + result)
except sr.UnknownValueError:
result = cmmd()
return zadanie
def read(sender_of_interest=None):
imap = imaplib.IMAP4_SSL("imap.gmail.com", 993)
imap.login('Почта', 'пароль')
imap.select('INBOX')
if sender_of_interest:
status, response = imap.uid('search', None, 'UNSEEN', 'FROM {0}'.format(sender_of_interest))
else:
status, response = imap.uid('search', None, 'UNSEEN')
if status == 'OK':
unread_msg_nums = response[0].split()
else:
unread_msg_nums = []
data_list = []
for e_id in unread_msg_nums:
e_id = e_id.decode('utf-8')
_, response = imap.uid('fetch', e_id, '(RFC822)')
html = response[0][1].decode('utf-8')
email_message = email.message_from_string(html)
data_list.append(email_message.get_payload())
for elem in data_list:
clean_html(elem)