Go to the documentation of this file.00001 import fnmatch
00002 from rosbridge_library.capability import Capability
00003
00004
00005 class UnadvertiseService(Capability):
00006
00007
00008
00009 services_glob = None
00010
00011 def __init__(self, protocol):
00012
00013 Capability.__init__(self, protocol)
00014
00015
00016 protocol.register_operation("unadvertise_service", self.unadvertise_service)
00017
00018 def unadvertise_service(self, message):
00019
00020 service_name = message["service"]
00021
00022 if UnadvertiseService.services_glob is not None and UnadvertiseService.services_glob:
00023 self.protocol.log("debug", "Service security glob enabled, checking service: " + service_name)
00024 match = False
00025 for glob in UnadvertiseService.services_glob:
00026 if (fnmatch.fnmatch(service_name, glob)):
00027 self.protocol.log("debug", "Found match with glob " + glob + ", continuing service unadvertisement...")
00028 match = True
00029 break
00030 if not match:
00031 self.protocol.log("warn", "No match found for service, cancelling service unadvertisement for: " + service_name)
00032 return
00033 else:
00034 self.protocol.log("debug", "No service security glob, not checking service unadvertisement...")
00035
00036
00037 if service_name in self.protocol.external_service_list.keys():
00038 self.protocol.external_service_list[service_name].service_handle.shutdown("Unadvertise request.")
00039 del self.protocol.external_service_list[service_name]
00040 self.protocol.log("info", "Unadvertised service %s." % service_name)
00041 else:
00042 self.protocol.log("error", "Service %s has no been advertised externally." % service_name)