@@ -82,12 +82,15 @@ def parse_args():
8282 .replace ('MAX_MESSAGE_CHUNKS' , str (MAX_MESSAGE_CHUNKS )))
8383 parser = argparse .ArgumentParser (description = '%s' % extra_descr )
8484 sub_parser = parser .add_subparsers (dest = 'mode' )
85+
8586 config_parser = sub_parser .add_parser ('config' , help = 'Configure the notification server.' )
86- message_parser = sub_parser . add_parser ( 'message' , help = 'Send a message.' )
87+
8788 config_parser .add_argument (action = 'store' ,
8889 dest = 'notification_ocid' ,
8990 type = str ,
9091 help = 'The ocid of the notification topic.' )
92+
93+ message_parser = sub_parser .add_parser ('message' , help = 'Send a message.' )
9194 message_parser .add_argument ('-t' , '--title' ,
9295 action = 'store' ,
9396 dest = 'message_title' ,
@@ -449,7 +452,7 @@ def _read_oci_config(fname, profile='DEFAULT'):
449452 oci_config = oci_sdk .config .from_file (full_fname , profile )
450453 return oci_config
451454 except oci_sdk .exceptions .ConfigFileNotFound as e :
452- _logger .debug (" Unable to read OCI config file: %s" , str (e ))
455+ _logger .debug (' Unable to read OCI config file: %s' , str (e ))
453456 raise Exception ('Unable to read OCI config file' ) from e
454457
455458 def get_auth_method (self , authentication_method = None ):
@@ -524,7 +527,7 @@ def _proxy_authenticate(self):
524527 """
525528 _logger .debug ('_proxy_authenticate' )
526529 if os .geteuid () != 0 :
527- raise Exception (" Must be root to use Proxy authentication" )
530+ raise Exception (' Must be root to use Proxy authentication' )
528531
529532 sdk_user = OCIUtilsConfiguration .get ('auth' , 'oci_sdk_user' )
530533 try :
@@ -533,8 +536,8 @@ def _proxy_authenticate(self):
533536 self ._identity_client = oci_sdk .identity .IdentityClient (self ._oci_config )
534537 self ._ons_client = oci_sdk .ons .NotificationDataPlaneClient (config = self ._oci_config )
535538 except Exception as e :
536- _logger .debug (" Proxy authentication failed: %s" , str (e ))
537- raise Exception (" Proxy authentication failed" ) from e
539+ _logger .debug (' Proxy authentication failed: %s' , str (e ))
540+ raise Exception (' Proxy authentication failed' ) from e
538541
539542 def _direct_authenticate (self ):
540543 """
@@ -556,7 +559,7 @@ def _direct_authenticate(self):
556559 self ._ons_client = oci_sdk .ons .NotificationDataPlaneClient (config = self ._oci_config )
557560 except Exception as e :
558561 _logger .debug ('Direct authentication failed: %s' , str (e ))
559- raise Exception (" Direct authentication failed" ) from e
562+ raise Exception (' Direct authentication failed' ) from e
560563
561564 def _ip_authenticate (self ):
562565 """
@@ -758,17 +761,19 @@ def send_message_chunk(self, chunk, nb, nbtot):
758761 _logger .debug ('_Send chunk %d of %d' , nb , nbtot )
759762 if nbtot <= 1 :
760763 _logger .info ("Publishing message '%s: %s'" , self ._instance_name , self ._title )
764+ thistitle = self ._title
761765 else :
762766 _logger .info ("Publishing message '[%d/%d] %s: %s'" , nb , nbtot , self ._instance_name , self ._title )
767+ thistitle = self ._title + ' [%d/%d]' % (nb ,nbtot )
763768 _message_details = oci_sdk .ons .models .MessageDetails (body = chunk , title = self ._instance_name
764769 + ':'
765- + ' self . _title )
770+ + thistitle )
766771 request_id = uuid .uuid4 ().hex
767772 _logger .debug ('Message request id: %s' , request_id )
768773 publish_message_response = self ._ons_client .publish_message (topic_id = self ._topic ,
769774 message_details = _message_details ,
770775 opc_request_id = request_id ,
771- message_type = " RAW_TEXT" )
776+ message_type = ' RAW_TEXT' )
772777 if nbtot <= 1 :
773778 _logger .info ("Published message '%s: %s'" , self ._instance_name , self ._title )
774779 else :
0 commit comments