import server
import requests
import json
#1st get
zapros = requests.get( server.FullZap, auth=(server.login, server.password) )
jsonDATA = json.loads( zapros.text )
#1st message
num = 4
Number0 = jsonDATA['value'][num]['Number']
Summ0 = jsonDATA['value'][num]['СуммаДокумента']
print(Number0 + '\n' + str(Summ0))
for value in jsonDATA['value'][num]['Работы']:
work = value['Номенклатура_Key']
get = f"http://192.168.100.200/TOOUT/odata/standard.odata/Catalog_Номенклатура(guid'{work}')?$format=json"
zaprosWORK = requests.get( get, auth=(server.login, server.password) )
jsonWORK = json.loads( zaprosWORK.text )
sotr = jsonWORK['Description']
print(sotr)
"C:\Program Files (x86)\Python38-32\python.exe" C:/Users/сергей/Desktop/tgbot/telov1.py
УТ01-000195
115000
диагностика ДВС
Компьютерная диагностика Bosch
Process finished with exit code 0
num = 2
Number0 = jsonDATA['value'][num]['Number']
print(Number0)
Summ0 = jsonDATA['value'][num]['СуммаДокумента']
Work0, Work01, Work02 = ([ x['Номенклатура_Key'] for x in jsonDATA['value'][num]['Работы']] +[""]*3)[:3]
guid0 = "guid'" + Work0 + "'"
guid01 = "guid'" + Work01 + "'"
guid02 = "guid'" + Work02 + "'"
get0 = "http://192.168.100.200/TOOUT/odata/standard.odata/Catalog_Номенклатура(" + guid0 + ")?$format=json"
get01 = "http://192.168.100.200/TOOUT/odata/standard.odata/Catalog_Номенклатура(" + guid01 + ")?$format=json"
get02 = "http://192.168.100.200/TOOUT/odata/standard.odata/Catalog_Номенклатура(" + guid02 + ")?$format=json"
zaprosWORK0 = requests.get( get0, auth=(server.login, server.password) )
zaprosWORK01 = requests.get( get01, auth=(server.login, server.password) )
zaprosWORK02 = requests.get( get02, auth=(server.login, server.password) )
jsonWORK0 = json.loads( zaprosWORK0.text )
jsonWORK01 = json.loads( zaprosWORK01.text )
jsonWORK02 = json.loads( zaprosWORK02.text )
sotr0 = jsonWORK0['Description']
sotr01 = jsonWORK01['Description']
sotr02 = jsonWORK02['Description']
print(Work01 + '\n' + Work01 + '\n' + Work02)
print(sotr0 + '\n' + sotr01 + '\n' + sotr02)
File "C:/Users/сергей/Desktop/tgbot/telo.py", line 29, in <module>
sotr0 = jsonWORK0['Description']
KeyError: 'Description'
"C:\Program Files (x86)\Python38-32\python.exe" C:/Users/сергей/Desktop/tgbot/telo.py
УТ01-000198
1e9c8ba3-e025-11e9-80d0-0cc47ab518ab
1e9c8ba3-e025-11e9-80d0-0cc47ab518ab
57a34ddf-0c35-11e2-90b2-0019213992ed
слить залить охлаждающую жидкость
Заменить прокладку уплотнительную головки цилиндра (головка цилиндра снята)
Услуги по ремонту электрики
Process finished with exit code 0
PS C:\Users\сергей\Desktop\tgbot> python botv1.py
УТ01-000200
PS C:\Users\сергей\Desktop\tgbot>
def zapros():
zapros = requests.get( server.FullZap, auth=(server.login, server.password) )
jsonDATA = json.loads( zapros.text )
num = 0
print(jsonDATA['value'][num]['Number'])
telebot.apihelper.ApiException: A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}']
"
2020-09-22 11:40:12,252 (__init__.py:443 MainThread) ERROR - TeleBot: "A request to the Telegram API was unsuccessful. The server returned HTTP 409 Conflict. Response body:
[b'{"ok":false,"error_code":409,"description":"Conflict: terminated by other getUpdates request; make sure that only one bot instance is running"}']"
PS C:\Users\сергей\Desktop\tgbot> python botv1.py
None
PS C:\Users\сергей\Desktop\tgbot>
sotr = jsonWORK['Description']
print(sotr)
всё работает в режиме цикла, то когда пытаешься запустить это всё вместе с ботом от отдает только самую крайнюю работу которая записалась в переменную)