chatgpt/pastedb/pastedb01/upload.py

25 lines
776 B
Python
Raw Normal View History

2023-04-04 22:55:16 +03:00
from typing import Dict
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 22:55:16 +03:00
def upload_and_store(data: Dict):
# set encryption key if necessary
set_encryption_key(b'upload_id=upload_and_store(my_da')
2023-04-04 22:55:16 +03:00
traces = {}
for service in [pastie, dpaste, rentry, defau, sprunge, opendev]:
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'])
save_data('data.json', data, key=b'my_key123')
return traces
2023-04-04 22:55:16 +03:00
my_data = {"name": "Sashenka", "age": 26, "country": "Anguilla"}
2023-04-04 22:55:16 +03:00
upload_trace = upload_and_store(my_data)
print('trace: ', upload_trace)