Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfacbc8c

Browse files
author
Gauvain Pocentek
committed
[cli] Fix the project-export download
Closes#559
1 parente9506d1 commitfacbc8c

File tree

1 file changed

+24
-2
lines changed

1 file changed

+24
-2
lines changed

‎gitlab/v4/cli.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from __future__importprint_function
2020
importinspect
2121
importoperator
22+
importsys
2223

2324
importsix
2425

@@ -54,11 +55,18 @@ def __init__(self, gl, what, action, args):
5455
self.args[attr_name]=obj.get()
5556

5657
def__call__(self):
58+
# Check for a method that matches object + action
59+
method='do_%s_%s'% (self.what,self.action)
60+
ifhasattr(self,method):
61+
returngetattr(self,method)()
62+
63+
# Fallback to standard actions (get, list, create, ...)
5764
method='do_%s'%self.action
5865
ifhasattr(self,method):
5966
returngetattr(self,method)()
60-
else:
61-
returnself.do_custom()
67+
68+
# Finally try to find custom methods
69+
returnself.do_custom()
6270

6371
defdo_custom(self):
6472
in_obj=cli.custom_actions[self.cls_name][self.action][2]
@@ -77,6 +85,20 @@ def do_custom(self):
7785
else:
7886
returngetattr(self.mgr,self.action)(**self.args)
7987

88+
defdo_project_export_download(self):
89+
try:
90+
project=self.gl.projects.get(int(self.args['project_id']),
91+
lazy=True)
92+
data=project.exports.get().download()
93+
ifhasattr(sys.stdout,'buffer'):
94+
# python3
95+
sys.stdout.buffer.write(data)
96+
else:
97+
sys.stdout.write(data)
98+
99+
exceptExceptionase:
100+
cli.die("Impossible to download the export",e)
101+
80102
defdo_create(self):
81103
try:
82104
returnself.mgr.create(self.args)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp