Commit 57e95378 authored by Amir MOHAMMADI's avatar Amir MOHAMMADI

[common] use with statement to open files

parent 5b2745c5
Pipeline #41405 passed with stage
in 4 minutes and 40 seconds
......@@ -1530,21 +1530,17 @@ def push(
# C++ algorithms must be sent in two steps, we send the binary file now
if asset_type == "algorithm" and storage.language == "cxx":
try:
webapi.upload(
"/api/v1/%s/%s/%s/%s/file/"
% (
TYPE_PLURAL[asset_type],
webapi.user,
storage.name,
storage.version,
),
{
"binary": (
"%s.so" % storage.version,
open(storage.code.path, "rb"),
)
},
)
with open(storage.code.path, "rb") as f:
webapi.upload(
"/api/v1/%s/%s/%s/%s/file/"
% (
TYPE_PLURAL[asset_type],
webapi.user,
storage.name,
storage.version,
),
{"binary": ("%s.so" % storage.version, f)},
)
except RuntimeError as e:
logger.error(e)
return 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment