Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.cmdline
Commits
57e95378
Commit
57e95378
authored
Jul 22, 2020
by
Amir MOHAMMADI
Browse files
[common] use with statement to open files
parent
5b2745c5
Pipeline
#41405
passed with stage
in 4 minutes and 40 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
beat/cmdline/common.py
View file @
57e95378
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment