2023-04-04 22:55:16 +03:00
|
|
|
from typing import Dict
|
2023-04-04 09:15:28 +03:00
|
|
|
from services import pastie, dpaste, rentry, defau, sprunge, opendev
|
2023-04-04 22:55:16 +03:00
|
|
|
from data.data import add_data, save_data, set_encryption_key
|
2023-04-04 09:15:28 +03:00
|
|
|
|
|
|
|
|
2023-04-04 22:55:16 +03:00
|
|
|
def upload_and_store(data: Dict):
|
|
|
|
# set encryption key if necessary
|
2023-05-21 13:56:01 +03:00
|
|
|
my_key = b'upload_id=upload_and_store(my_da'
|
|
|
|
set_encryption_key(my_key)
|
2023-04-04 09:15:28 +03:00
|
|
|
|
2023-04-04 22:55:16 +03:00
|
|
|
traces = {}
|
|
|
|
for service in [pastie, dpaste, rentry, defau, sprunge, opendev]:
|
2023-04-04 09:15:28 +03:00
|
|
|
result = service.upload(data)
|
2023-04-04 22:55:16 +03:00
|
|
|
if result:
|
|
|
|
traces[result['name']] = result['key']
|
|
|
|
add_data(service.get_service_tag(), result['name'], result['md5sum'])
|
2023-05-21 13:56:01 +03:00
|
|
|
save_data('data.json', data, key=my_key)
|
2023-04-04 22:55:16 +03:00
|
|
|
return traces
|
2023-04-04 09:15:28 +03:00
|
|
|
|
2023-04-04 22:55:16 +03:00
|
|
|
my_data = {"name": "Sashenka", "age": 26, "country": "Anguilla"}
|
2023-04-04 09:15:28 +03:00
|
|
|
|
2023-05-21 13:56:01 +03:00
|
|
|
|
|
|
|
|
2023-04-04 22:55:16 +03:00
|
|
|
upload_trace = upload_and_store(my_data)
|
|
|
|
|
|
|
|
print('trace: ', upload_trace)
|
2023-04-04 09:15:28 +03:00
|
|
|
|