summaryrefslogtreecommitdiff
path: root/gitlab/v4/cli.py
diff options
context:
space:
mode:
authorMax Wittig <max.wittig@siemens.com>2020-10-12 21:52:33 +0200
committerGitHub <noreply@github.com>2020-10-12 21:52:33 +0200
commit3a38c6d78ceaed1116ebbdd8e5cded60c99c6f95 (patch)
treee5285dece164fe826412e93c7e1f5753ad6890e9 /gitlab/v4/cli.py
parentbc178898776d2d61477ff773248217adfac81f56 (diff)
parentf4e79501f1be1394873042dd65beda49e869afb8 (diff)
downloadgitlab-3a38c6d78ceaed1116ebbdd8e5cded60c99c6f95.tar.gz
Merge pull request #1202 from python-gitlab/fix/cli-binary-data
fix(cli): write binary data to stdout buffer
Diffstat (limited to 'gitlab/v4/cli.py')
-rw-r--r--gitlab/v4/cli.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/gitlab/v4/cli.py b/gitlab/v4/cli.py
index 51416f1..6172f93 100644
--- a/gitlab/v4/cli.py
+++ b/gitlab/v4/cli.py
@@ -85,11 +85,7 @@ class GitlabCLI(object):
try:
project = self.gl.projects.get(int(self.args["project_id"]), lazy=True)
data = project.exports.get().download()
- if hasattr(sys.stdout, "buffer"):
- # python3
- sys.stdout.buffer.write(data)
- else:
- sys.stdout.write(data)
+ sys.stdout.buffer.write(data)
except Exception as e:
cli.die("Impossible to download the export", e)
@@ -440,5 +436,7 @@ def run(gl, what, action, args, verbose, output, fields):
printer.display(get_dict(data, fields), verbose=verbose, obj=data)
elif isinstance(data, str):
print(data)
+ elif isinstance(data, bytes):
+ sys.stdout.buffer.write(data)
elif hasattr(data, "decode"):
print(data.decode())