_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q9700
RemoteServiceAdminEvent.fromexportreg
train
def fromexportreg(cls, bundle, export_reg): # type: (Bundle, ExportRegistration) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from an ExportRegistration """ exc = export_reg.get_exception() if exc: return RemoteServiceAdminEvent( ...
python
{ "resource": "" }
q9701
RemoteServiceAdminEvent.fromexportupdate
train
def fromexportupdate(cls, bundle, export_reg): # type: (Bundle, ExportRegistration) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from the update of an ExportRegistration """ exc = export_reg.get_exception() if exc: return Rem...
python
{ "resource": "" }
q9702
RemoteServiceAdminEvent.fromimportupdate
train
def fromimportupdate(cls, bundle, import_reg): # type: (Bundle, ImportRegistration) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from the update of an ImportRegistration """ exc = import_reg.get_exception() if exc: return Rem...
python
{ "resource": "" }
q9703
RemoteServiceAdminEvent.fromimportunreg
train
def fromimportunreg( cls, bundle, cid, rsid, import_ref, exception, endpoint ): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], ImportReference, Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object...
python
{ "resource": "" }
q9704
RemoteServiceAdminEvent.fromexportunreg
train
def fromexportunreg( cls, bundle, exporterid, rsid, export_ref, exception, endpoint ): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], ExportReference, Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent...
python
{ "resource": "" }
q9705
RemoteServiceAdminEvent.fromimporterror
train
def fromimporterror(cls, bundle, importerid, rsid, exception, endpoint): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from an import error """ ...
python
{ "resource": "" }
q9706
RemoteServiceAdminEvent.fromexporterror
train
def fromexporterror(cls, bundle, exporterid, rsid, exception, endpoint): # type: (Bundle, Tuple[str, str], Tuple[Tuple[str, str], int], Optional[Tuple[Any, Any, Any]], EndpointDescription) -> RemoteServiceAdminEvent """ Creates a RemoteServiceAdminEvent object from an export error """ ...
python
{ "resource": "" }
q9707
IPopoWaitingList._try_instantiate
train
def _try_instantiate(self, ipopo, factory, component): # type: (Any, str, str) -> None """ Tries to instantiate a component from the queue. Hides all exceptions. :param ipopo: The iPOPO service :param factory: Component factory :param component: Component name ""...
python
{ "resource": "" }
q9708
IPopoWaitingList.service_changed
train
def service_changed(self, event): # type: (ServiceEvent) -> None """ Handles an event about the iPOPO service """ kind = event.get_kind() if kind == ServiceEvent.REGISTERED: # iPOPO service registered: register to factory events with use_ipopo(self...
python
{ "resource": "" }
q9709
IPopoWaitingList.handle_ipopo_event
train
def handle_ipopo_event(self, event): # type: (IPopoEvent) -> None """ Handles an iPOPO event :param event: iPOPO event bean """ kind = event.get_kind() if kind == IPopoEvent.REGISTERED: # A factory has been registered try: ...
python
{ "resource": "" }
q9710
IPopoWaitingList.add
train
def add(self, factory, component, properties=None): # type: (str, str, dict) -> None """ Enqueues the instantiation of the given component :param factory: Factory name :param component: Component name :param properties: Component properties :raise ValueError: Com...
python
{ "resource": "" }
q9711
_create_server
train
def _create_server( shell, server_address, port, cert_file=None, key_file=None, key_password=None, ca_file=None, ): """ Creates the TCP console on the given address and port :param shell: The remote shell handler :param server_address: Server bound address :param port: S...
python
{ "resource": "" }
q9712
_run_interpreter
train
def _run_interpreter(variables, banner): """ Runs a Python interpreter console and blocks until the user exits it. :param variables: Interpreters variables (locals) :param banner: Start-up banners """ # Script-only imports import code try: import readline import rlcompl...
python
{ "resource": "" }
q9713
RemoteConsole.send
train
def send(self, data): """ Tries to send data to the client. :param data: Data to be sent :return: True if the data was sent, False on error """ if data is not None: data = data.encode("UTF-8") try: self.wfile.write(data) self....
python
{ "resource": "" }
q9714
RemoteConsole.handle
train
def handle(self): """ Handles a TCP client """ _logger.info( "RemoteConsole client connected: [%s]:%d", self.client_address[0], self.client_address[1], ) # Prepare the session session = beans.ShellSession( beans.IOH...
python
{ "resource": "" }
q9715
ThreadingTCPServerFamily.get_request
train
def get_request(self): """ Accepts a new client. Sets up SSL wrapping if necessary. :return: A tuple: (client socket, client address tuple) """ # Accept the client client_socket, client_address = self.socket.accept() if ssl is not None and self.cert_file: ...
python
{ "resource": "" }
q9716
ThreadingTCPServerFamily.process_request
train
def process_request(self, request, client_address): """ Starts a new thread to process the request, adding the client address in its name. """ thread = threading.Thread( name="RemoteShell-{0}-Client-{1}".format( self.server_address[1], client_address[:...
python
{ "resource": "" }
q9717
_HTTPServletRequest.get_header
train
def get_header(self, name, default=None): """ Retrieves the value of a header """ return self._handler.headers.get(name, default)
python
{ "resource": "" }
q9718
_HTTPServletResponse.end_headers
train
def end_headers(self): """ Ends the headers part """ # Send them all at once for name, value in self._headers.items(): self._handler.send_header(name, value) self._handler.end_headers()
python
{ "resource": "" }
q9719
_RequestHandler.log_error
train
def log_error(self, message, *args, **kwargs): # pylint: disable=W0221 """ Log server error """ self._service.log(logging.ERROR, message, *args, **kwargs)
python
{ "resource": "" }
q9720
_RequestHandler.log_request
train
def log_request(self, code="-", size="-"): """ Logs a request to the server """ self._service.log(logging.DEBUG, '"%s" %s', self.requestline, code)
python
{ "resource": "" }
q9721
_RequestHandler.send_no_servlet_response
train
def send_no_servlet_response(self): """ Default response sent when no servlet is found for the requested path """ # Use the helper to send the error page response = _HTTPServletResponse(self) response.send_content(404, self._service.make_not_found_page(self.path))
python
{ "resource": "" }
q9722
_RequestHandler.send_exception
train
def send_exception(self, response): """ Sends an exception page with a 500 error code. Must be called from inside the exception handling block. :param response: The response handler """ # Get a formatted stack trace stack = traceback.format_exc() # Log t...
python
{ "resource": "" }
q9723
_HttpServerFamily.server_bind
train
def server_bind(self): """ Override server_bind to store the server name, even in IronPython. See https://ironpython.codeplex.com/workitem/29477 """ TCPServer.server_bind(self) host, port = self.socket.getsockname()[:2] self.server_port = port try: ...
python
{ "resource": "" }
q9724
encode_list
train
def encode_list(key, list_): # type: (str, Iterable) -> Dict[str, str] """ Converts a list into a space-separated string and puts it in a dictionary :param key: Dictionary key to store the list :param list_: A list of objects :return: A dictionary key->string or an empty dictionary """ ...
python
{ "resource": "" }
q9725
package_name
train
def package_name(package): # type: (str) -> str """ Returns the package name of the given module name """ if not package: return "" lastdot = package.rfind(".") if lastdot == -1: return package return package[:lastdot]
python
{ "resource": "" }
q9726
encode_osgi_props
train
def encode_osgi_props(ed): # type: (EndpointDescription) -> Dict[str, str] """ Prepares a dictionary of OSGi properties for the given EndpointDescription """ result_props = {} intfs = ed.get_interfaces() result_props[OBJECTCLASS] = " ".join(intfs) for intf in intfs: pkg_name = pa...
python
{ "resource": "" }
q9727
decode_list
train
def decode_list(input_props, name): # type: (Dict[str, str], str) -> List[str] """ Decodes a space-separated list """ val_str = input_props.get(name, None) if val_str: return val_str.split(" ") return []
python
{ "resource": "" }
q9728
decode_osgi_props
train
def decode_osgi_props(input_props): # type: (Dict[str, Any]) -> Dict[str, Any] """ Decodes the OSGi properties of the given endpoint properties """ result_props = {} intfs = decode_list(input_props, OBJECTCLASS) result_props[OBJECTCLASS] = intfs for intf in intfs: package_key = E...
python
{ "resource": "" }
q9729
decode_endpoint_props
train
def decode_endpoint_props(input_props): # type: (Dict) -> Dict[str, Any] """ Decodes the endpoint properties from the given dictionary """ ed_props = decode_osgi_props(input_props) ed_props[ECF_ENDPOINT_CONTAINERID_NAMESPACE] = input_props[ ECF_ENDPOINT_CONTAINERID_NAMESPACE ] ed...
python
{ "resource": "" }
q9730
encode_endpoint_props
train
def encode_endpoint_props(ed): """ Encodes the properties of the given EndpointDescription """ props = encode_osgi_props(ed) props[ECF_RSVC_ID] = "{0}".format(ed.get_remoteservice_id()[1]) props[ECF_ENDPOINT_ID] = "{0}".format(ed.get_container_id()[1]) props[ECF_ENDPOINT_CONTAINERID_NAMESPAC...
python
{ "resource": "" }
q9731
EndpointDescription.is_same_service
train
def is_same_service(self, endpoint): # type: (EndpointDescription) -> bool """ Tests if this endpoint and the given one have the same framework UUID and service ID :param endpoint: Another endpoint :return: True if both endpoints represent the same remote service ...
python
{ "resource": "" }
q9732
MqttClient.generate_id
train
def generate_id(cls, prefix="pelix-"): """ Generates a random MQTT client ID :param prefix: Client ID prefix (truncated to 8 chars) :return: A client ID of 22 or 23 characters """ if not prefix: # Normalize string prefix = "" else: ...
python
{ "resource": "" }
q9733
MqttClient.set_will
train
def set_will(self, topic, payload, qos=0, retain=False): """ Sets up the will message :param topic: Topic of the will message :param payload: Content of the message :param qos: Quality of Service :param retain: The message will be retained :raise ValueError: Inva...
python
{ "resource": "" }
q9734
MqttClient.connect
train
def connect(self, host="localhost", port=1883, keepalive=60): """ Connects to the MQTT server. The client will automatically try to reconnect to this server when the connection is lost. :param host: MQTT server host :param port: MQTT server port :param keepalive: Maximum...
python
{ "resource": "" }
q9735
MqttClient.disconnect
train
def disconnect(self): """ Disconnects from the MQTT server """ # Stop the timer self.__stop_timer() # Unlock all publishers for event in self.__in_flight.values(): event.set() # Disconnect from the server self.__mqtt.disconnect() ...
python
{ "resource": "" }
q9736
MqttClient.publish
train
def publish(self, topic, payload, qos=0, retain=False, wait=False): """ Sends a message through the MQTT connection :param topic: Message topic :param payload: Message content :param qos: Quality of Service :param retain: Retain flag :param wait: If True, prepare...
python
{ "resource": "" }
q9737
MqttClient.__start_timer
train
def __start_timer(self, delay): """ Starts the reconnection timer :param delay: Delay (in seconds) before calling the reconnection method """ self.__timer = threading.Timer(delay, self.__reconnect) self.__timer.daemon = True self.__timer.start()
python
{ "resource": "" }
q9738
MqttClient.__reconnect
train
def __reconnect(self): """ Tries to connect to the MQTT server """ # Cancel the timer, if any self.__stop_timer() try: # Try to reconnect the server result_code = self.__mqtt.reconnect() if result_code: # Something wron...
python
{ "resource": "" }
q9739
MqttClient.__on_connect
train
def __on_connect(self, client, userdata, flags, result_code): # pylint: disable=W0613 """ Client connected to the server :param client: Connected Paho client :param userdata: User data (unused) :param flags: Response flags sent by the broker :param result_code: C...
python
{ "resource": "" }
q9740
MqttClient.__on_disconnect
train
def __on_disconnect(self, client, userdata, result_code): # pylint: disable=W0613 """ Client has been disconnected from the server :param client: Client that received the message :param userdata: User data (unused) :param result_code: Disconnection reason (0: expected, 1...
python
{ "resource": "" }
q9741
MqttClient.__on_message
train
def __on_message(self, client, userdata, msg): # pylint: disable=W0613 """ A message has been received from a server :param client: Client that received the message :param userdata: User data (unused) :param msg: A MQTTMessage bean """ # Notify the caller...
python
{ "resource": "" }
q9742
MqttClient.__on_publish
train
def __on_publish(self, client, userdata, mid): # pylint: disable=W0613 """ A message has been published by a server :param client: Client that received the message :param userdata: User data (unused) :param mid: Message ID """ try: self.__in_f...
python
{ "resource": "" }
q9743
to_import_properties
train
def to_import_properties(properties): # type: (dict) -> dict """ Returns a dictionary where export properties have been replaced by import ones :param properties: A dictionary of service properties (with export keys) :return: A dictionary with import properties """ # Copy the given dict...
python
{ "resource": "" }
q9744
compute_exported_specifications
train
def compute_exported_specifications(svc_ref): # type: (pelix.framework.ServiceReference) -> List[str] """ Computes the list of specifications exported by the given service :param svc_ref: A ServiceReference :return: The list of exported specifications (or an empty list) """ if svc_ref.get_p...
python
{ "resource": "" }
q9745
format_specifications
train
def format_specifications(specifications): # type: (Iterable[str]) -> List[str] """ Transforms the interfaces names into URI strings, with the interface implementation language as a scheme. :param specifications: Specifications to transform :return: The transformed names """ transformed...
python
{ "resource": "" }
q9746
ExportEndpoint.get_properties
train
def get_properties(self): # type: () -> dict """ Returns merged properties :return: Endpoint merged properties """ # Get service properties properties = self.__reference.get_properties() # Merge with local properties properties.update(self.__prop...
python
{ "resource": "" }
q9747
ExportEndpoint.make_import_properties
train
def make_import_properties(self): # type: () -> dict """ Returns the properties of this endpoint where export properties have been replaced by import ones :return: A dictionary with import properties """ # Convert merged properties props = to_import_prope...
python
{ "resource": "" }
q9748
EndpointDescription.__check_properties
train
def __check_properties(props): # type: (dict) -> None """ Checks that the given dictionary doesn't have export keys and has import keys :param props: Properties to validate :raise ValueError: Invalid properties """ # Mandatory properties mandatory...
python
{ "resource": "" }
q9749
EndpointDescription.matches
train
def matches(self, ldap_filter): # type: (Any[str, pelix.ldapfilter.LDAPFilter]) -> bool """ Tests the properties of this EndpointDescription against the given filter :param ldap_filter: A filter :return: True if properties matches the filter """ return pe...
python
{ "resource": "" }
q9750
EndpointDescription.to_import
train
def to_import(self): # type: () -> ImportEndpoint """ Converts an EndpointDescription bean to an ImportEndpoint :return: An ImportEndpoint bean """ # Properties properties = self.get_properties() # Framework UUID fw_uid = self.get_framework_uuid(...
python
{ "resource": "" }
q9751
EndpointDescription.from_export
train
def from_export(cls, endpoint): # type: (ExportEndpoint) -> EndpointDescription """ Converts an ExportEndpoint bean to an EndpointDescription :param endpoint: An ExportEndpoint bean :return: An EndpointDescription bean """ assert isinstance(endpoint, ExportEndpoi...
python
{ "resource": "" }
q9752
EDEFReader._parse_description
train
def _parse_description(self, node): # type: (ElementTree.Element) -> EndpointDescription """ Parse an endpoint description node :param node: The endpoint description node :return: The parsed EndpointDescription bean :raise KeyError: Attribute missing :raise Value...
python
{ "resource": "" }
q9753
EDEFReader._parse_property
train
def _parse_property(self, node): # type: (ElementTree.Element) -> Tuple[str, Any] """ Parses a property node :param node: The property node :return: A (name, value) tuple :raise KeyError: Attribute missing """ # Get information name = node.attrib[...
python
{ "resource": "" }
q9754
EDEFReader._parse_value_node
train
def _parse_value_node(self, vtype, node): # type: (str, ElementTree.Element) -> Any """ Parses a value node :param vtype: The value type :param node: The value node :return: The parsed value """ kind = node.tag if kind == TAG_XML: # Ra...
python
{ "resource": "" }
q9755
EDEFReader.parse
train
def parse(self, xml_str): # type: (str) -> List[EndpointDescription] """ Parses an EDEF XML string :param xml_str: An XML string :return: The list of parsed EndpointDescription """ # Parse the document root = ElementTree.fromstring(xml_str) if roo...
python
{ "resource": "" }
q9756
EDEFWriter._make_endpoint
train
def _make_endpoint(self, root_node, endpoint): # type: (ElementTree.Element, EndpointDescription) -> None """ Converts the given endpoint bean to an XML Element :param root_node: The XML root Element :param endpoint: An EndpointDescription bean """ endpoint_node ...
python
{ "resource": "" }
q9757
EDEFWriter._make_xml
train
def _make_xml(self, endpoints): # type: (List[EndpointDescription]) -> ElementTree.Element """ Converts the given endpoint description beans into an XML Element :param endpoints: A list of EndpointDescription beans :return: A string containing an XML document """ ...
python
{ "resource": "" }
q9758
EDEFWriter.write
train
def write(self, endpoints, filename): # type: (List[EndpointDescription], str) -> None """ Writes the given endpoint descriptions to the given file :param endpoints: A list of EndpointDescription beans :param filename: Name of the file where to write the XML :raise IOErr...
python
{ "resource": "" }
q9759
is_from_parent
train
def is_from_parent(cls, attribute_name, value=None): # type: (type, str, bool) -> bool """ Tests if the current attribute value is shared by a parent of the given class. Returns None if the attribute value is None. :param cls: Child class with the requested attribute :param attribute_name:...
python
{ "resource": "" }
q9760
get_factory_context
train
def get_factory_context(cls): # type: (type) -> FactoryContext """ Retrieves the factory context object associated to a factory. Creates it if needed :param cls: The factory class :return: The factory class context """ context = getattr(cls, constants.IPOPO_FACTORY_CONTEXT, None) i...
python
{ "resource": "" }
q9761
get_method_description
train
def get_method_description(method): # type: (Callable) -> str """ Retrieves a description of the given method. If possible, the description contains the source file name and line. :param method: A method :return: A description of the method (at least its name) :raise AttributeError: Given o...
python
{ "resource": "" }
q9762
validate_method_arity
train
def validate_method_arity(method, *needed_args): # type: (Callable, *str) -> None """ Tests if the decorated method has a sufficient number of parameters. :param method: The method to be tested :param needed_args: The name (for description only) of the needed arguments, with...
python
{ "resource": "" }
q9763
_ipopo_setup_callback
train
def _ipopo_setup_callback(cls, context): # type: (type, FactoryContext) -> None """ Sets up the class _callback dictionary :param cls: The class to handle :param context: The factory class context """ assert inspect.isclass(cls) assert isinstance(context, FactoryContext) if context...
python
{ "resource": "" }
q9764
_ipopo_setup_field_callback
train
def _ipopo_setup_field_callback(cls, context): # type: (type, FactoryContext) -> None """ Sets up the class _field_callback dictionary :param cls: The class to handle :param context: The factory class context """ assert inspect.isclass(cls) assert isinstance(context, FactoryContext) ...
python
{ "resource": "" }
q9765
_append_object_entry
train
def _append_object_entry(obj, list_name, entry): # type: (Any, str, Any) -> None """ Appends the given entry in the given object list. Creates the list field if needed. :param obj: The object that contains the list :param list_name: The name of the list member in *obj* :param entry: The ent...
python
{ "resource": "" }
q9766
_get_specifications
train
def _get_specifications(specifications): """ Computes the list of strings corresponding to the given specifications :param specifications: A string, a class or a list of specifications :return: A list of strings :raise ValueError: Invalid specification found """ if not specifications or spe...
python
{ "resource": "" }
q9767
PostRegistration
train
def PostRegistration(method): # pylint: disable=C0103 """ The service post-registration callback decorator is called after a service of the component has been registered to the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered servi...
python
{ "resource": "" }
q9768
PostUnregistration
train
def PostUnregistration(method): # pylint: disable=C0103 """ The service post-unregistration callback decorator is called after a service of the component has been unregistered from the framework. The decorated method must accept the :class:`~pelix.framework.ServiceReference` of the registered ...
python
{ "resource": "" }
q9769
_ShellUtils.bundlestate_to_str
train
def bundlestate_to_str(state): """ Converts a bundle state integer to a string """ states = { pelix.Bundle.INSTALLED: "INSTALLED", pelix.Bundle.ACTIVE: "ACTIVE", pelix.Bundle.RESOLVED: "RESOLVED", pelix.Bundle.STARTING: "STARTING", ...
python
{ "resource": "" }
q9770
_ShellUtils.make_table
train
def make_table(headers, lines, prefix=None): """ Generates an ASCII table according to the given headers and lines :param headers: List of table headers (N-tuple) :param lines: List of table lines (N-tuples) :param prefix: Optional prefix for each line :return: The ASCII...
python
{ "resource": "" }
q9771
_ShellService.bind_handler
train
def bind_handler(self, svc_ref): """ Called if a command service has been found. Registers the methods of this service. :param svc_ref: A reference to the found service :return: True if the commands have been registered """ if svc_ref in self._bound_references: ...
python
{ "resource": "" }
q9772
_ShellService.unbind_handler
train
def unbind_handler(self, svc_ref): """ Called if a command service is gone. Unregisters its commands. :param svc_ref: A reference to the unbound service :return: True if the commands have been unregistered """ if svc_ref not in self._bound_references: ...
python
{ "resource": "" }
q9773
_ShellService.bundle_details
train
def bundle_details(self, io_handler, bundle_id): """ Prints the details of the bundle with the given ID or name """ bundle = None try: # Convert the given ID into an integer bundle_id = int(bundle_id) except ValueError: # Not an intege...
python
{ "resource": "" }
q9774
_ShellService.bundles_list
train
def bundles_list(self, io_handler, name=None): """ Lists the bundles in the framework and their state. Possibility to filter on the bundle name. """ # Head of the table headers = ("ID", "Name", "State", "Version") # Get the bundles bundles = self._context...
python
{ "resource": "" }
q9775
_ShellService.service_details
train
def service_details(self, io_handler, service_id): """ Prints the details of the service with the given ID """ svc_ref = self._context.get_service_reference( None, "({0}={1})".format(constants.SERVICE_ID, service_id) ) if svc_ref is None: io_handle...
python
{ "resource": "" }
q9776
_ShellService.services_list
train
def services_list(self, io_handler, specification=None): """ Lists the services in the framework. Possibility to filter on an exact specification. """ # Head of the table headers = ("ID", "Specifications", "Bundle", "Ranking") # Lines references = ( ...
python
{ "resource": "" }
q9777
_ShellService.properties_list
train
def properties_list(self, io_handler): """ Lists the properties of the framework """ # Get the framework framework = self._context.get_framework() # Head of the table headers = ("Property Name", "Value") # Lines lines = [item for item in framewor...
python
{ "resource": "" }
q9778
_ShellService.property_value
train
def property_value(self, io_handler, name): """ Prints the value of the given property, looking into framework properties then environment variables. """ value = self._context.get_property(name) if value is None: # Avoid printing "None" value = "" ...
python
{ "resource": "" }
q9779
_ShellService.environment_list
train
def environment_list(self, io_handler): """ Lists the framework process environment variables """ # Head of the table headers = ("Environment Variable", "Value") # Lines lines = [item for item in os.environ.items()] # Sort lines lines.sort() ...
python
{ "resource": "" }
q9780
_ShellService.change_dir
train
def change_dir(self, session, path): """ Changes the working directory """ if path == "-": # Previous directory path = self._previous_path or "." try: previous = os.getcwd() os.chdir(path) except IOError as ex: ...
python
{ "resource": "" }
q9781
_ShellService.start
train
def start(self, io_handler, bundle_id, *bundles_ids): """ Starts the bundles with the given IDs. Stops on first failure. """ for bid in (bundle_id,) + bundles_ids: try: # Got an int => it's a bundle ID bid = int(bid) except ValueErr...
python
{ "resource": "" }
q9782
_ShellService.stop
train
def stop(self, io_handler, bundle_id, *bundles_ids): """ Stops the bundles with the given IDs. Stops on first failure. """ for bid in (bundle_id,) + bundles_ids: bundle = self.__get_bundle(io_handler, bid) if bundle is not None: io_handler.write_li...
python
{ "resource": "" }
q9783
_ShellService.install
train
def install(self, io_handler, module_name): """ Installs the bundle with the given module name """ bundle = self._context.install_bundle(module_name) io_handler.write_line("Bundle ID: {0}", bundle.get_bundle_id()) return bundle.get_bundle_id()
python
{ "resource": "" }
q9784
TemporalDependency.__cancel_timer
train
def __cancel_timer(self): """ Cancels the timer, and calls its target method immediately """ if self.__timer is not None: self.__timer.cancel() self.__unbind_call(True) self.__timer_args = None self.__timer = None
python
{ "resource": "" }
q9785
TemporalDependency.__unbind_call
train
def __unbind_call(self, still_valid): """ Calls the iPOPO unbind method """ with self._lock: if self.__timer is not None: # Timeout expired, we're not valid anymore self.__timer = None self.__still_valid = still_valid ...
python
{ "resource": "" }
q9786
_JabsorbRpcServlet.do_POST
train
def do_POST(self, request, response): # pylint: disable=C0103 """ Handle a POST request :param request: The HTTP request bean :param response: The HTTP response handler """ # Get the request JSON content data = jsonrpclib.loads(to_str(request.read_data())...
python
{ "resource": "" }
q9787
RestDispatcher._rest_dispatch
train
def _rest_dispatch(self, request, response): # type: (AbstractHTTPServletRequest, AbstractHTTPServletResponse) -> None """ Dispatches the request :param request: Request bean :param response: Response bean """ # Extract request information http_verb = req...
python
{ "resource": "" }
q9788
RestDispatcher._setup_rest_dispatcher
train
def _setup_rest_dispatcher(self): """ Finds all methods to call when handling a route """ for _, method in inspect.getmembers(self, inspect.isroutine): try: config = getattr(method, HTTP_ROUTE_ATTRIBUTE) except AttributeError: # Not...
python
{ "resource": "" }
q9789
StoredInstance.check_event
train
def check_event(self, event): # type: (ServiceEvent) -> bool """ Tests if the given service event must be handled or ignored, based on the state of the iPOPO service and on the content of the event. :param event: A service event :return: True if the event can be handled,...
python
{ "resource": "" }
q9790
StoredInstance.bind
train
def bind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to inject a new service and update the component life cycle. """ with self._lock: self.__set_binding(dependency, svc, svc_ref) ...
python
{ "resource": "" }
q9791
StoredInstance.update
train
def update(self, dependency, svc, svc_ref, old_properties, new_value=False): # type: (Any, Any, ServiceReference, dict, bool) -> None """ Called by a dependency manager when the properties of an injected dependency have been updated. :param dependency: The dependency handler ...
python
{ "resource": "" }
q9792
StoredInstance.unbind
train
def unbind(self, dependency, svc, svc_ref): # type: (Any, Any, ServiceReference) -> None """ Called by a dependency manager to remove an injected service and to update the component life cycle. """ with self._lock: # Invalidate first (if needed) se...
python
{ "resource": "" }
q9793
StoredInstance.set_controller_state
train
def set_controller_state(self, name, value): # type: (str, bool) -> None """ Sets the state of the controller with the given name :param name: The name of the controller :param value: The new value of the controller """ with self._lock: self._controll...
python
{ "resource": "" }
q9794
StoredInstance.update_property
train
def update_property(self, name, old_value, new_value): # type: (str, Any, Any) -> None """ Handles a property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value """ w...
python
{ "resource": "" }
q9795
StoredInstance.update_hidden_property
train
def update_hidden_property(self, name, old_value, new_value): # type: (str, Any, Any) -> None """ Handles an hidden property changed event :param name: The changed property name :param old_value: The previous property value :param new_value: The new property value ...
python
{ "resource": "" }
q9796
StoredInstance.get_handlers
train
def get_handlers(self, kind=None): """ Retrieves the handlers of the given kind. If kind is None, all handlers are returned. :param kind: The kind of the handlers to return :return: A list of handlers, or an empty list """ with self._lock: if kind is ...
python
{ "resource": "" }
q9797
StoredInstance.check_lifecycle
train
def check_lifecycle(self): """ Tests if the state of the component must be updated, based on its own state and on the state of its dependencies """ with self._lock: # Validation flags was_valid = self.state == StoredInstance.VALID can_validate ...
python
{ "resource": "" }
q9798
StoredInstance.update_bindings
train
def update_bindings(self): # type: () -> bool """ Updates the bindings of the given component :return: True if the component can be validated """ with self._lock: all_valid = True for handler in self.get_handlers(handlers_const.KIND_DEPENDENCY): ...
python
{ "resource": "" }
q9799
StoredInstance.retry_erroneous
train
def retry_erroneous(self, properties_update): # type: (dict) -> int """ Removes the ERRONEOUS state from a component and retries a validation :param properties_update: A dictionary to update component properties :return: The new state of the component """ with se...
python
{ "resource": "" }