def run(self, path, *args, **kwargs): if path: return self.parse_query(path) else: try: return {self.name: psextensions.get_services()} except Exception, e: return {self.name: u'Error getting services: %s' % unicode(e)}
def parse_query(self, path): desired_service = path[0].replace(u'|', u'/') try: desired_state = path[1] except IndexError: desired_state = None services = psextensions.get_services() if desired_state: return {desired_service: services.get(desired_service, u'Service not found') == desired_state} else: return {desired_service: services.get(desired_service, u'Service not found')}