@@ -111,6 +111,7 @@ def _print_message_patched(self, message, file=None):
111111 swrite (FLAG_TAIL_ARGINF )
112112 sflush ()
113113
114+
114115def exit_patched (self , status = 0 , message = None ):
115116 """ A patch on `argparse.ArgumentParser`
116117
@@ -124,6 +125,7 @@ def exit_patched(self, status=0, message=None):
124125 self ._print_message (emsg )
125126 raise InterruptLoop
126127
128+
127129class Bugzilla_patched (bugzilla .Bugzilla ):
128130 """ Patch `bugzilla.Bugzilla` to fit MI
129131
@@ -209,6 +211,7 @@ def setup_logging():
209211 datefmt = "%y.%m.%d %H:%M:%S" ))
210212 log .addHandler (handler )
211213
214+
212215def level_logging (debug , verbose ):
213216 """ Change log level on the fly
214217 """
@@ -405,6 +408,7 @@ def _process_attachment_data(_attlist):
405408 swrite (FLAG_TAIL_ATTACH )
406409 sflush ()
407410
411+
408412def _do_set_attach (bz , opt , parser ):
409413 """ (Patched version)
410414 Replace original print statement;
@@ -551,11 +555,20 @@ def _main(unittest_bz_instance):
551555 log .debug ("Bugzilla module: %s" , bugzilla )
552556 NewAct = NewOpt .command
553557
554- if unittest_bz_instance :
555- bz = unittest_bz_instance
556- else :
557- bz = _make_bz_instance (NewOpt , force_new = bz_REFRESH )
558- bz_REFRESH = False
558+ try :
559+ if unittest_bz_instance :
560+ bz = unittest_bz_instance
561+ else :
562+ bz = _make_bz_instance (NewOpt , force_new = bz_REFRESH )
563+ bz_REFRESH = False
564+ except Exception as E :
565+ swrite (FLAG_HEAD_EXCEPT )
566+ swrite ("CANNOT create the instance of `bugzilla.Bugzilla` " )
567+ swrite ("with args ` %s ` because of " % NewCmd )
568+ swrite ("%s: %s" % (E .__class__ .__name__ ,str (E )))
569+ swrite (FLAG_TAIL_EXCEPT )
570+ sflush ()
571+ continue
559572
560573 try :
561574 # Handle login options
@@ -629,6 +642,7 @@ def _main(unittest_bz_instance):
629642 bz_REFRESH = True
630643 continue
631644
645+
632646def main (unittest_bz_instance = None ):
633647 """ (Patched version)
634648 """
0 commit comments