_id
stringlengths
2
7
title
stringlengths
1
88
partition
stringclasses
3 values
text
stringlengths
75
19.8k
language
stringclasses
1 value
meta_information
dict
q16300
KATCPClientResourceContainer.set_sampling_strategies
train
def set_sampling_strategies(self, filter, strategy_and_parms): """Set sampling strategies for filtered sensors - these sensors have to exsist""" result_list = yield self.list_sensors(filter=filter) sensor_dict = {} for result in result_list: sensor_name = result.object.normal...
python
{ "resource": "" }
q16301
KATCPClientResourceContainer.add_child_resource_client
train
def add_child_resource_client(self, res_name, res_spec): """Add a resource client to the container and start the resource connection""" res_spec = dict(res_spec) res_spec['name'] = res_name res = self.client_resource_factory( res_spec, parent=self, logger=self._logger) ...
python
{ "resource": "" }
q16302
KATCPClientResourceContainer.stop
train
def stop(self): """Stop all child resources""" for child_name, child in dict.items(self.children): # Catch child exceptions when stopping so we make sure to stop all children # that want to listen. try: child.stop() except Exception: ...
python
{ "resource": "" }
q16303
make_chunk
train
def make_chunk(chunk_type, chunk_data): """Create a raw chunk by composing chunk type and data. It calculates chunk length and CRC for you. :arg str chunk_type: PNG chunk type. :arg bytes chunk_data: PNG chunk data, **excluding chunk length, type, and CRC**. :rtype: bytes """ out = struct.pack("!I", len(chunk_d...
python
{ "resource": "" }
q16304
PNG.init
train
def init(self): """Extract some info from chunks""" for type_, data in self.chunks: if type_ == "IHDR": self.hdr = data elif type_ == "IEND": self.end = data if self.hdr: # grab w, h info self.width, self.height = struct.unpack("!II", self.hdr[8:16])
python
{ "resource": "" }
q16305
readme
train
def readme(): """Live reload readme""" from livereload import Server server = Server() server.watch("README.rst", "py cute.py readme_build") server.serve(open_url_delay=1, root="build/readme")
python
{ "resource": "" }
q16306
BenchmarkServer.request_add_sensor
train
def request_add_sensor(self, sock, msg): """ add a sensor """ self.add_sensor(Sensor(int, 'int_sensor%d' % len(self._sensors), 'descr', 'unit', params=[-10, 10])) return Message.reply('add-sensor', 'ok')
python
{ "resource": "" }
q16307
normalize_strategy_parameters
train
def normalize_strategy_parameters(params): """Normalize strategy parameters to be a list of strings. Parameters ---------- params : (space-delimited) string or sequence of strings/numbers Parameters expected by :class:`SampleStrategy` object, in various forms, where the first parameter ...
python
{ "resource": "" }
q16308
KATCPResource.wait
train
def wait(self, sensor_name, condition_or_value, timeout=5): """Wait for a sensor in this resource to satisfy a condition. Parameters ---------- sensor_name : string The name of the sensor to check condition_or_value : obj or callable, or seq of objs or callables ...
python
{ "resource": "" }
q16309
KATCPResource.set_sampling_strategies
train
def set_sampling_strategies(self, filter, strategy_and_params): """Set a sampling strategy for all sensors that match the specified filter. Parameters ---------- filter : string The regular expression filter to use to select the sensors to which to apply the spec...
python
{ "resource": "" }
q16310
KATCPResource.set_sampling_strategy
train
def set_sampling_strategy(self, sensor_name, strategy_and_params): """Set a sampling strategy for a specific sensor. Parameters ---------- sensor_name : string The specific sensor. strategy_and_params : seq of str or str As tuple contains (<strat_name>, [...
python
{ "resource": "" }
q16311
KATCPSensor.set_strategy
train
def set_strategy(self, strategy, params=None): """Set current sampling strategy for sensor. Add this footprint for backwards compatibility. Parameters ---------- strategy : seq of str or str As tuple contains (<strat_name>, [<strat_parm1>, ...]) where the strategy ...
python
{ "resource": "" }
q16312
KATCPSensor.register_listener
train
def register_listener(self, listener, reading=False): """Add a callback function that is called when sensor value is updated. The callback footprint is received_timestamp, timestamp, status, value. Parameters ---------- listener : function Callback signature: if read...
python
{ "resource": "" }
q16313
KATCPSensor.set_value
train
def set_value(self, value, status=Sensor.NOMINAL, timestamp=None): """Set sensor value with optinal specification of status and timestamp""" if timestamp is None: timestamp = self._manager.time() self.set(timestamp, status, value)
python
{ "resource": "" }
q16314
KATCPSensor.get_reading
train
def get_reading(self): """Get a fresh sensor reading from the KATCP resource Returns ------- reply : tornado Future resolving with :class:`KATCPSensorReading` object Note ---- As a side-effect this will update the reading stored in this object, and result in ...
python
{ "resource": "" }
q16315
KATCPSensor.get_value
train
def get_value(self): """Get a fresh sensor value from the KATCP resource Returns ------- reply : tornado Future resolving with :class:`KATCPSensorReading` object Note ---- As a side-effect this will update the reading stored in this object, and result in ...
python
{ "resource": "" }
q16316
KATCPSensor.get_status
train
def get_status(self): """Get a fresh sensor status from the KATCP resource Returns ------- reply : tornado Future resolving with :class:`KATCPSensorReading` object Note ---- As a side-effect this will update the reading stored in this object, and result in ...
python
{ "resource": "" }
q16317
KATCPSensor.wait
train
def wait(self, condition_or_value, timeout=None): """Wait for the sensor to satisfy a condition. Parameters ---------- condition_or_value : obj or callable, or seq of objs or callables If obj, sensor.value is compared with obj. If callable, condition_or_value(rea...
python
{ "resource": "" }
q16318
fake_KATCP_client_resource_factory
train
def fake_KATCP_client_resource_factory( KATCPClientResourceClass, fake_options, resource_spec, *args, **kwargs): """Create a fake KATCPClientResource-like class and a fake-manager Parameters ---------- KATCPClientResourceClass : class Subclass of :class:`katcp.resource_client.KATCPClien...
python
{ "resource": "" }
q16319
fake_KATCP_client_resource_container_factory
train
def fake_KATCP_client_resource_container_factory( KATCPClientResourceContainerClass, fake_options, resources_spec, *args, **kwargs): """Create a fake KATCPClientResourceContainer-like class and a fake-manager Parameters ---------- KATCPClientResourceContainerClass : class Subcla...
python
{ "resource": "" }
q16320
FakeInspectingClientManager.add_sensors
train
def add_sensors(self, sensor_infos): """Add fake sensors sensor_infos is a dict <sensor-name> : ( <description>, <unit>, <sensor-type>, <params>*) The sensor info is string-reprs of whatever they are, as they would be on the wire in a real KATCP connection. Values are passed...
python
{ "resource": "" }
q16321
FakeInspectingClientManager.add_request_handlers_dict
train
def add_request_handlers_dict(self, rh_dict): """Add fake request handler functions from a dict keyed by request name Note the keys must be the KATCP message name (i.e. "the-request", not "the_request") The request-handler interface is more or less compatible with request handler API ...
python
{ "resource": "" }
q16322
ExponentialRandomBackoff.failed
train
def failed(self): """Call whenever an action has failed, grows delay exponentially After calling failed(), the `delay` property contains the next delay """ try: self._validate_parameters() self._base_delay = min( self._base_delay * self.exp_fac, ...
python
{ "resource": "" }
q16323
_InformHookDeviceClient.hook_inform
train
def hook_inform(self, inform_name, callback): """Hookup a function to be called when an inform is received. Useful for interface-changed and sensor-status informs. Parameters ---------- inform_name : str The name of the inform. callback : function ...
python
{ "resource": "" }
q16324
_InformHookDeviceClient.handle_inform
train
def handle_inform(self, msg): """Call callbacks on hooked informs followed by normal processing""" try: for func in self._inform_hooks.get(msg.name, []): func(msg) except Exception: self._logger.warning('Call to function "{0}" with message "{1}".' ...
python
{ "resource": "" }
q16325
InspectingClientAsync.until_state
train
def until_state(self, desired_state, timeout=None): """ Wait until state is desired_state, InspectingClientStateType instance Returns a future """ return self._state.until_state(desired_state, timeout=timeout)
python
{ "resource": "" }
q16326
InspectingClientAsync.connect
train
def connect(self, timeout=None): """Connect to KATCP interface, starting what is needed Parameters ---------- timeout : float, None Time to wait until connected. No waiting if None. Raises ------ :class:`tornado.gen.TimeoutError` if the connect time...
python
{ "resource": "" }
q16327
InspectingClientAsync.inspect
train
def inspect(self): """Inspect device requests and sensors, update model Returns ------- Tornado future that resolves with: model_changes : Nested AttrDict or None Contains sets of added/removed request/sensor names Example structure: {'req...
python
{ "resource": "" }
q16328
InspectingClientAsync.inspect_requests
train
def inspect_requests(self, name=None, timeout=None): """Inspect all or one requests on the device. Update requests index. Parameters ---------- name : str or None, optional Name of the request or None to get all requests. timeout : float or None, optional ...
python
{ "resource": "" }
q16329
InspectingClientAsync._get_request_timeout_hints
train
def _get_request_timeout_hints(self, name=None, timeout=None): """Get request timeout hints from device Parameters ========= name : str or None, optional Name of the request or None to get all request timeout hints. timeout : float seconds Timeout for ?re...
python
{ "resource": "" }
q16330
InspectingClientAsync.inspect_sensors
train
def inspect_sensors(self, name=None, timeout=None): """Inspect all or one sensor on the device. Update sensors index. Parameters ---------- name : str or None, optional Name of the sensor or None to get all sensors. timeout : float or None, optional Timeo...
python
{ "resource": "" }
q16331
InspectingClientAsync.future_check_sensor
train
def future_check_sensor(self, name, update=None): """Check if the sensor exists. Used internally by future_get_sensor. This method is aware of synchronisation in progress and if inspection of the server is allowed. Parameters ---------- name : str Name of th...
python
{ "resource": "" }
q16332
InspectingClientAsync.future_get_sensor
train
def future_get_sensor(self, name, update=None): """Get the sensor object. Check if we have information for this sensor, if not connect to server and update (if allowed) to get information. Parameters ---------- name : string Name of the sensor. updat...
python
{ "resource": "" }
q16333
InspectingClientAsync.future_check_request
train
def future_check_request(self, name, update=None): """Check if the request exists. Used internally by future_get_request. This method is aware of synchronisation in progress and if inspection of the server is allowed. Parameters ---------- name : str Name of...
python
{ "resource": "" }
q16334
InspectingClientAsync.future_get_request
train
def future_get_request(self, name, update=None): """Get the request object. Check if we have information for this request, if not connect to server and update (if allowed). Parameters ---------- name : string Name of the request. update : bool or Non...
python
{ "resource": "" }
q16335
InspectingClientAsync._cb_inform_sensor_status
train
def _cb_inform_sensor_status(self, msg): """Update received for an sensor.""" timestamp = msg.arguments[0] num_sensors = int(msg.arguments[1]) assert len(msg.arguments) == 2 + num_sensors * 3 for n in xrange(num_sensors): name = msg.arguments[2 + n * 3] st...
python
{ "resource": "" }
q16336
InspectingClientAsync._cb_inform_interface_change
train
def _cb_inform_interface_change(self, msg): """Update the sensors and requests available.""" self._logger.debug('cb_inform_interface_change(%s)', msg) self._interface_changed.set()
python
{ "resource": "" }
q16337
InspectingClientAsync._difference
train
def _difference(self, original_keys, updated_keys, name, item_index): """Calculate difference between the original and updated sets of keys. Removed items will be removed from item_index, new items should have been added by the discovery process. (?help or ?sensor-list) This method is ...
python
{ "resource": "" }
q16338
SampleStrategy.get_strategy
train
def get_strategy(cls, strategyName, inform_callback, sensor, *params, **kwargs): """Factory method to create a strategy object. Parameters ---------- strategyName : str Name of strategy. inform_callback : callable, signature inform_callback(senso...
python
{ "resource": "" }
q16339
SampleStrategy.get_sampling_formatted
train
def get_sampling_formatted(self): """The current sampling strategy and parameters. The strategy is returned as a string and the values in the parameter list are formatted as strings using the formatter for this sensor type. Returns ------- strategy_name : string...
python
{ "resource": "" }
q16340
SampleStrategy.attach
train
def attach(self): """Attach strategy to its sensor and send initial update.""" s = self._sensor self.update(s, s.read()) self._sensor.attach(self)
python
{ "resource": "" }
q16341
SampleStrategy.cancel
train
def cancel(self): """Detach strategy from its sensor and cancel ioloop callbacks.""" if self.OBSERVE_UPDATES: self.detach() self.ioloop.add_callback(self.cancel_timeouts)
python
{ "resource": "" }
q16342
SampleStrategy.start
train
def start(self): """Start operating the strategy. Subclasses that override start() should call the super method before it does anything that uses the ioloop. This will attach to the sensor as an observer if :attr:`OBSERVE_UPDATES` is True, and sets :attr:`_ioloop_thread_id` usin...
python
{ "resource": "" }
q16343
SampleStrategy.inform
train
def inform(self, reading): """Inform strategy creator of the sensor status.""" try: self._inform_callback(self._sensor, reading) except Exception: log.exception('Unhandled exception trying to send {!r} ' 'for sensor {!r} of type {!r}' ...
python
{ "resource": "" }
q16344
IOLoopManager.start
train
def start(self, timeout=None): """Start managed ioloop thread, or do nothing if not managed. If a timeout is passed, it will block until the the event loop is alive (or the timeout expires) even if the ioloop is not managed. """ if not self._ioloop: raise RuntimeErr...
python
{ "resource": "" }
q16345
IOLoopManager.join
train
def join(self, timeout=None): """Join managed ioloop thread, or do nothing if not managed.""" if not self._ioloop_managed: # Do nothing if the loop is not managed return try: self._ioloop_thread.join(timeout) except AttributeError: raise Ru...
python
{ "resource": "" }
q16346
GenericSensorTree.update
train
def update(self, sensor, reading): """Update callback used by sensors to notify obervers of changes. Parameters ---------- sensor : :class:`katcp.Sensor` object The sensor whose value has changed. reading : (timestamp, status, value) tuple Sensor reading ...
python
{ "resource": "" }
q16347
GenericSensorTree._add_sensor
train
def _add_sensor(self, sensor): """Add a new sensor to the tree. Parameters ---------- sensor : :class:`katcp.Sensor` object New sensor to add to the tree. """ self._parent_to_children[sensor] = set() self._child_to_parents[sensor] = set()
python
{ "resource": "" }
q16348
GenericSensorTree.add_links
train
def add_links(self, parent, children): """Create dependency links from parent to child. Any sensors not in the tree are added. After all dependency links have been created, the parent is recalculated and the tree attaches to any sensors it was not yet attached to. Links that already exi...
python
{ "resource": "" }
q16349
GenericSensorTree.remove_links
train
def remove_links(self, parent, children): """Remove dependency links from parent to child. Any sensors that have no dependency links are removed from the tree and the tree detaches from each sensor removed. After all dependency links have been removed the parent is recalculated. Links t...
python
{ "resource": "" }
q16350
GenericSensorTree.children
train
def children(self, parent): """Return set of children of parent. Parameters ---------- parent : :class:`katcp.Sensor` object Parent whose children to return. Returns ------- children : set of :class:`katcp.Sensor` objects The child sensor...
python
{ "resource": "" }
q16351
GenericSensorTree.parents
train
def parents(self, child): """Return set of parents of child. Parameters ---------- child : :class:`katcp.Sensor` object Child whose parents to return. Returns ------- parents : set of :class:`katcp.Sensor` objects The parent sensors of ch...
python
{ "resource": "" }
q16352
BooleanSensorTree.add
train
def add(self, parent, child): """Add a pair of boolean sensors. Parent depends on child. Parameters ---------- parent : boolean instance of :class:`katcp.Sensor` The sensor that depends on child. child : boolean instance of :class:`katcp.Sensor` ...
python
{ "resource": "" }
q16353
BooleanSensorTree.remove
train
def remove(self, parent, child): """Remove a dependency between parent and child. Parameters ---------- parent : boolean instance of :class:`katcp.Sensor` The sensor that used to depend on child. child : boolean instance of :class:`katcp.Sensor` or None T...
python
{ "resource": "" }
q16354
AggregateSensorTree.add
train
def add(self, parent, rule_function, children): """Create an aggregation rule. Parameters ---------- parent : :class:`katcp.Sensor` object The aggregate sensor. rule_function : f(parent, children) Function to update the parent sensor value. childr...
python
{ "resource": "" }
q16355
AggregateSensorTree.add_delayed
train
def add_delayed(self, parent, rule_function, child_names): """Create an aggregation rule before child sensors are present. Parameters ---------- parent : :class:`katcp.Sensor` object The aggregate sensor. rule_function : f(parent, children) Function to up...
python
{ "resource": "" }
q16356
AggregateSensorTree.register_sensor
train
def register_sensor(self, child): """Register a sensor required by an aggregate sensor registered with add_delayed. Parameters ---------- child : :class:`katcp.Sensor` object A child sensor required by one or more delayed aggregate sensors. """ child...
python
{ "resource": "" }
q16357
AggregateSensorTree._child_from_reference
train
def _child_from_reference(self, reference): """Returns the child sensor from its reference. Parameters ---------- reference : str Reference to sensor (typically its name). Returns ------- child : :class:`katcp.Sensor` object A child senso...
python
{ "resource": "" }
q16358
AggregateSensorTree.remove
train
def remove(self, parent): """Remove an aggregation rule. Parameters ---------- parent : :class:`katcp.Sensor` object The aggregate sensor to remove. """ if parent not in self._aggregates: raise ValueError("Sensor %r does not have an aggregate rul...
python
{ "resource": "" }
q16359
request
train
def request(*types, **options): """Decorator for request handler methods. The method being decorated should take a req argument followed by arguments matching the list of types. The decorator will unpack the request message into the arguments. Parameters ---------- types : list of kattypes...
python
{ "resource": "" }
q16360
return_reply
train
def return_reply(*types, **options): """Decorator for returning replies from request handler methods. The method being decorated should return an iterable of result values. If the first value is 'ok', the decorator will check the remaining values against the specified list of types (if any). If the...
python
{ "resource": "" }
q16361
send_reply
train
def send_reply(*types, **options): """Decorator for sending replies from request callback methods. This decorator constructs a reply from a list or tuple returned from a callback method, but unlike the return_reply decorator it also sends the reply rather than returning it. The list/tuple returned...
python
{ "resource": "" }
q16362
make_reply
train
def make_reply(msgname, types, arguments, major): """Helper method for constructing a reply message from a list or tuple. Parameters ---------- msgname : str Name of the reply message. types : list of kattypes The types of the reply message parameters (in order). arguments : lis...
python
{ "resource": "" }
q16363
minimum_katcp_version
train
def minimum_katcp_version(major, minor=0): """Decorator; exclude handler if server's protocol version is too low Useful for including default handler implementations for KATCP features that are only present in certain KATCP protocol versions Examples -------- >>> class MyDevice(DeviceServer): ...
python
{ "resource": "" }
q16364
request_timeout_hint
train
def request_timeout_hint(timeout_hint): """Decorator; add recommended client timeout hint to a request for request Useful for requests that take longer than average to reply. Hint is provided to clients via ?request-timeout-hint. Note this is only exposed if the device server sets the protocol version ...
python
{ "resource": "" }
q16365
unpack_types
train
def unpack_types(types, args, argnames, major): """Parse arguments according to types list. Parameters ---------- types : list of kattypes The types of the arguments (in order). args : list of strings The arguments to parse. argnames : list of strings The names of the ar...
python
{ "resource": "" }
q16366
pack_types
train
def pack_types(types, args, major): """Pack arguments according the the types list. Parameters ---------- types : list of kattypes The types of the arguments (in order). args : list of objects The arguments to format. major : integer Major version of KATCP to use when pa...
python
{ "resource": "" }
q16367
KatcpType.pack
train
def pack(self, value, nocheck=False, major=DEFAULT_KATCP_MAJOR): """Return the value formatted as a KATCP parameter. Parameters ---------- value : object The value to pack. nocheck : bool, optional Whether to check that the value is valid before ...
python
{ "resource": "" }
q16368
KatcpType.unpack
train
def unpack(self, packed_value, major=DEFAULT_KATCP_MAJOR): """Parse a KATCP parameter into an object. Parameters ---------- packed_value : str The unescaped KATCP string to parse into a value. major : int, optional Major version of KATCP to use when inter...
python
{ "resource": "" }
q16369
Int.check
train
def check(self, value, major): """Check whether the value is between the minimum and maximum. Raise a ValueError if it is not. """ if self._min is not None and value < self._min: raise ValueError("Integer %d is lower than minimum %d." % (value, ...
python
{ "resource": "" }
q16370
Discrete.check
train
def check(self, value, major): """Check whether the value in the set of allowed values. Raise a ValueError if it is not. """ if self._case_insensitive: value = value.lower() values = self._valid_values_lower caseflag = " (case-insensitive)" e...
python
{ "resource": "" }
q16371
DiscreteMulti.check
train
def check(self, value, major): """Check that each item in the value list is in the allowed set.""" for v in value: super(DiscreteMulti, self).check(v, major)
python
{ "resource": "" }
q16372
Parameter.unpack
train
def unpack(self, value): """Unpack the parameter using its kattype. Parameters ---------- packed_value : str The unescaped KATCP string to unpack. Returns ------- value : object The unpacked value. """ # Wrap errors in Fa...
python
{ "resource": "" }
q16373
return_future
train
def return_future(fn): """Decorator that turns a synchronous function into one returning a future. This should only be applied to non-blocking functions. Will do set_result() with the return value, or set_exc_info() if an exception is raised. """ @wraps(fn) def decorated(*args, **kwargs): ...
python
{ "resource": "" }
q16374
construct_name_filter
train
def construct_name_filter(pattern): """Return a function for filtering sensor names based on a pattern. Parameters ---------- pattern : None or str If None, the returned function matches all names. If pattern starts and ends with '/' the text between the slashes is used as a reg...
python
{ "resource": "" }
q16375
ClientConnection.disconnect
train
def disconnect(self, reason): """Disconnect this client connection for specified reason""" self._server._disconnect_client(self._conn_key, self, reason)
python
{ "resource": "" }
q16376
KATCPServer.start
train
def start(self, timeout=None): """Install the server on its IOLoop, optionally starting the IOLoop. Parameters ---------- timeout : float or None, optional Time in seconds to wait for server thread to start. """ if self._running.isSet(): raise Ru...
python
{ "resource": "" }
q16377
KATCPServer._bind_socket
train
def _bind_socket(self, bindaddr): """Create a listening server socket.""" sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) sock.setblocking(0) try: sock.bind(bindaddr) except Exception: ...
python
{ "resource": "" }
q16378
KATCPServer._handle_stream
train
def _handle_stream(self, stream, address): """Handle a new connection as a tornado.iostream.IOStream instance.""" try: assert get_thread_ident() == self.ioloop_thread_id stream.set_close_callback(partial(self._stream_closed_callback, ...
python
{ "resource": "" }
q16379
KATCPServer.get_address
train
def get_address(self, stream): """Text representation of the network address of a connection stream. Notes ----- This method is thread-safe """ try: addr = ":".join(str(part) for part in stream.KATCPServer_address) except AttributeError: ...
python
{ "resource": "" }
q16380
KATCPServer.send_message
train
def send_message(self, stream, msg): """Send an arbitrary message to a particular client. Parameters ---------- stream : :class:`tornado.iostream.IOStream` object The stream to send the message to. msg : Message object The message to send. Notes ...
python
{ "resource": "" }
q16381
KATCPServer.flush_on_close
train
def flush_on_close(self, stream): """Flush tornado iostream write buffer and prevent further writes. Returns a future that resolves when the stream is flushed. """ assert get_thread_ident() == self.ioloop_thread_id # Prevent futher writes stream.KATCPServer_closing = Tr...
python
{ "resource": "" }
q16382
KATCPServer.call_from_thread
train
def call_from_thread(self, fn): """Allow thread-safe calls to ioloop functions. Uses add_callback if not in the IOLoop thread, otherwise calls directly. Returns an already resolved `tornado.concurrent.Future` if in ioloop, otherwise a `concurrent.Future`. Logs unhandled exceptions. ...
python
{ "resource": "" }
q16383
KATCPServer.mass_send_message
train
def mass_send_message(self, msg): """Send a message to all connected clients. Notes ----- This method can only be called in the IOLoop thread. """ for stream in self._connections.keys(): if not stream.closed(): # Don't cause noise by trying t...
python
{ "resource": "" }
q16384
ClientRequestConnection.reply_with_message
train
def reply_with_message(self, rep_msg): """Send a pre-created reply message to the client connection. Will check that rep_msg.name matches the bound request. """ self._post_reply() return self.client_connection.reply(rep_msg, self.msg)
python
{ "resource": "" }
q16385
MessageHandlerThread.on_message
train
def on_message(self, client_conn, msg): """Handle message. Returns ------- ready : Future A future that will resolve once we're ready, else None. Notes ----- *on_message* should not be called again until *ready* has resolved. """ MAX...
python
{ "resource": "" }
q16386
DeviceServerBase.create_log_inform
train
def create_log_inform(self, level_name, msg, name, timestamp=None): """Create a katcp logging inform message. Usually this will be called from inside a DeviceLogger object, but it is also used by the methods in this class when errors need to be reported to the client. """ ...
python
{ "resource": "" }
q16387
DeviceServerBase.handle_message
train
def handle_message(self, client_conn, msg): """Handle messages of all types from clients. Parameters ---------- client_conn : ClientConnection object The client connection the message was from. msg : Message object The message to process. """ ...
python
{ "resource": "" }
q16388
DeviceServerBase.set_ioloop
train
def set_ioloop(self, ioloop=None): """Set the tornado IOLoop to use. Sets the tornado.ioloop.IOLoop instance to use, defaulting to IOLoop.current(). If set_ioloop() is never called the IOLoop is started in a new thread, and will be stopped if self.stop() is called. Notes ...
python
{ "resource": "" }
q16389
DeviceServerBase.start
train
def start(self, timeout=None): """Start the server in a new thread. Parameters ---------- timeout : float or None, optional Time in seconds to wait for server thread to start. """ if self._handler_thread and self._handler_thread.isAlive(): raise ...
python
{ "resource": "" }
q16390
DeviceServerBase.sync_with_ioloop
train
def sync_with_ioloop(self, timeout=None): """Block for ioloop to complete a loop if called from another thread. Returns a future if called from inside the ioloop. Raises concurrent.futures.TimeoutError if timed out while blocking. """ in_ioloop = self._server.in_ioloop_thread(...
python
{ "resource": "" }
q16391
DeviceServer.on_client_connect
train
def on_client_connect(self, client_conn): """Inform client of build state and version on connect. Parameters ---------- client_conn : ClientConnection object The client connection that has been successfully established. Returns ------- Future that re...
python
{ "resource": "" }
q16392
DeviceServer.clear_strategies
train
def clear_strategies(self, client_conn, remove_client=False): """Clear the sensor strategies of a client connection. Parameters ---------- client_connection : ClientConnection instance The connection that should have its sampling strategies cleared remove_client : bo...
python
{ "resource": "" }
q16393
DeviceServer.on_client_disconnect
train
def on_client_disconnect(self, client_conn, msg, connection_valid): """Inform client it is about to be disconnected. Parameters ---------- client_conn : ClientConnection object The client connection being disconnected. msg : str Reason client is being dis...
python
{ "resource": "" }
q16394
DeviceServer.remove_sensor
train
def remove_sensor(self, sensor): """Remove a sensor from the device. Also deregisters all clients observing the sensor. Parameters ---------- sensor : Sensor object or name string The sensor to remove from the device server. """ if isinstance(sensor...
python
{ "resource": "" }
q16395
DeviceServer.get_sensor
train
def get_sensor(self, sensor_name): """Fetch the sensor with the given name. Parameters ---------- sensor_name : str Name of the sensor to retrieve. Returns ------- sensor : Sensor object The sensor with the given name. """ ...
python
{ "resource": "" }
q16396
DeviceServer.request_halt
train
def request_halt(self, req, msg): """Halt the device server. Returns ------- success : {'ok', 'fail'} Whether scheduling the halt succeeded. Examples -------- :: ?halt !halt ok """ f = Future() @gen.c...
python
{ "resource": "" }
q16397
DeviceServer.request_help
train
def request_help(self, req, msg): """Return help on the available requests. Return a description of the available requests using a sequence of #help informs. Parameters ---------- request : str, optional The name of the request to return help for (the defaul...
python
{ "resource": "" }
q16398
DeviceServer.request_request_timeout_hint
train
def request_request_timeout_hint(self, req, request): """Return timeout hints for requests KATCP requests should generally take less than 5s to complete, but some requests are unavoidably slow. This results in spurious client timeout errors. This request provides timeout hints that clie...
python
{ "resource": "" }
q16399
DeviceServer.request_log_level
train
def request_log_level(self, req, msg): """Query or set the current logging level. Parameters ---------- level : {'all', 'trace', 'debug', 'info', 'warn', 'error', 'fatal', \ 'off'}, optional Name of the logging level to set the device server to (the default ...
python
{ "resource": "" }