This repository has been archived on 2023-02-09. You can view files and clone it, but cannot push or open issues or pull requests.
Files
blender-benchmark-bundle/benchmark/submission/__init__.py
Sybren A. Stüvel 7b88d7704c Fix T56372: Properly show error messages when submission fails
This also introduces a word-wrapping function that takes variable character
widths into account.
2018-08-14 15:08:58 +02:00

33 lines
1023 B
Python

from .client import CommunicationError
def submit_benchmark(benchmark_data: dict):
"""Submit benchmark data to MyData.
Authenticates the user via the web browser and Blender ID if necessary.
Authentication tokens are stored on disk and validated before reusing.
"""
import logging
import os
from .client import BenchmarkClient
mydata_url = os.environ.get('MYDATA') or 'https://mydata.blender.org/'
if 'MYDATA' in os.environ:
# Assume we're debugging here.
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)-15s %(levelname)8s %(name)s %(message)s')
bc = BenchmarkClient(mydata_url)
# Make sure we have a token; can start the browser to get one.
token = bc.load_auth_token()
result = bc.submit_benchmark(benchmark_data)
print(result)
# If we get a location from the MyData server, show it in a browser.
if result.location:
import webbrowser
webbrowser.open_new_tab(result.location)