Все должно работать, осталось отправить запрос на закрытие задания
This commit is contained in:
parent
5a7bd2408b
commit
d5f72de57e
BIN
data/.DS_Store
vendored
Normal file
BIN
data/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
data/domreshetnikovo@gmail.com/.DS_Store
vendored
Normal file
BIN
data/domreshetnikovo@gmail.com/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
data/domreshetnikovo@gmail.com/6/.DS_Store
vendored
Normal file
BIN
data/domreshetnikovo@gmail.com/6/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
data/osa212@mail.ru/.DS_Store
vendored
Normal file
BIN
data/osa212@mail.ru/.DS_Store
vendored
Normal file
Binary file not shown.
BIN
data/osa212@mail.ru/6/.DS_Store
vendored
Normal file
BIN
data/osa212@mail.ru/6/.DS_Store
vendored
Normal file
Binary file not shown.
47
knd_bot.py
47
knd_bot.py
@ -14,24 +14,6 @@ from classes.users import Users
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
# anwer_text = '{"question_chains":[{"id":6145,"questions":[{"id":6559,"question_components":[]}]},{"id":6147,"questions":[{"id":6561,"question_components":[]}]},{"id":6147,"questions":[{"id":6561,"question_components":[]}]},{"id":6147,"questions":[{"id":6561,"question_components":[]}]},{"id":6147,"questions":[{"id":6561,"question_components":[]}]}]}'
|
|
||||||
|
|
||||||
# question_text = ''
|
|
||||||
|
|
||||||
|
|
||||||
#def get_enterance_and_coord(session, headers, execution_id):
|
|
||||||
# photo_id = send_image(session, headers, execution_id)
|
|
||||||
# pass
|
|
||||||
|
|
||||||
|
|
||||||
def send_execution(task, session, headers):
|
|
||||||
# answers_for_data = [{"id":6145,"questions":[{"id":6559,"question_components":[{"id":18850,"answer":[80634165],"answer_status":null,"end_time":1591866979,"start_time":1591866978},{"id":18851,"answer":{"location":[56.439337,36.557897]},"answer_status":null,"start_time":1591866873,"end_time":1591867165}]}]}]
|
|
||||||
# print(task)
|
|
||||||
# print(time.ctime(1592235230))
|
|
||||||
string1 = '{"id":6145,"questions":[{"id":6559,"question_components":[{"id":18850,"answer":[80634165],"answer_status":null,"end_time":1591866979,"start_time":1591866978},{"id":18851,"answer":{"location":[56.439337,36.557897]},"answer_status":null,"start_time":1591866873,"end_time":1591867165},{"id":18852,"answer":"1","answer_status":null,"start_time":1591867063,"end_time":1591867063}]}]}'
|
|
||||||
# get_questions(task.get('id'), session, headers)
|
|
||||||
print(json.dumps(json.loads(string1), indent=4))
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_questions(id_task, session, headers):
|
def get_questions(id_task, session, headers):
|
||||||
@ -47,11 +29,9 @@ def send_image(session, headers, url, photo):
|
|||||||
files = {
|
files = {
|
||||||
'image': (photo[-5:], open(photo, 'rb')),
|
'image': (photo[-5:], open(photo, 'rb')),
|
||||||
}
|
}
|
||||||
|
print(photo)
|
||||||
img = session.post('https://knd.mosreg.ru//api/v1/executions/'+str(url)+'/images', headers=headers, files=files)
|
img = session.post('https://knd.mosreg.ru//api/v1/executions/'+str(url)+'/images', headers=headers, files=files)
|
||||||
return img.json()
|
return img.json()
|
||||||
# print(img.headers)
|
|
||||||
# print(img.text)
|
|
||||||
# print(img.status_code)
|
|
||||||
|
|
||||||
|
|
||||||
def complete_task(session, headers, task, address):
|
def complete_task(session, headers, task, address):
|
||||||
@ -79,7 +59,6 @@ def complete_task(session, headers, task, address):
|
|||||||
answer_chain.update({'questions': comp})
|
answer_chain.update({'questions': comp})
|
||||||
data.append(answer_chain)
|
data.append(answer_chain)
|
||||||
if len(data) == len(photos):
|
if len(data) == len(photos):
|
||||||
print('1')
|
|
||||||
for chain in data:
|
for chain in data:
|
||||||
for item in chain['questions']:
|
for item in chain['questions']:
|
||||||
if len(data) == len(photos):
|
if len(data) == len(photos):
|
||||||
@ -112,8 +91,6 @@ def get_photo(address, email):
|
|||||||
for images in os.listdir(main_path):
|
for images in os.listdir(main_path):
|
||||||
photos.append(main_path + '/' + images)
|
photos.append(main_path + '/' + images)
|
||||||
return photos
|
return photos
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_addresses(email):
|
def get_addresses(email):
|
||||||
@ -162,7 +139,7 @@ def get_task(session, headers):
|
|||||||
)
|
)
|
||||||
for address in addresses:
|
for address in addresses:
|
||||||
# need split enterance from address
|
# need split enterance from address
|
||||||
search = 'Майданово п, Радищева ул, 73'#address[:-4]
|
search = address[:-4]
|
||||||
print(search)
|
print(search)
|
||||||
data = {'search': search}
|
data = {'search': search}
|
||||||
tasks = session_t.post('https://knd.mosreg.ru//api/v1/executions',
|
tasks = session_t.post('https://knd.mosreg.ru//api/v1/executions',
|
||||||
@ -213,16 +190,16 @@ def main():
|
|||||||
'uid': response.headers.get('uid'),
|
'uid': response.headers.get('uid'),
|
||||||
}
|
}
|
||||||
if response.status_code == 200:
|
if response.status_code == 200:
|
||||||
task = {
|
# task = {
|
||||||
'id': 23607882,
|
# 'id': 23607882,
|
||||||
'address': 'Решетниково рп, ОПМС-1 проезд, 13',
|
# 'address': 'Решетниково рп, ОПМС-1 проезд, 13',
|
||||||
'enterance': 6,
|
# 'enterance': 6,
|
||||||
'coord': [56.442503, 36.5596493]
|
# 'coord': [56.442503, 36.5596493]
|
||||||
}
|
# }
|
||||||
address = 'Решетниково рп, ОПМС-1 проезд, 13, 6п'
|
# address = 'Решетниково рп, ОПМС-1 проезд, 13, 6п'
|
||||||
assign_task(session, headers, task, address)
|
# assign_task(session, headers, task, address)
|
||||||
break
|
# break
|
||||||
# get_task(session, headers)
|
get_task(session, headers)
|
||||||
else:
|
else:
|
||||||
print(f"Отказ в авторизации для пользователя {user['email']}!")
|
print(f"Отказ в авторизации для пользователя {user['email']}!")
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user