#NEWLINE# def publish( self ) : #NEWLINE# #INDENT# 'Publish the service.\n\n        Call when your service starts.\n        ' #NEWLINE# if _is_loopback_address ( e . host ) : #NEWLINE# #INDENT# logger . debug ( '%s: Publish on loopback interface is not supported.' , self ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( not dbus ) : #NEWLINE# #INDENT# logger . debug ( '%s: dbus not installed; publish failed.' , self ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( not self . bus ) : #NEWLINE# #INDENT# logger . debug ( '%s: Bus not available; publish failed.' , self ) #NEWLINE# return False #NEWLINE# #UNINDENT# if ( not self . server ) : #NEWLINE# #INDENT# logger . debug ( '%s: Server not available; publish failed.' , self ) #NEWLINE# return False #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( not self . bus . name_has_owner ( 'org.freedesktop.Avahi' ) ) : #NEWLINE# #INDENT# logger . debug ( '%s: Avahi service not running; publish failed.' , self ) #NEWLINE# return False #NEWLINE# #UNINDENT# self . group = dbus . Interface ( self . bus . get_object ( 'org.freedesktop.Avahi' , self . server . EntryGroupNew ( ) ) , 'org.freedesktop.Avahi.EntryGroup' ) #NEWLINE# self . group . AddService ( _AVAHI_IF_UNSPEC , _AVAHI_PROTO_UNSPEC , dbus . UInt32 ( _AVAHI_PUBLISHFLAGS_NONE ) , self . name , self . stype , self . domain , self . host , dbus . UInt16 ( self . port ) , _convert_text_list_to_dbus_format ( self . text ) ) #NEWLINE# self . group . Commit ( ) #NEWLINE# logger . debug ( '%s: Published' , self ) #NEWLINE# return True #NEWLINE# #UNINDENT# except dbus . exceptions . DBusException as e : #NEWLINE# #INDENT# logger . debug ( '%s: Publish failed: %s' , self , e ) #NEWLINE# return False