MCPcopy Index your code
hub / github.com/battlecode/battlecode-2018 / upload_scrim_server

Function upload_scrim_server

battlecode-manager/gui.py:48–79  ·  view source on GitHub ↗
(return_args)

Source from the content-addressed store, hash-verified

46
47@eel.expose
48def upload_scrim_server(return_args):
49 cwd = os.getcwd()
50 if 'NODOCKER' in os.environ:
51 os.chdir('..')
52 else:
53 os.chdir('/player')
54 os.chdir(return_args['file_name'])
55 zip_file_name = os.path.abspath(os.path.join('../',
56 return_args['file_name']))
57
58 shutil.make_archive(zip_file_name, 'zip', '.')
59 if not zip_file_name.endswith('.zip'):
60 zip_file_name += '.zip'
61
62 os.chdir(cwd)
63 username = return_args['username']
64 password = return_args['password']
65 req = get_token(username, password)
66 if req.status_code != 200:
67 print("Error authenticating.")
68 return "Error authenticating."
69
70 token = json.loads(req.text)['access_token']
71 headers = {}
72 headers['Authorization'] = 'Bearer ' + token
73 data = {}
74 data['label'] = return_args['player']
75 with open(zip_file_name, 'rb') as image_file:
76 encoded_string = base64.b64encode(image_file.read())
77 data['src'] = encoded_string
78 res = requests.post("https://battlecode.org/apis/submissions", headers=headers, data=data)
79 return "success"
80
81
82

Callers

nothing calls this directly

Calls 2

get_tokenFunction · 0.85
readMethod · 0.80

Tested by

no test coverage detected