7373}
7474
7575
76- def _die (msg ):
76+ def _die (msg , e = None ):
77+ if e :
78+ msg = "%s (%s)" % (msg , e )
7779 sys .stderr .write (msg + "\n " )
7880 sys .exit (1 )
7981
@@ -111,7 +113,7 @@ def do_create(self, cls, gl, what, args):
111113 try :
112114 o = cls .create (gl , args )
113115 except Exception as e :
114- _die ("Impossible to create object (%s)" % str ( e ) )
116+ _die ("Impossible to create object" , e )
115117
116118 return o
117119
@@ -122,7 +124,7 @@ def do_list(self, cls, gl, what, args):
122124 try :
123125 l = cls .list (gl , ** args )
124126 except Exception as e :
125- _die ("Impossible to list objects (%s)" % str ( e ) )
127+ _die ("Impossible to list objects" , e )
126128
127129 return l
128130
@@ -137,7 +139,7 @@ def do_get(self, cls, gl, what, args):
137139 try :
138140 o = cls .get (gl , id , ** args )
139141 except Exception as e :
140- _die ("Impossible to get object (%s)" % str ( e ) )
142+ _die ("Impossible to get object" , e )
141143
142144 return o
143145
@@ -149,7 +151,7 @@ def do_delete(self, cls, gl, what, args):
149151 try :
150152 gl .delete (cls , id , ** args )
151153 except Exception as e :
152- _die ("Impossible to destroy object (%s)" % str ( e ) )
154+ _die ("Impossible to destroy object" , e )
153155
154156 def do_update (self , cls , gl , what , args ):
155157 if not cls .canUpdate :
@@ -161,173 +163,172 @@ def do_update(self, cls, gl, what, args):
161163 o .__dict__ [k ] = v
162164 o .save ()
163165 except Exception as e :
164- _die ("Impossible to update object (%s)" % str ( e ) )
166+ _die ("Impossible to update object" , e )
165167
166168 return o
167169
168170 def do_group_search (self , cls , gl , what , args ):
169171 try :
170172 return gl .groups .search (args ['query' ])
171173 except Exception as e :
172- _die ("Impossible to search projects (%s)" % str ( e ) )
174+ _die ("Impossible to search projects" , e )
173175
174176 def do_project_search (self , cls , gl , what , args ):
175177 try :
176178 return gl .projects .search (args ['query' ])
177179 except Exception as e :
178- _die ("Impossible to search projects (%s)" % str ( e ) )
180+ _die ("Impossible to search projects" , e )
179181
180182 def do_project_all (self , cls , gl , what , args ):
181183 try :
182184 return gl .projects .all ()
183185 except Exception as e :
184- _die ("Impossible to list all projects (%s)" % str ( e ) )
186+ _die ("Impossible to list all projects" , e )
185187
186188 def do_project_starred (self , cls , gl , what , args ):
187189 try :
188190 return gl .projects .starred ()
189191 except Exception as e :
190- _die ("Impossible to list starred projects (%s)" % str ( e ) )
192+ _die ("Impossible to list starred projects" , e )
191193
192194 def do_project_owned (self , cls , gl , what , args ):
193195 try :
194196 return gl .projects .owned ()
195197 except Exception as e :
196- _die ("Impossible to list owned projects (%s)" % str ( e ) )
198+ _die ("Impossible to list owned projects" , e )
197199
198200 def do_project_star (self , cls , gl , what , args ):
199201 try :
200202 o = self .do_get (cls , gl , what , args )
201203 o .star ()
202204 except Exception as e :
203- _die ("Impossible to star project (%s)" % str ( e ) )
205+ _die ("Impossible to star project" , e )
204206
205207 def do_project_unstar (self , cls , gl , what , args ):
206208 try :
207209 o = self .do_get (cls , gl , what , args )
208210 o .unstar ()
209211 except Exception as e :
210- _die ("Impossible to unstar project (%s)" % str ( e ) )
212+ _die ("Impossible to unstar project" , e )
211213
212214 def do_project_archive (self , cls , gl , what , args ):
213215 try :
214216 o = self .do_get (cls , gl , what , args )
215217 o .archive_ ()
216218 except Exception as e :
217- _die ("Impossible to archive project (%s)" % str ( e ) )
219+ _die ("Impossible to archive project" , e )
218220
219221 def do_project_unarchive (self , cls , gl , what , args ):
220222 try :
221223 o = self .do_get (cls , gl , what , args )
222224 o .unarchive_ ()
223225 except Exception as e :
224- _die ("Impossible to unarchive project (%s)" % str ( e ) )
226+ _die ("Impossible to unarchive project" , e )
225227
226228 def do_project_share (self , cls , gl , what , args ):
227229 try :
228230 o = self .do_get (cls , gl , what , args )
229231 o .share (args ['group_id' ], args ['group_access' ])
230232 except Exception as e :
231- _die ("Impossible to share project (%s)" % str ( e ) )
233+ _die ("Impossible to share project" , e )
232234
233235 def do_user_block (self , cls , gl , what , args ):
234236 try :
235237 o = self .do_get (cls , gl , what , args )
236238 o .block ()
237239 except Exception as e :
238- _die ("Impossible to block user (%s)" % str ( e ) )
240+ _die ("Impossible to block user" , e )
239241
240242 def do_user_unblock (self , cls , gl , what , args ):
241243 try :
242244 o = self .do_get (cls , gl , what , args )
243245 o .unblock ()
244246 except Exception as e :
245- _die ("Impossible to block user (%s)" % str ( e ) )
247+ _die ("Impossible to block user" , e )
246248
247249 def do_project_commit_diff (self , cls , gl , what , args ):
248250 try :
249251 o = self .do_get (cls , gl , what , args )
250252 return [x ['diff' ] for x in o .diff ()]
251253 except Exception as e :
252- _die ("Impossible to get commit diff (%s)" % str ( e ) )
254+ _die ("Impossible to get commit diff" , e )
253255
254256 def do_project_commit_blob (self , cls , gl , what , args ):
255257 try :
256258 o = self .do_get (cls , gl , what , args )
257259 return o .blob (args ['filepath' ])
258260 except Exception as e :
259- _die ("Impossible to get commit blob (%s)" % str ( e ) )
261+ _die ("Impossible to get commit blob" , e )
260262
261263 def do_project_commit_builds (self , cls , gl , what , args ):
262264 try :
263265 o = self .do_get (cls , gl , what , args )
264266 return o .builds ()
265267 except Exception as e :
266- _die ("Impossible to get commit builds (%s)" % str ( e ) )
268+ _die ("Impossible to get commit builds" , e )
267269
268270 def do_project_build_cancel (self , cls , gl , what , args ):
269271 try :
270272 o = self .do_get (cls , gl , what , args )
271273 return o .cancel ()
272274 except Exception as e :
273- _die ("Impossible to cancel project build (%s)" % str ( e ) )
275+ _die ("Impossible to cancel project build" , e )
274276
275277 def do_project_build_retry (self , cls , gl , what , args ):
276278 try :
277279 o = self .do_get (cls , gl , what , args )
278280 return o .retry ()
279281 except Exception as e :
280- _die ("Impossible to retry project build (%s)" % str ( e ) )
282+ _die ("Impossible to retry project build" , e )
281283
282284 def do_project_build_artifacts (self , cls , gl , what , args ):
283285 try :
284286 o = self .do_get (cls , gl , what , args )
285287 return o .artifacts ()
286288 except Exception as e :
287- _die ("Impossible to get project build artifacts (%s)" % str ( e ) )
289+ _die ("Impossible to get project build artifacts" , e )
288290
289291 def do_project_build_trace (self , cls , gl , what , args ):
290292 try :
291293 o = self .do_get (cls , gl , what , args )
292294 return o .trace ()
293295 except Exception as e :
294- _die ("Impossible to get project build trace (%s)" % str ( e ) )
296+ _die ("Impossible to get project build trace" , e )
295297
296298 def do_project_issue_subscribe (self , cls , gl , what , args ):
297299 try :
298300 o = self .do_get (cls , gl , what , args )
299301 o .subscribe ()
300302 except Exception as e :
301- _die ("Impossible to subscribe to issue (%s)" % str ( e ) )
303+ _die ("Impossible to subscribe to issue" , e )
302304
303305 def do_project_issue_unsubscribe (self , cls , gl , what , args ):
304306 try :
305307 o = self .do_get (cls , gl , what , args )
306308 o .unsubscribe ()
307309 except Exception as e :
308- _die ("Impossible to subscribe to issue (%s)" % str ( e ) )
310+ _die ("Impossible to subscribe to issue" , e )
309311
310312 def do_project_issue_move (self , cls , gl , what , args ):
311313 try :
312314 o = self .do_get (cls , gl , what , args )
313315 o .move (args ['to_project_id' ])
314316 except Exception as e :
315- _die ("Impossible to move issue (%s)" % str ( e ) )
317+ _die ("Impossible to move issue" , e )
316318
317319 def do_project_merge_request_closesissues (self , cls , gl , what , args ):
318320 try :
319321 o = self .do_get (cls , gl , what , args )
320322 return o .closes_issues ()
321323 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 )
324325
325326 def do_project_merge_request_cancel (self , cls , gl , what , args ):
326327 try :
327328 o = self .do_get (cls , gl , what , args )
328329 return o .cancel_merge_when_build_succeeds ()
329330 except Exception as e :
330- _die ("Impossible to cancel merge request (%s)" % str ( e ) )
331+ _die ("Impossible to cancel merge request" , e )
331332
332333 def do_project_merge_request_merge (self , cls , gl , what , args ):
333334 try :
@@ -339,26 +340,26 @@ def do_project_merge_request_merge(self, cls, gl, what, args):
339340 should_remove_source_branch = should_remove ,
340341 merged_when_build_succeeds = build_succeeds )
341342 except Exception as e :
342- _die ("Impossible to validate merge request (%s)" % str ( e ) )
343+ _die ("Impossible to validate merge request" , e )
343344
344345 def do_project_milestone_issues (self , cls , gl , what , args ):
345346 try :
346347 o = self .do_get (cls , gl , what , args )
347348 return o .issues ()
348349 except Exception as e :
349- _die ("Impossible to get milestone issues (%s)" % str ( e ) )
350+ _die ("Impossible to get milestone issues" , e )
350351
351352 def do_user_search (self , cls , gl , what , args ):
352353 try :
353354 return gl .users .search (args ['query' ])
354355 except Exception as e :
355- _die ("Impossible to search users (%s)" % str ( e ) )
356+ _die ("Impossible to search users" , e )
356357
357358 def do_user_getbyusername (self , cls , gl , what , args ):
358359 try :
359360 return gl .users .search (args ['query' ])
360361 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 )
362363
363364
364365def _populate_sub_parser_by_class (cls , sub_parser ):
0 commit comments