示例#1
0
    def get_bundle_detail(self, bundle_number):
        """
        Returns details about the identified instance
        """
        details = {}
        try:
            bundle_id = int(bundle_number)
        except ValueError as ex:
            return json.dumps({"error": str(ex)})
        else:
            # Integer ID
            try:
                bundle = self._context.get_bundle(bundle_id)
            except:
                return {}
        if bundle is None:
            return {}
        else:
            details = {
                "id": bundle.get_bundle_id(),
                "name": bundle.get_symbolic_name(),
                "version": bundle.get_version(),
                "state": _ShellUtils.bundlestate_to_str(bundle.get_state()),
                "location": bundle.get_location(),
                "published-services": [],
                "used-services": []
            }
            try:
                services = bundle.get_registered_services()
                if services:
                    details["published-services"] = [
                        str(svc_ref) for svc_ref in services
                    ]
                else:
                    pass
            except pelix.constants.BundleException as ex:
                # Bundle in a invalid state
                pass
            try:
                services = bundle.get_services_in_use()
                if services:
                    details["used-services"] = [
                        str(svc_ref) for svc_ref in services
                    ]
                else:
                    pass
            except pelix.constants.BundleException as ex:
                # Bundle in a invalid state
                pass

            return json.dumps(details)
示例#2
0
    def get_bundles(self):
        """
        Returns the list of isolate bundles
        """
        bundles = self._context.get_bundles()
        bundles.insert(0, self._context.get_bundle(0))

        result = [{
            "id": bundle.get_bundle_id(),
            "name": bundle.get_symbolic_name(),
            "state": _ShellUtils.bundlestate_to_str(bundle.get_state()),
            "version": bundle.get_version()
        } for bundle in bundles]
        return json.dumps(result)
示例#3
0
 def get_bundle_detail(self, bundle_number):
     """
     Returns details about the identified instance
     """
     details = {}        
     try:
         bundle_id = int(bundle_number)            
     except ValueError as ex:
         return json.dumps({"error" : str(ex)})
     else:
         # Integer ID
         try:
             bundle = self._context.get_bundle(bundle_id)
         except:
             return {}
     if bundle is None:
         return {}
     else:
         details = {
             "id": bundle.get_bundle_id(),
             "name" : bundle.get_symbolic_name(),
             "version" : bundle.get_version(),
             "state" : _ShellUtils.bundlestate_to_str(
                                 bundle.get_state()),
             "location" : bundle.get_location(),
             "published-services" : [],
             "used-services" : []
         }                   
         try:
             services = bundle.get_registered_services()
             if services:
                 details["published-services"] = [ str(svc_ref) for svc_ref in services ]                    
             else:
                 pass
         except pelix.constants.BundleException as ex:
             # Bundle in a invalid state
             pass
         try:
             services = bundle.get_services_in_use()
             if services:
                 details["used-services"] = [ str(svc_ref) for svc_ref in services ]                         
             else:
                 pass
         except pelix.constants.BundleException as ex:
             # Bundle in a invalid state
             pass
         
         return json.dumps(details)
示例#4
0
 def get_bundles(self):
     """
     Returns the list of isolate bundles
     """
     bundles = self._context.get_bundles()
     bundles.insert(0, self._context.get_bundle(0))
     
     return [
         { 
           "id" : bundle.get_bundle_id(),
           "name" : bundle.get_symbolic_name(),
           "state" : _ShellUtils.bundlestate_to_str(
                                 bundle.get_state()),
           "version" : bundle.get_version()
         } for bundle in bundles              
     ]