73
73
}
74
74
75
75
76
- def _die (msg ):
76
+ def _die (msg , e = None ):
77
+ if e :
78
+ msg = "%s (%s)" % (msg , e )
77
79
sys .stderr .write (msg + "\n " )
78
80
sys .exit (1 )
79
81
@@ -111,7 +113,7 @@ def do_create(self, cls, gl, what, args):
111
113
try :
112
114
o = cls .create (gl , args )
113
115
except Exception as e :
114
- _die ("Impossible to create object (%s)" % str ( e ) )
116
+ _die ("Impossible to create object" , e )
115
117
116
118
return o
117
119
@@ -122,7 +124,7 @@ def do_list(self, cls, gl, what, args):
122
124
try :
123
125
l = cls .list (gl , ** args )
124
126
except Exception as e :
125
- _die ("Impossible to list objects (%s)" % str ( e ) )
127
+ _die ("Impossible to list objects" , e )
126
128
127
129
return l
128
130
@@ -137,7 +139,7 @@ def do_get(self, cls, gl, what, args):
137
139
try :
138
140
o = cls .get (gl , id , ** args )
139
141
except Exception as e :
140
- _die ("Impossible to get object (%s)" % str ( e ) )
142
+ _die ("Impossible to get object" , e )
141
143
142
144
return o
143
145
@@ -149,7 +151,7 @@ def do_delete(self, cls, gl, what, args):
149
151
try :
150
152
gl .delete (cls , id , ** args )
151
153
except Exception as e :
152
- _die ("Impossible to destroy object (%s)" % str ( e ) )
154
+ _die ("Impossible to destroy object" , e )
153
155
154
156
def do_update (self , cls , gl , what , args ):
155
157
if not cls .canUpdate :
@@ -161,173 +163,172 @@ def do_update(self, cls, gl, what, args):
161
163
o .__dict__ [k ] = v
162
164
o .save ()
163
165
except Exception as e :
164
- _die ("Impossible to update object (%s)" % str ( e ) )
166
+ _die ("Impossible to update object" , e )
165
167
166
168
return o
167
169
168
170
def do_group_search (self , cls , gl , what , args ):
169
171
try :
170
172
return gl .groups .search (args ['query' ])
171
173
except Exception as e :
172
- _die ("Impossible to search projects (%s)" % str ( e ) )
174
+ _die ("Impossible to search projects" , e )
173
175
174
176
def do_project_search (self , cls , gl , what , args ):
175
177
try :
176
178
return gl .projects .search (args ['query' ])
177
179
except Exception as e :
178
- _die ("Impossible to search projects (%s)" % str ( e ) )
180
+ _die ("Impossible to search projects" , e )
179
181
180
182
def do_project_all (self , cls , gl , what , args ):
181
183
try :
182
184
return gl .projects .all ()
183
185
except Exception as e :
184
- _die ("Impossible to list all projects (%s)" % str ( e ) )
186
+ _die ("Impossible to list all projects" , e )
185
187
186
188
def do_project_starred (self , cls , gl , what , args ):
187
189
try :
188
190
return gl .projects .starred ()
189
191
except Exception as e :
190
- _die ("Impossible to list starred projects (%s)" % str ( e ) )
192
+ _die ("Impossible to list starred projects" , e )
191
193
192
194
def do_project_owned (self , cls , gl , what , args ):
193
195
try :
194
196
return gl .projects .owned ()
195
197
except Exception as e :
196
- _die ("Impossible to list owned projects (%s)" % str ( e ) )
198
+ _die ("Impossible to list owned projects" , e )
197
199
198
200
def do_project_star (self , cls , gl , what , args ):
199
201
try :
200
202
o = self .do_get (cls , gl , what , args )
201
203
o .star ()
202
204
except Exception as e :
203
- _die ("Impossible to star project (%s)" % str ( e ) )
205
+ _die ("Impossible to star project" , e )
204
206
205
207
def do_project_unstar (self , cls , gl , what , args ):
206
208
try :
207
209
o = self .do_get (cls , gl , what , args )
208
210
o .unstar ()
209
211
except Exception as e :
210
- _die ("Impossible to unstar project (%s)" % str ( e ) )
212
+ _die ("Impossible to unstar project" , e )
211
213
212
214
def do_project_archive (self , cls , gl , what , args ):
213
215
try :
214
216
o = self .do_get (cls , gl , what , args )
215
217
o .archive_ ()
216
218
except Exception as e :
217
- _die ("Impossible to archive project (%s)" % str ( e ) )
219
+ _die ("Impossible to archive project" , e )
218
220
219
221
def do_project_unarchive (self , cls , gl , what , args ):
220
222
try :
221
223
o = self .do_get (cls , gl , what , args )
222
224
o .unarchive_ ()
223
225
except Exception as e :
224
- _die ("Impossible to unarchive project (%s)" % str ( e ) )
226
+ _die ("Impossible to unarchive project" , e )
225
227
226
228
def do_project_share (self , cls , gl , what , args ):
227
229
try :
228
230
o = self .do_get (cls , gl , what , args )
229
231
o .share (args ['group_id' ], args ['group_access' ])
230
232
except Exception as e :
231
- _die ("Impossible to share project (%s)" % str ( e ) )
233
+ _die ("Impossible to share project" , e )
232
234
233
235
def do_user_block (self , cls , gl , what , args ):
234
236
try :
235
237
o = self .do_get (cls , gl , what , args )
236
238
o .block ()
237
239
except Exception as e :
238
- _die ("Impossible to block user (%s)" % str ( e ) )
240
+ _die ("Impossible to block user" , e )
239
241
240
242
def do_user_unblock (self , cls , gl , what , args ):
241
243
try :
242
244
o = self .do_get (cls , gl , what , args )
243
245
o .unblock ()
244
246
except Exception as e :
245
- _die ("Impossible to block user (%s)" % str ( e ) )
247
+ _die ("Impossible to block user" , e )
246
248
247
249
def do_project_commit_diff (self , cls , gl , what , args ):
248
250
try :
249
251
o = self .do_get (cls , gl , what , args )
250
252
return [x ['diff' ] for x in o .diff ()]
251
253
except Exception as e :
252
- _die ("Impossible to get commit diff (%s)" % str ( e ) )
254
+ _die ("Impossible to get commit diff" , e )
253
255
254
256
def do_project_commit_blob (self , cls , gl , what , args ):
255
257
try :
256
258
o = self .do_get (cls , gl , what , args )
257
259
return o .blob (args ['filepath' ])
258
260
except Exception as e :
259
- _die ("Impossible to get commit blob (%s)" % str ( e ) )
261
+ _die ("Impossible to get commit blob" , e )
260
262
261
263
def do_project_commit_builds (self , cls , gl , what , args ):
262
264
try :
263
265
o = self .do_get (cls , gl , what , args )
264
266
return o .builds ()
265
267
except Exception as e :
266
- _die ("Impossible to get commit builds (%s)" % str ( e ) )
268
+ _die ("Impossible to get commit builds" , e )
267
269
268
270
def do_project_build_cancel (self , cls , gl , what , args ):
269
271
try :
270
272
o = self .do_get (cls , gl , what , args )
271
273
return o .cancel ()
272
274
except Exception as e :
273
- _die ("Impossible to cancel project build (%s)" % str ( e ) )
275
+ _die ("Impossible to cancel project build" , e )
274
276
275
277
def do_project_build_retry (self , cls , gl , what , args ):
276
278
try :
277
279
o = self .do_get (cls , gl , what , args )
278
280
return o .retry ()
279
281
except Exception as e :
280
- _die ("Impossible to retry project build (%s)" % str ( e ) )
282
+ _die ("Impossible to retry project build" , e )
281
283
282
284
def do_project_build_artifacts (self , cls , gl , what , args ):
283
285
try :
284
286
o = self .do_get (cls , gl , what , args )
285
287
return o .artifacts ()
286
288
except Exception as e :
287
- _die ("Impossible to get project build artifacts (%s)" % str ( e ) )
289
+ _die ("Impossible to get project build artifacts" , e )
288
290
289
291
def do_project_build_trace (self , cls , gl , what , args ):
290
292
try :
291
293
o = self .do_get (cls , gl , what , args )
292
294
return o .trace ()
293
295
except Exception as e :
294
- _die ("Impossible to get project build trace (%s)" % str ( e ) )
296
+ _die ("Impossible to get project build trace" , e )
295
297
296
298
def do_project_issue_subscribe (self , cls , gl , what , args ):
297
299
try :
298
300
o = self .do_get (cls , gl , what , args )
299
301
o .subscribe ()
300
302
except Exception as e :
301
- _die ("Impossible to subscribe to issue (%s)" % str ( e ) )
303
+ _die ("Impossible to subscribe to issue" , e )
302
304
303
305
def do_project_issue_unsubscribe (self , cls , gl , what , args ):
304
306
try :
305
307
o = self .do_get (cls , gl , what , args )
306
308
o .unsubscribe ()
307
309
except Exception as e :
308
- _die ("Impossible to subscribe to issue (%s)" % str ( e ) )
310
+ _die ("Impossible to subscribe to issue" , e )
309
311
310
312
def do_project_issue_move (self , cls , gl , what , args ):
311
313
try :
312
314
o = self .do_get (cls , gl , what , args )
313
315
o .move (args ['to_project_id' ])
314
316
except Exception as e :
315
- _die ("Impossible to move issue (%s)" % str ( e ) )
317
+ _die ("Impossible to move issue" , e )
316
318
317
319
def do_project_merge_request_closesissues (self , cls , gl , what , args ):
318
320
try :
319
321
o = self .do_get (cls , gl , what , args )
320
322
return o .closes_issues ()
321
323
except Exception as e :
322
- _die ("Impossible to list issues closed by merge request (%s)" %
323
- str (e ))
324
+ _die ("Impossible to list issues closed by merge request" , e )
324
325
325
326
def do_project_merge_request_cancel (self , cls , gl , what , args ):
326
327
try :
327
328
o = self .do_get (cls , gl , what , args )
328
329
return o .cancel_merge_when_build_succeeds ()
329
330
except Exception as e :
330
- _die ("Impossible to cancel merge request (%s)" % str ( e ) )
331
+ _die ("Impossible to cancel merge request" , e )
331
332
332
333
def do_project_merge_request_merge (self , cls , gl , what , args ):
333
334
try :
@@ -339,26 +340,26 @@ def do_project_merge_request_merge(self, cls, gl, what, args):
339
340
should_remove_source_branch = should_remove ,
340
341
merged_when_build_succeeds = build_succeeds )
341
342
except Exception as e :
342
- _die ("Impossible to validate merge request (%s)" % str ( e ) )
343
+ _die ("Impossible to validate merge request" , e )
343
344
344
345
def do_project_milestone_issues (self , cls , gl , what , args ):
345
346
try :
346
347
o = self .do_get (cls , gl , what , args )
347
348
return o .issues ()
348
349
except Exception as e :
349
- _die ("Impossible to get milestone issues (%s)" % str ( e ) )
350
+ _die ("Impossible to get milestone issues" , e )
350
351
351
352
def do_user_search (self , cls , gl , what , args ):
352
353
try :
353
354
return gl .users .search (args ['query' ])
354
355
except Exception as e :
355
- _die ("Impossible to search users (%s)" % str ( e ) )
356
+ _die ("Impossible to search users" , e )
356
357
357
358
def do_user_getbyusername (self , cls , gl , what , args ):
358
359
try :
359
360
return gl .users .search (args ['query' ])
360
361
except Exception as e :
361
- _die ("Impossible to get user %s (%s) " % ( args ['query' ], str ( e )) )
362
+ _die ("Impossible to get user %s" % args ['query' ], e )
362
363
363
364
364
365
def _populate_sub_parser_by_class (cls , sub_parser ):
0 commit comments