repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jws/dsa.py
ECDSASigner._cross_check
def _cross_check(self, pub_key): """ In Ecdsa, both the key and the algorithm define the curve. Therefore, we must cross check them to make sure they're the same. :param key: :raises: ValueError is the curves are not the same """ if self.curve_name != pub_key.cur...
python
def _cross_check(self, pub_key): """ In Ecdsa, both the key and the algorithm define the curve. Therefore, we must cross check them to make sure they're the same. :param key: :raises: ValueError is the curves are not the same """ if self.curve_name != pub_key.cur...
In Ecdsa, both the key and the algorithm define the curve. Therefore, we must cross check them to make sure they're the same. :param key: :raises: ValueError is the curves are not the same
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/dsa.py#L87-L98
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jws/dsa.py
ECDSASigner._split_raw_signature
def _split_raw_signature(sig): """ Split raw signature into components :param sig: The signature :return: A 2-tuple """ c_length = len(sig) // 2 r = int_from_bytes(sig[:c_length], byteorder='big') s = int_from_bytes(sig[c_length:], byteorder='big') ...
python
def _split_raw_signature(sig): """ Split raw signature into components :param sig: The signature :return: A 2-tuple """ c_length = len(sig) // 2 r = int_from_bytes(sig[:c_length], byteorder='big') s = int_from_bytes(sig[c_length:], byteorder='big') ...
Split raw signature into components :param sig: The signature :return: A 2-tuple
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/dsa.py#L101-L111
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jws/utils.py
left_hash
def left_hash(msg, func="HS256"): """ Calculate left hash as described in https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken for at_hash and in for c_hash :param msg: The message over which the hash should be calculated :param func: Which hash function that was used for the ID to...
python
def left_hash(msg, func="HS256"): """ Calculate left hash as described in https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken for at_hash and in for c_hash :param msg: The message over which the hash should be calculated :param func: Which hash function that was used for the ID to...
Calculate left hash as described in https://openid.net/specs/openid-connect-core-1_0.html#CodeIDToken for at_hash and in for c_hash :param msg: The message over which the hash should be calculated :param func: Which hash function that was used for the ID token
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/utils.py#L14-L28
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jws/utils.py
alg2keytype
def alg2keytype(alg): """ Go from algorithm name to key type. :param alg: The algorithm name :return: The key type """ if not alg or alg.lower() == "none": return "none" elif alg.startswith("RS") or alg.startswith("PS"): return "RSA" elif alg.startswith("HS") or alg.star...
python
def alg2keytype(alg): """ Go from algorithm name to key type. :param alg: The algorithm name :return: The key type """ if not alg or alg.lower() == "none": return "none" elif alg.startswith("RS") or alg.startswith("PS"): return "RSA" elif alg.startswith("HS") or alg.star...
Go from algorithm name to key type. :param alg: The algorithm name :return: The key type
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/utils.py#L36-L52
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jws/utils.py
parse_rsa_algorithm
def parse_rsa_algorithm(algorithm): """ Parses a RSA algorithm and returns tuple (hash, padding). :param algorithm: string, RSA algorithm as defined at https://tools.ietf.org/html/rfc7518#section-3.1. :raises: UnsupportedAlgorithm: if the algorithm is not supported. :returns: (hash, padding...
python
def parse_rsa_algorithm(algorithm): """ Parses a RSA algorithm and returns tuple (hash, padding). :param algorithm: string, RSA algorithm as defined at https://tools.ietf.org/html/rfc7518#section-3.1. :raises: UnsupportedAlgorithm: if the algorithm is not supported. :returns: (hash, padding...
Parses a RSA algorithm and returns tuple (hash, padding). :param algorithm: string, RSA algorithm as defined at https://tools.ietf.org/html/rfc7518#section-3.1. :raises: UnsupportedAlgorithm: if the algorithm is not supported. :returns: (hash, padding) tuple.
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/utils.py#L55-L87
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/jwe_ec.py
ecdh_derive_key
def ecdh_derive_key(key, epk, apu, apv, alg, dk_len): """ ECDH key derivation, as defined by JWA :param key : Elliptic curve private key :param epk : Elliptic curve public key :param apu : PartyUInfo :param apv : PartyVInfo :param alg : Algorithm identifier :param dk_len: Length of...
python
def ecdh_derive_key(key, epk, apu, apv, alg, dk_len): """ ECDH key derivation, as defined by JWA :param key : Elliptic curve private key :param epk : Elliptic curve public key :param apu : PartyUInfo :param apv : PartyVInfo :param alg : Algorithm identifier :param dk_len: Length of...
ECDH key derivation, as defined by JWA :param key : Elliptic curve private key :param epk : Elliptic curve public key :param apu : PartyUInfo :param apv : PartyVInfo :param alg : Algorithm identifier :param dk_len: Length of key to be derived, in bits :return: The derived key
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwe_ec.py#L23-L43
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/jwe_ec.py
JWE_EC.encrypt
def encrypt(self, key=None, iv="", cek="", **kwargs): """ Produces a JWE as defined in RFC7516 using an Elliptic curve key :param key: *Not used>, only there to present the same API as JWE_RSA and JWE_SYM :param iv: Initialization vector :param cek: Content master ke...
python
def encrypt(self, key=None, iv="", cek="", **kwargs): """ Produces a JWE as defined in RFC7516 using an Elliptic curve key :param key: *Not used>, only there to present the same API as JWE_RSA and JWE_SYM :param iv: Initialization vector :param cek: Content master ke...
Produces a JWE as defined in RFC7516 using an Elliptic curve key :param key: *Not used>, only there to present the same API as JWE_RSA and JWE_SYM :param iv: Initialization vector :param cek: Content master key :param kwargs: Extra keyword arguments :return: An encry...
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwe_ec.py#L181-L214
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/jwe_rsa.py
JWE_RSA.encrypt
def encrypt(self, key, iv="", cek="", **kwargs): """ Produces a JWE as defined in RFC7516 using RSA algorithms :param key: RSA key :param iv: Initialization vector :param cek: Content master key :param kwargs: Extra keyword arguments :return: A signed payload ...
python
def encrypt(self, key, iv="", cek="", **kwargs): """ Produces a JWE as defined in RFC7516 using RSA algorithms :param key: RSA key :param iv: Initialization vector :param cek: Content master key :param kwargs: Extra keyword arguments :return: A signed payload ...
Produces a JWE as defined in RFC7516 using RSA algorithms :param key: RSA key :param iv: Initialization vector :param cek: Content master key :param kwargs: Extra keyword arguments :return: A signed payload
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwe_rsa.py#L22-L72
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/jwe_rsa.py
JWE_RSA.decrypt
def decrypt(self, token, key, cek=None): """ Decrypts a JWT :param token: The JWT :param key: A key to use for decrypting :param cek: Ephemeral cipher key :return: The decrypted message """ if not isinstance(token, JWEnc): jwe = JWEnc().unpack(token) ...
python
def decrypt(self, token, key, cek=None): """ Decrypts a JWT :param token: The JWT :param key: A key to use for decrypting :param cek: Ephemeral cipher key :return: The decrypted message """ if not isinstance(token, JWEnc): jwe = JWEnc().unpack(token) ...
Decrypts a JWT :param token: The JWT :param key: A key to use for decrypting :param cek: Ephemeral cipher key :return: The decrypted message
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwe_rsa.py#L74-L119
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/jwe.py
JWE.encrypt
def encrypt(self, keys=None, cek="", iv="", **kwargs): """ Encrypt a payload :param keys: A set of possibly usable keys :param cek: Content master key :param iv: Initialization vector :param kwargs: Extra key word arguments :return: Encrypted message """ ...
python
def encrypt(self, keys=None, cek="", iv="", **kwargs): """ Encrypt a payload :param keys: A set of possibly usable keys :param cek: Content master key :param iv: Initialization vector :param kwargs: Extra key word arguments :return: Encrypted message """ ...
Encrypt a payload :param keys: A set of possibly usable keys :param cek: Content master key :param iv: Initialization vector :param kwargs: Extra key word arguments :return: Encrypted message
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwe.py#L64-L124
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/utils.py
base64url_to_long
def base64url_to_long(data): """ Stricter then base64_to_long since it really checks that it's base64url encoded :param data: The base64 string :return: """ _data = as_bytes(data) _d = base64.urlsafe_b64decode(_data + b'==') # verify that it's base64url encoded and not just base64 ...
python
def base64url_to_long(data): """ Stricter then base64_to_long since it really checks that it's base64url encoded :param data: The base64 string :return: """ _data = as_bytes(data) _d = base64.urlsafe_b64decode(_data + b'==') # verify that it's base64url encoded and not just base64 ...
Stricter then base64_to_long since it really checks that it's base64url encoded :param data: The base64 string :return:
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/utils.py#L51-L65
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/utils.py
b64d
def b64d(b): """Decode some base64-encoded bytes. Raises BadSyntax if the string contains invalid characters or padding. :param b: bytes """ cb = b.rstrip(b"=") # shouldn't but there you are # Python's base64 functions ignore invalid characters, so we need to # check for them explicitly...
python
def b64d(b): """Decode some base64-encoded bytes. Raises BadSyntax if the string contains invalid characters or padding. :param b: bytes """ cb = b.rstrip(b"=") # shouldn't but there you are # Python's base64 functions ignore invalid characters, so we need to # check for them explicitly...
Decode some base64-encoded bytes. Raises BadSyntax if the string contains invalid characters or padding. :param b: bytes
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/utils.py#L94-L112
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/utils.py
deser
def deser(val): """ Deserialize from a string representation of an long integer to the python representation of a long integer. :param val: The string representation of the long integer. :return: The long integer. """ if isinstance(val, str): _val = val.encode("utf-8") else: ...
python
def deser(val): """ Deserialize from a string representation of an long integer to the python representation of a long integer. :param val: The string representation of the long integer. :return: The long integer. """ if isinstance(val, str): _val = val.encode("utf-8") else: ...
Deserialize from a string representation of an long integer to the python representation of a long integer. :param val: The string representation of the long integer. :return: The long integer.
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/utils.py#L185-L198
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwk/__init__.py
JWK.to_dict
def to_dict(self): """ A wrapper for to_dict the makes sure that all the private information as well as extra arguments are included. This method should *not* be used for exporting information about the key. :return: A dictionary representation of the JSON Web key """ ...
python
def to_dict(self): """ A wrapper for to_dict the makes sure that all the private information as well as extra arguments are included. This method should *not* be used for exporting information about the key. :return: A dictionary representation of the JSON Web key """ ...
A wrapper for to_dict the makes sure that all the private information as well as extra arguments are included. This method should *not* be used for exporting information about the key. :return: A dictionary representation of the JSON Web key
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/__init__.py#L70-L80
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwk/__init__.py
JWK.common
def common(self): """ Return the set of parameters that are common to all types of keys. :return: Dictionary """ res = {"kty": self.kty} if self.use: res["use"] = self.use if self.kid: res["kid"] = self.kid if self.alg: ...
python
def common(self): """ Return the set of parameters that are common to all types of keys. :return: Dictionary """ res = {"kty": self.kty} if self.use: res["use"] = self.use if self.kid: res["kid"] = self.kid if self.alg: ...
Return the set of parameters that are common to all types of keys. :return: Dictionary
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/__init__.py#L82-L95
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwk/__init__.py
JWK.verify
def verify(self): """ Verify that the information gathered from the on-the-wire representation is of the right type. This is supposed to be run before the info is deserialized. :return: True/False """ for param in self.longs: item = getattr(self, para...
python
def verify(self): """ Verify that the information gathered from the on-the-wire representation is of the right type. This is supposed to be run before the info is deserialized. :return: True/False """ for param in self.longs: item = getattr(self, para...
Verify that the information gathered from the on-the-wire representation is of the right type. This is supposed to be run before the info is deserialized. :return: True/False
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/__init__.py#L124-L152
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwk/__init__.py
JWK.thumbprint
def thumbprint(self, hash_function, members=None): """ Create a thumbprint of the key following the outline in https://tools.ietf.org/html/draft-jones-jose-jwk-thumbprint-01 :param hash_function: A hash function to use for hashing the information :param members: Whic...
python
def thumbprint(self, hash_function, members=None): """ Create a thumbprint of the key following the outline in https://tools.ietf.org/html/draft-jones-jose-jwk-thumbprint-01 :param hash_function: A hash function to use for hashing the information :param members: Whic...
Create a thumbprint of the key following the outline in https://tools.ietf.org/html/draft-jones-jose-jwk-thumbprint-01 :param hash_function: A hash function to use for hashing the information :param members: Which attributes of the Key instance that should be included wh...
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwk/__init__.py#L176-L205
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwe/utils.py
concat_sha256
def concat_sha256(secret, dk_len, other_info): """ The Concat KDF, using SHA256 as the hash function. Note: Does not validate that otherInfo meets the requirements of SP800-56A. :param secret: The shared secret value :param dk_len: Length of key to be derived, in bits :param other_info: Ot...
python
def concat_sha256(secret, dk_len, other_info): """ The Concat KDF, using SHA256 as the hash function. Note: Does not validate that otherInfo meets the requirements of SP800-56A. :param secret: The shared secret value :param dk_len: Length of key to be derived, in bits :param other_info: Ot...
The Concat KDF, using SHA256 as the hash function. Note: Does not validate that otherInfo meets the requirements of SP800-56A. :param secret: The shared secret value :param dk_len: Length of key to be derived, in bits :param other_info: Other info to be incorporated (see SP800-56A) :return: Th...
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/utils.py#L98-L121
openid/JWTConnect-Python-CryptoJWT
src/cryptojwt/jwx.py
JWx.pick_keys
def pick_keys(self, keys, use="", alg=""): """ The assumption is that upper layer has made certain you only get keys you can use. :param alg: The crypto algorithm :param use: What the key should be used for :param keys: A list of JWK instances :return: A list of ...
python
def pick_keys(self, keys, use="", alg=""): """ The assumption is that upper layer has made certain you only get keys you can use. :param alg: The crypto algorithm :param use: What the key should be used for :param keys: A list of JWK instances :return: A list of ...
The assumption is that upper layer has made certain you only get keys you can use. :param alg: The crypto algorithm :param use: What the key should be used for :param keys: A list of JWK instances :return: A list of JWK instances that fulfill the requirements
https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwx.py#L175-L228
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.setup_sensors
def setup_sensors(self): """Setup some server sensors.""" self._add_result = Sensor.float("add.result", "Last ?add result.", "", [-10000, 10000]) self._add_result.set_value(0, Sensor.UNREACHABLE) self._time_result = Sensor.timestamp("time.result", "Last ?time res...
python
def setup_sensors(self): """Setup some server sensors.""" self._add_result = Sensor.float("add.result", "Last ?add result.", "", [-10000, 10000]) self._add_result.set_value(0, Sensor.UNREACHABLE) self._time_result = Sensor.timestamp("time.result", "Last ?time res...
Setup some server sensors.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L29-L50
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_add
def request_add(self, req, x, y): """Add two numbers""" r = x + y self._add_result.set_value(r) return ("ok", r)
python
def request_add(self, req, x, y): """Add two numbers""" r = x + y self._add_result.set_value(r) return ("ok", r)
Add two numbers
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L54-L58
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_time
def request_time(self, req): """Return the current time in ms since the Unix Epoch.""" r = time.time() self._time_result.set_value(r) return ("ok", r)
python
def request_time(self, req): """Return the current time in ms since the Unix Epoch.""" r = time.time() self._time_result.set_value(r) return ("ok", r)
Return the current time in ms since the Unix Epoch.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L62-L66
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_eval
def request_eval(self, req, expression): """Evaluate a Python expression.""" r = str(eval(expression)) self._eval_result.set_value(r) return ("ok", r)
python
def request_eval(self, req, expression): """Evaluate a Python expression.""" r = str(eval(expression)) self._eval_result.set_value(r) return ("ok", r)
Evaluate a Python expression.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L70-L74
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_pick_fruit
def request_pick_fruit(self, req): """Pick a random fruit.""" r = random.choice(self.FRUIT + [None]) if r is None: return ("fail", "No fruit.") delay = random.randrange(1,5) req.inform("Picking will take %d seconds" % delay) def pick_handler(): se...
python
def request_pick_fruit(self, req): """Pick a random fruit.""" r = random.choice(self.FRUIT + [None]) if r is None: return ("fail", "No fruit.") delay = random.randrange(1,5) req.inform("Picking will take %d seconds" % delay) def pick_handler(): se...
Pick a random fruit.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L78-L93
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_set_sensor_inactive
def request_set_sensor_inactive(self, req, sensor_name): """Set sensor status to inactive""" sensor = self.get_sensor(sensor_name) ts, status, value = sensor.read() sensor.set_value(value, sensor.INACTIVE, ts) return('ok',)
python
def request_set_sensor_inactive(self, req, sensor_name): """Set sensor status to inactive""" sensor = self.get_sensor(sensor_name) ts, status, value = sensor.read() sensor.set_value(value, sensor.INACTIVE, ts) return('ok',)
Set sensor status to inactive
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L97-L102
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_set_sensor_unreachable
def request_set_sensor_unreachable(self, req, sensor_name): """Set sensor status to unreachable""" sensor = self.get_sensor(sensor_name) ts, status, value = sensor.read() sensor.set_value(value, sensor.UNREACHABLE, ts) return('ok',)
python
def request_set_sensor_unreachable(self, req, sensor_name): """Set sensor status to unreachable""" sensor = self.get_sensor(sensor_name) ts, status, value = sensor.read() sensor.set_value(value, sensor.UNREACHABLE, ts) return('ok',)
Set sensor status to unreachable
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L106-L111
ska-sa/katcp-python
scratchpad/basic_server.py
MyServer.request_raw_reverse
def request_raw_reverse(self, req, msg): """ A raw request handler to demonstrate the calling convention if @request decoraters are not used. Reverses the message arguments. """ # msg is a katcp.Message.request object reversed_args = msg.arguments[::-1] # req.make...
python
def request_raw_reverse(self, req, msg): """ A raw request handler to demonstrate the calling convention if @request decoraters are not used. Reverses the message arguments. """ # msg is a katcp.Message.request object reversed_args = msg.arguments[::-1] # req.make...
A raw request handler to demonstrate the calling convention if @request decoraters are not used. Reverses the message arguments.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/scratchpad/basic_server.py#L113-L122
ska-sa/katcp-python
katcp/resource_client.py
transform_future
def transform_future(transformation, future): """Returns a new future that will resolve with a transformed value Takes the resolution value of `future` and applies transformation(*future.result()) to it before setting the result of the new future with the transformed value. If future() resolves with an...
python
def transform_future(transformation, future): """Returns a new future that will resolve with a transformed value Takes the resolution value of `future` and applies transformation(*future.result()) to it before setting the result of the new future with the transformed value. If future() resolves with an...
Returns a new future that will resolve with a transformed value Takes the resolution value of `future` and applies transformation(*future.result()) to it before setting the result of the new future with the transformed value. If future() resolves with an exception, it is passed through to the new future. ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L44-L67
ska-sa/katcp-python
katcp/resource_client.py
list_sensors
def list_sensors(parent_class, sensor_items, filter, strategy, status, use_python_identifiers, tuple, refresh): """Helper for implementing :meth:`katcp.resource.KATCPResource.list_sensors` Parameters ---------- sensor_items : tuple of sensor-item tuples As would be returned th...
python
def list_sensors(parent_class, sensor_items, filter, strategy, status, use_python_identifiers, tuple, refresh): """Helper for implementing :meth:`katcp.resource.KATCPResource.list_sensors` Parameters ---------- sensor_items : tuple of sensor-item tuples As would be returned th...
Helper for implementing :meth:`katcp.resource.KATCPResource.list_sensors` Parameters ---------- sensor_items : tuple of sensor-item tuples As would be returned the items() method of a dict containing KATCPSensor objects keyed by Python-identifiers. parent_class: KATCPClientResource or ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L70-L130
ska-sa/katcp-python
katcp/resource_client.py
monitor_resource_sync_state
def monitor_resource_sync_state(resource, callback, exit_event=None): """Coroutine that monitors a KATCPResource's sync state. Calls callback(True/False) whenever the resource becomes synced or unsynced. Will always do an initial callback(False) call. Exits without calling callback() if exit_event is s...
python
def monitor_resource_sync_state(resource, callback, exit_event=None): """Coroutine that monitors a KATCPResource's sync state. Calls callback(True/False) whenever the resource becomes synced or unsynced. Will always do an initial callback(False) call. Exits without calling callback() if exit_event is s...
Coroutine that monitors a KATCPResource's sync state. Calls callback(True/False) whenever the resource becomes synced or unsynced. Will always do an initial callback(False) call. Exits without calling callback() if exit_event is set
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1717-L1740
ska-sa/katcp-python
katcp/resource_client.py
ReplyWrappedInspectingClientAsync.wrapped_request
def wrapped_request(self, request, *args, **kwargs): """Create and send a request to the server. This method implements a very small subset of the options possible to send an request. It is provided as a shortcut to sending a simple wrapped request. Parameters ---------...
python
def wrapped_request(self, request, *args, **kwargs): """Create and send a request to the server. This method implements a very small subset of the options possible to send an request. It is provided as a shortcut to sending a simple wrapped request. Parameters ---------...
Create and send a request to the server. This method implements a very small subset of the options possible to send an request. It is provided as a shortcut to sending a simple wrapped request. Parameters ---------- request : str The request to call. ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L138-L188
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.until_state
def until_state(self, state, timeout=None): """Future that resolves when a certain client state is attained Parameters ---------- state : str Desired state, one of ("disconnected", "syncing", "synced") timeout: float Timeout for operation in seconds. ...
python
def until_state(self, state, timeout=None): """Future that resolves when a certain client state is attained Parameters ---------- state : str Desired state, one of ("disconnected", "syncing", "synced") timeout: float Timeout for operation in seconds. ...
Future that resolves when a certain client state is attained Parameters ---------- state : str Desired state, one of ("disconnected", "syncing", "synced") timeout: float Timeout for operation in seconds.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L371-L382
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.start
def start(self): """Start the client and connect""" # TODO (NM 2015-03-12) Some checking to prevent multiple calls to start() host, port = self.address ic = self._inspecting_client = self.inspecting_client_factory( host, port, self._ioloop_set_to) self.ioloop = ic.iol...
python
def start(self): """Start the client and connect""" # TODO (NM 2015-03-12) Some checking to prevent multiple calls to start() host, port = self.address ic = self._inspecting_client = self.inspecting_client_factory( host, port, self._ioloop_set_to) self.ioloop = ic.iol...
Start the client and connect
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L407-L426
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.inspecting_client_factory
def inspecting_client_factory(self, host, port, ioloop_set_to): """Return an instance of :class:`ReplyWrappedInspectingClientAsync` or similar Provided to ease testing. Dynamically overriding this method after instantiation but before start() is called allows for deep brain surgery. See ...
python
def inspecting_client_factory(self, host, port, ioloop_set_to): """Return an instance of :class:`ReplyWrappedInspectingClientAsync` or similar Provided to ease testing. Dynamically overriding this method after instantiation but before start() is called allows for deep brain surgery. See ...
Return an instance of :class:`ReplyWrappedInspectingClientAsync` or similar Provided to ease testing. Dynamically overriding this method after instantiation but before start() is called allows for deep brain surgery. See :class:`katcp.fake_clients.fake_inspecting_client_factory`
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L428-L437
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.until_not_synced
def until_not_synced(self, timeout=None): """Convenience method to wait (with Future) until client is not synced""" not_synced_states = [state for state in self._state.valid_states if state != 'synced'] not_synced_futures = [self._state.until_state(state) ...
python
def until_not_synced(self, timeout=None): """Convenience method to wait (with Future) until client is not synced""" not_synced_states = [state for state in self._state.valid_states if state != 'synced'] not_synced_futures = [self._state.until_state(state) ...
Convenience method to wait (with Future) until client is not synced
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L443-L449
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.set_sampling_strategies
def set_sampling_strategies(self, filter, strategy_and_parms): """Set a strategy for all sensors matching the filter, including unseen sensors The strategy should persist across sensor disconnect/reconnect. filter : str Filter for sensor names strategy_and_params : seq of st...
python
def set_sampling_strategies(self, filter, strategy_and_parms): """Set a strategy for all sensors matching the filter, including unseen sensors The strategy should persist across sensor disconnect/reconnect. filter : str Filter for sensor names strategy_and_params : seq of st...
Set a strategy for all sensors matching the filter, including unseen sensors The strategy should persist across sensor disconnect/reconnect. filter : str Filter for sensor names strategy_and_params : seq of str or str As tuple contains (<strat_name>, [<strat_parm1>, ...]...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L458-L488
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.set_sampling_strategy
def set_sampling_strategy(self, sensor_name, strategy_and_parms): """Set a strategy for a sensor even if it is not yet known. The strategy should persist across sensor disconnect/reconnect. sensor_name : str Name of the sensor strategy_and_params : seq of str or str ...
python
def set_sampling_strategy(self, sensor_name, strategy_and_parms): """Set a strategy for a sensor even if it is not yet known. The strategy should persist across sensor disconnect/reconnect. sensor_name : str Name of the sensor strategy_and_params : seq of str or str ...
Set a strategy for a sensor even if it is not yet known. The strategy should persist across sensor disconnect/reconnect. sensor_name : str Name of the sensor strategy_and_params : seq of str or str As tuple contains (<strat_name>, [<strat_parm1>, ...]) where the strategy...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L491-L526
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.drop_sampling_strategy
def drop_sampling_strategy(self, sensor_name): """Drop the sampling strategy for the named sensor from the cache Calling :meth:`set_sampling_strategy` requires the requested strategy to be memorised so that it can automatically be reapplied. This method causes the strategy to be forgot...
python
def drop_sampling_strategy(self, sensor_name): """Drop the sampling strategy for the named sensor from the cache Calling :meth:`set_sampling_strategy` requires the requested strategy to be memorised so that it can automatically be reapplied. This method causes the strategy to be forgot...
Drop the sampling strategy for the named sensor from the cache Calling :meth:`set_sampling_strategy` requires the requested strategy to be memorised so that it can automatically be reapplied. This method causes the strategy to be forgotten. There is no change to the current strategy. ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L528-L546
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResource.set_sensor_listener
def set_sensor_listener(self, sensor_name, listener): """Set a sensor listener for a sensor even if it is not yet known The listener registration should persist across sensor disconnect/reconnect. sensor_name : str Name of the sensor listener : callable Listening...
python
def set_sensor_listener(self, sensor_name, listener): """Set a sensor listener for a sensor even if it is not yet known The listener registration should persist across sensor disconnect/reconnect. sensor_name : str Name of the sensor listener : callable Listening...
Set a sensor listener for a sensor even if it is not yet known The listener registration should persist across sensor disconnect/reconnect. sensor_name : str Name of the sensor listener : callable Listening callable that will be registered on the named sensor when it bec...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L549-L582
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceSensorsManager._get_strategy_cache_key
def _get_strategy_cache_key(self, sensor_name): """Lookup sensor name in cache, allowing names in escaped form The strategy cache uses the normal KATCP sensor names as the keys. In order to allow access using an escaped sensor name, this method tries to find the normal form of the name....
python
def _get_strategy_cache_key(self, sensor_name): """Lookup sensor name in cache, allowing names in escaped form The strategy cache uses the normal KATCP sensor names as the keys. In order to allow access using an escaped sensor name, this method tries to find the normal form of the name....
Lookup sensor name in cache, allowing names in escaped form The strategy cache uses the normal KATCP sensor names as the keys. In order to allow access using an escaped sensor name, this method tries to find the normal form of the name. Returns ------- key : str ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L763-L788
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceSensorsManager.get_sampling_strategy
def get_sampling_strategy(self, sensor_name): """Get the current sampling strategy for the named sensor Parameters ---------- sensor_name : str Name of the sensor (normal or escaped form) Returns ------- strategy : tuple of str contains...
python
def get_sampling_strategy(self, sensor_name): """Get the current sampling strategy for the named sensor Parameters ---------- sensor_name : str Name of the sensor (normal or escaped form) Returns ------- strategy : tuple of str contains...
Get the current sampling strategy for the named sensor Parameters ---------- sensor_name : str Name of the sensor (normal or escaped form) Returns ------- strategy : tuple of str contains (<strat_name>, [<strat_parm1>, ...]) where the strategy ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L804-L825
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceSensorsManager.set_sampling_strategy
def set_sampling_strategy(self, sensor_name, strategy_and_params): """Set the sampling strategy for the named sensor Parameters ---------- sensor_name : str Name of the sensor strategy_and_params : seq of str or str As tuple contains (<strat_name>, [<str...
python
def set_sampling_strategy(self, sensor_name, strategy_and_params): """Set the sampling strategy for the named sensor Parameters ---------- sensor_name : str Name of the sensor strategy_and_params : seq of str or str As tuple contains (<strat_name>, [<str...
Set the sampling strategy for the named sensor Parameters ---------- sensor_name : str Name of the sensor strategy_and_params : seq of str or str As tuple contains (<strat_name>, [<strat_parm1>, ...]) where the strategy names and parameters are as de...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L828-L866
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceSensorsManager.drop_sampling_strategy
def drop_sampling_strategy(self, sensor_name): """Drop the sampling strategy for the named sensor from the cache Calling :meth:`set_sampling_strategy` requires the sensor manager to memorise the requested strategy so that it can automatically be reapplied. If the client is no longer int...
python
def drop_sampling_strategy(self, sensor_name): """Drop the sampling strategy for the named sensor from the cache Calling :meth:`set_sampling_strategy` requires the sensor manager to memorise the requested strategy so that it can automatically be reapplied. If the client is no longer int...
Drop the sampling strategy for the named sensor from the cache Calling :meth:`set_sampling_strategy` requires the sensor manager to memorise the requested strategy so that it can automatically be reapplied. If the client is no longer interested in the sensor, or knows the sensor may be ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L868-L886
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceSensorsManager.reapply_sampling_strategies
def reapply_sampling_strategies(self): """Reapply all sensor strategies using cached values""" check_sensor = self._inspecting_client.future_check_sensor for sensor_name, strategy in list(self._strategy_cache.items()): try: sensor_exists = yield check_sensor(sensor_na...
python
def reapply_sampling_strategies(self): """Reapply all sensor strategies using cached values""" check_sensor = self._inspecting_client.future_check_sensor for sensor_name, strategy in list(self._strategy_cache.items()): try: sensor_exists = yield check_sensor(sensor_na...
Reapply all sensor strategies using cached values
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L889-L906
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceRequest.issue_request
def issue_request(self, *args, **kwargs): """Issue the wrapped request to the server. Parameters ---------- *args : list of objects Arguments to pass on to the request. Keyword Arguments ----------------- timeout : float or None, optional ...
python
def issue_request(self, *args, **kwargs): """Issue the wrapped request to the server. Parameters ---------- *args : list of objects Arguments to pass on to the request. Keyword Arguments ----------------- timeout : float or None, optional ...
Issue the wrapped request to the server. Parameters ---------- *args : list of objects Arguments to pass on to the request. Keyword Arguments ----------------- timeout : float or None, optional Timeout after this amount of seconds (keyword argume...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L941-L971
ska-sa/katcp-python
katcp/resource_client.py
ClientGroup.set_sampling_strategies
def set_sampling_strategies(self, filter, strategy_and_params): """Set sampling strategy for the sensors of all the group's clients. Only sensors that match the specified filter are considered. See the `KATCPResource.set_sampling_strategies` docstring for parameter definitions and more ...
python
def set_sampling_strategies(self, filter, strategy_and_params): """Set sampling strategy for the sensors of all the group's clients. Only sensors that match the specified filter are considered. See the `KATCPResource.set_sampling_strategies` docstring for parameter definitions and more ...
Set sampling strategy for the sensors of all the group's clients. Only sensors that match the specified filter are considered. See the `KATCPResource.set_sampling_strategies` docstring for parameter definitions and more info. Returns ------- sensors_strategies : tornado...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1125-L1144
ska-sa/katcp-python
katcp/resource_client.py
ClientGroup.set_sampling_strategy
def set_sampling_strategy(self, sensor_name, strategy_and_params): """Set sampling strategy for the sensors of all the group's clients. Only sensors that match the specified filter are considered. See the `KATCPResource.set_sampling_strategies` docstring for parameter definitions and mo...
python
def set_sampling_strategy(self, sensor_name, strategy_and_params): """Set sampling strategy for the sensors of all the group's clients. Only sensors that match the specified filter are considered. See the `KATCPResource.set_sampling_strategies` docstring for parameter definitions and mo...
Set sampling strategy for the sensors of all the group's clients. Only sensors that match the specified filter are considered. See the `KATCPResource.set_sampling_strategies` docstring for parameter definitions and more info. Returns ------- sensors_strategies : tornado...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1147-L1166
ska-sa/katcp-python
katcp/resource_client.py
ClientGroup.wait
def wait(self, sensor_name, condition_or_value, timeout=5.0, quorum=None, max_grace_period=1.0): """Wait for sensor present on all group clients to satisfy a condition. Parameters ---------- sensor_name : string The name of the sensor to check condition_...
python
def wait(self, sensor_name, condition_or_value, timeout=5.0, quorum=None, max_grace_period=1.0): """Wait for sensor present on all group clients to satisfy a condition. Parameters ---------- sensor_name : string The name of the sensor to check condition_...
Wait for sensor present on all group clients 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 If obj, sensor.value is compared with obj. If callabl...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1169-L1249
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.client_resource_factory
def client_resource_factory(self, res_spec, parent, logger): """Return an instance of :class:`KATCPClientResource` or similar Provided to ease testing. Overriding this method allows deep brain surgery. See :func:`katcp.fake_clients.fake_KATCP_client_resource_factory` """ return...
python
def client_resource_factory(self, res_spec, parent, logger): """Return an instance of :class:`KATCPClientResource` or similar Provided to ease testing. Overriding this method allows deep brain surgery. See :func:`katcp.fake_clients.fake_KATCP_client_resource_factory` """ return...
Return an instance of :class:`KATCPClientResource` or similar Provided to ease testing. Overriding this method allows deep brain surgery. See :func:`katcp.fake_clients.fake_KATCP_client_resource_factory`
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1349-L1356
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.add_group
def add_group(self, group_name, group_client_names): """Add a new :class:`ClientGroup` to container groups member. Add the group named *group_name* with sequence of client names to the container groups member. From there it will be wrapped appropriately in the higher-level thread-safe c...
python
def add_group(self, group_name, group_client_names): """Add a new :class:`ClientGroup` to container groups member. Add the group named *group_name* with sequence of client names to the container groups member. From there it will be wrapped appropriately in the higher-level thread-safe c...
Add a new :class:`ClientGroup` to container groups member. Add the group named *group_name* with sequence of client names to the container groups member. From there it will be wrapped appropriately in the higher-level thread-safe container.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1369-L1379
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.set_ioloop
def set_ioloop(self, ioloop=None): """Set the tornado ioloop to use Defaults to tornado.ioloop.IOLoop.current() if set_ioloop() is not called or if ioloop=None. Must be called before start() """ ioloop = ioloop or tornado.ioloop.IOLoop.current() self.ioloop = ioloop ...
python
def set_ioloop(self, ioloop=None): """Set the tornado ioloop to use Defaults to tornado.ioloop.IOLoop.current() if set_ioloop() is not called or if ioloop=None. Must be called before start() """ ioloop = ioloop or tornado.ioloop.IOLoop.current() self.ioloop = ioloop ...
Set the tornado ioloop to use Defaults to tornado.ioloop.IOLoop.current() if set_ioloop() is not called or if ioloop=None. Must be called before start()
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1381-L1390
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.is_connected
def is_connected(self): """Indication of the connection state of all children""" return all([r.is_connected() for r in dict.values(self.children)])
python
def is_connected(self): """Indication of the connection state of all children""" return all([r.is_connected() for r in dict.values(self.children)])
Indication of the connection state of all children
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1392-L1394
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.until_synced
def until_synced(self, timeout=None): """Return a tornado Future; resolves when all subordinate clients are synced""" futures = [r.until_synced(timeout) for r in dict.values(self.children)] yield tornado.gen.multi(futures, quiet_exceptions=tornado.gen.TimeoutError)
python
def until_synced(self, timeout=None): """Return a tornado Future; resolves when all subordinate clients are synced""" futures = [r.until_synced(timeout) for r in dict.values(self.children)] yield tornado.gen.multi(futures, quiet_exceptions=tornado.gen.TimeoutError)
Return a tornado Future; resolves when all subordinate clients are synced
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1402-L1405
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.until_not_synced
def until_not_synced(self, timeout=None): """Return a tornado Future; resolves when any subordinate client is not synced""" yield until_any(*[r.until_not_synced() for r in dict.values(self.children)], timeout=timeout)
python
def until_not_synced(self, timeout=None): """Return a tornado Future; resolves when any subordinate client is not synced""" yield until_any(*[r.until_not_synced() for r in dict.values(self.children)], timeout=timeout)
Return a tornado Future; resolves when any subordinate client is not synced
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1408-L1411
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.until_any_child_in_state
def until_any_child_in_state(self, state, timeout=None): """Return a tornado Future; resolves when any client is in specified state""" return until_any(*[r.until_state(state) for r in dict.values(self.children)], timeout=timeout)
python
def until_any_child_in_state(self, state, timeout=None): """Return a tornado Future; resolves when any client is in specified state""" return until_any(*[r.until_state(state) for r in dict.values(self.children)], timeout=timeout)
Return a tornado Future; resolves when any client is in specified state
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1413-L1416
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.until_all_children_in_state
def until_all_children_in_state(self, state, timeout=None): """Return a tornado Future; resolves when all clients are in specified state""" futures = [r.until_state(state, timeout=timeout) for r in dict.values(self.children)] yield tornado.gen.multi(futures, quiet_exceptions=t...
python
def until_all_children_in_state(self, state, timeout=None): """Return a tornado Future; resolves when all clients are in specified state""" futures = [r.until_state(state, timeout=timeout) for r in dict.values(self.children)] yield tornado.gen.multi(futures, quiet_exceptions=t...
Return a tornado Future; resolves when all clients are in specified state
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1419-L1423
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.set_sampling_strategies
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
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...
Set sampling strategies for filtered sensors - these sensors have to exsist
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1445-L1466
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.add_child_resource_client
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
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) ...
Add a resource client to the container and start the resource connection
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1516-L1526
ska-sa/katcp-python
katcp/resource_client.py
KATCPClientResourceContainer.stop
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
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: ...
Stop all child resources
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource_client.py#L1541-L1550
eight04/pyAPNG
apng/__init__.py
parse_chunks
def parse_chunks(b): """Parse PNG bytes into multiple chunks. :arg bytes b: The raw bytes of the PNG file. :return: A generator yielding :class:`Chunk`. :rtype: Iterator[Chunk] """ # skip signature i = 8 # yield chunks while i < len(b): data_len, = struct.unpack("!I", b[i:i+4]) type_ = b[i+4:i+8].decode...
python
def parse_chunks(b): """Parse PNG bytes into multiple chunks. :arg bytes b: The raw bytes of the PNG file. :return: A generator yielding :class:`Chunk`. :rtype: Iterator[Chunk] """ # skip signature i = 8 # yield chunks while i < len(b): data_len, = struct.unpack("!I", b[i:i+4]) type_ = b[i+4:i+8].decode...
Parse PNG bytes into multiple chunks. :arg bytes b: The raw bytes of the PNG file. :return: A generator yielding :class:`Chunk`. :rtype: Iterator[Chunk]
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L27-L41
eight04/pyAPNG
apng/__init__.py
make_chunk
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
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...
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
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L43-L54
eight04/pyAPNG
apng/__init__.py
make_text_chunk
def make_text_chunk( type="tEXt", key="Comment", value="", compression_flag=0, compression_method=0, lang="", translated_key=""): """Create a text chunk with a key value pair. See https://www.w3.org/TR/PNG/#11textinfo for text chunk information. Usage: .. code:: python from apng import APNG, make_text_chu...
python
def make_text_chunk( type="tEXt", key="Comment", value="", compression_flag=0, compression_method=0, lang="", translated_key=""): """Create a text chunk with a key value pair. See https://www.w3.org/TR/PNG/#11textinfo for text chunk information. Usage: .. code:: python from apng import APNG, make_text_chu...
Create a text chunk with a key value pair. See https://www.w3.org/TR/PNG/#11textinfo for text chunk information. Usage: .. code:: python from apng import APNG, make_text_chunk im = APNG.open("file.png") png, control = im.frames[0] png.chunks.append(make_text_chunk("tEXt", "Comment", "some text")) im.s...
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L56-L111
eight04/pyAPNG
apng/__init__.py
read_file
def read_file(file): """Read ``file`` into ``bytes``. :arg file type: path-like or file-like :rtype: bytes """ if hasattr(file, "read"): return file.read() if hasattr(file, "read_bytes"): return file.read_bytes() with open(file, "rb") as f: return f.read()
python
def read_file(file): """Read ``file`` into ``bytes``. :arg file type: path-like or file-like :rtype: bytes """ if hasattr(file, "read"): return file.read() if hasattr(file, "read_bytes"): return file.read_bytes() with open(file, "rb") as f: return f.read()
Read ``file`` into ``bytes``. :arg file type: path-like or file-like :rtype: bytes
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L113-L124
eight04/pyAPNG
apng/__init__.py
write_file
def write_file(file, b): """Write ``b`` to file ``file``. :arg file type: path-like or file-like object. :arg bytes b: The content. """ if hasattr(file, "write_bytes"): file.write_bytes(b) elif hasattr(file, "write"): file.write(b) else: with open(file, "wb") as f: f.write(b)
python
def write_file(file, b): """Write ``b`` to file ``file``. :arg file type: path-like or file-like object. :arg bytes b: The content. """ if hasattr(file, "write_bytes"): file.write_bytes(b) elif hasattr(file, "write"): file.write(b) else: with open(file, "wb") as f: f.write(b)
Write ``b`` to file ``file``. :arg file type: path-like or file-like object. :arg bytes b: The content.
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L126-L138
eight04/pyAPNG
apng/__init__.py
open_file
def open_file(file, mode): """Open a file. :arg file: file-like or path-like object. :arg str mode: ``mode`` argument for :func:`open`. """ if hasattr(file, "read"): return file if hasattr(file, "open"): return file.open(mode) return open(file, mode)
python
def open_file(file, mode): """Open a file. :arg file: file-like or path-like object. :arg str mode: ``mode`` argument for :func:`open`. """ if hasattr(file, "read"): return file if hasattr(file, "open"): return file.open(mode) return open(file, mode)
Open a file. :arg file: file-like or path-like object. :arg str mode: ``mode`` argument for :func:`open`.
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L140-L150
eight04/pyAPNG
apng/__init__.py
file_to_png
def file_to_png(fp): """Convert an image to PNG format with Pillow. :arg file-like fp: The image file. :rtype: bytes """ import PIL.Image # pylint: disable=import-error with io.BytesIO() as dest: PIL.Image.open(fp).save(dest, "PNG", optimize=True) return dest.getvalue()
python
def file_to_png(fp): """Convert an image to PNG format with Pillow. :arg file-like fp: The image file. :rtype: bytes """ import PIL.Image # pylint: disable=import-error with io.BytesIO() as dest: PIL.Image.open(fp).save(dest, "PNG", optimize=True) return dest.getvalue()
Convert an image to PNG format with Pillow. :arg file-like fp: The image file. :rtype: bytes
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L152-L161
eight04/pyAPNG
apng/__init__.py
PNG.init
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
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])
Extract some info from chunks
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L185-L195
eight04/pyAPNG
apng/__init__.py
PNG.open_any
def open_any(cls, file): """Open an image file. If the image is not PNG format, it would convert the image into PNG with Pillow module. If the module is not installed, :class:`ImportError` would be raised. :arg file: Input file. :type file: path-like or file-like :rtype: :class:`PNG` """ with open_fi...
python
def open_any(cls, file): """Open an image file. If the image is not PNG format, it would convert the image into PNG with Pillow module. If the module is not installed, :class:`ImportError` would be raised. :arg file: Input file. :type file: path-like or file-like :rtype: :class:`PNG` """ with open_fi...
Open an image file. If the image is not PNG format, it would convert the image into PNG with Pillow module. If the module is not installed, :class:`ImportError` would be raised. :arg file: Input file. :type file: path-like or file-like :rtype: :class:`PNG`
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L208-L224
eight04/pyAPNG
apng/__init__.py
PNG.from_bytes
def from_bytes(cls, b): """Create :class:`PNG` from raw bytes. :arg bytes b: The raw bytes of the PNG file. :rtype: :class:`PNG` """ im = cls() im.chunks = list(parse_chunks(b)) im.init() return im
python
def from_bytes(cls, b): """Create :class:`PNG` from raw bytes. :arg bytes b: The raw bytes of the PNG file. :rtype: :class:`PNG` """ im = cls() im.chunks = list(parse_chunks(b)) im.init() return im
Create :class:`PNG` from raw bytes. :arg bytes b: The raw bytes of the PNG file. :rtype: :class:`PNG`
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L227-L236
eight04/pyAPNG
apng/__init__.py
PNG.from_chunks
def from_chunks(cls, chunks): """Construct PNG from raw chunks. :arg chunks: A list of ``(chunk_type, chunk_raw_data)``. Also see :func:`chunks`. :type chunks: list[tuple(str, bytes)] """ im = cls() im.chunks = chunks im.init() return im
python
def from_chunks(cls, chunks): """Construct PNG from raw chunks. :arg chunks: A list of ``(chunk_type, chunk_raw_data)``. Also see :func:`chunks`. :type chunks: list[tuple(str, bytes)] """ im = cls() im.chunks = chunks im.init() return im
Construct PNG from raw chunks. :arg chunks: A list of ``(chunk_type, chunk_raw_data)``. Also see :func:`chunks`. :type chunks: list[tuple(str, bytes)]
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L239-L249
eight04/pyAPNG
apng/__init__.py
PNG.to_bytes
def to_bytes(self): """Convert the entire image to bytes. :rtype: bytes """ chunks = [PNG_SIGN] chunks.extend(c[1] for c in self.chunks) return b"".join(chunks)
python
def to_bytes(self): """Convert the entire image to bytes. :rtype: bytes """ chunks = [PNG_SIGN] chunks.extend(c[1] for c in self.chunks) return b"".join(chunks)
Convert the entire image to bytes. :rtype: bytes
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L252-L259
eight04/pyAPNG
apng/__init__.py
FrameControl.to_bytes
def to_bytes(self): """Convert to bytes. :rtype: bytes """ return struct.pack( "!IIIIHHbb", self.width, self.height, self.x_offset, self.y_offset, self.delay, self.delay_den, self.depose_op, self.blend_op )
python
def to_bytes(self): """Convert to bytes. :rtype: bytes """ return struct.pack( "!IIIIHHbb", self.width, self.height, self.x_offset, self.y_offset, self.delay, self.delay_den, self.depose_op, self.blend_op )
Convert to bytes. :rtype: bytes
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L287-L295
eight04/pyAPNG
apng/__init__.py
APNG.append
def append(self, png, **options): """Append one frame. :arg PNG png: Append a :class:`PNG` as a frame. :arg dict options: The options for :class:`FrameControl`. """ if not isinstance(png, PNG): raise TypeError("Expect an instance of `PNG` but got `{}`".format(png)) control = FrameControl(**options) ...
python
def append(self, png, **options): """Append one frame. :arg PNG png: Append a :class:`PNG` as a frame. :arg dict options: The options for :class:`FrameControl`. """ if not isinstance(png, PNG): raise TypeError("Expect an instance of `PNG` but got `{}`".format(png)) control = FrameControl(**options) ...
Append one frame. :arg PNG png: Append a :class:`PNG` as a frame. :arg dict options: The options for :class:`FrameControl`.
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L321-L334
eight04/pyAPNG
apng/__init__.py
APNG.append_file
def append_file(self, file, **options): """Create a PNG from file and append the PNG as a frame. :arg file: Input file. :type file: path-like or file-like. :arg dict options: The options for :class:`FrameControl`. """ self.append(PNG.open_any(file), **options)
python
def append_file(self, file, **options): """Create a PNG from file and append the PNG as a frame. :arg file: Input file. :type file: path-like or file-like. :arg dict options: The options for :class:`FrameControl`. """ self.append(PNG.open_any(file), **options)
Create a PNG from file and append the PNG as a frame. :arg file: Input file. :type file: path-like or file-like. :arg dict options: The options for :class:`FrameControl`.
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L336-L343
eight04/pyAPNG
apng/__init__.py
APNG.to_bytes
def to_bytes(self): """Convert the entire image to bytes. :rtype: bytes """ # grab the chunks we needs out = [PNG_SIGN] # FIXME: it's tricky to define "other_chunks". HoneyView stop the # animation if it sees chunks other than fctl or idat, so we put other # chunks to the end of the file other_...
python
def to_bytes(self): """Convert the entire image to bytes. :rtype: bytes """ # grab the chunks we needs out = [PNG_SIGN] # FIXME: it's tricky to define "other_chunks". HoneyView stop the # animation if it sees chunks other than fctl or idat, so we put other # chunks to the end of the file other_...
Convert the entire image to bytes. :rtype: bytes
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L345-L411
eight04/pyAPNG
apng/__init__.py
APNG.from_files
def from_files(cls, files, **options): """Create an APNG from multiple files. This is a shortcut of:: im = APNG() for file in files: im.append_file(file, **options) :arg list files: A list of filename. See :meth:`PNG.open`. :arg dict options: Options for :class:`FrameControl`. :rtype: APN...
python
def from_files(cls, files, **options): """Create an APNG from multiple files. This is a shortcut of:: im = APNG() for file in files: im.append_file(file, **options) :arg list files: A list of filename. See :meth:`PNG.open`. :arg dict options: Options for :class:`FrameControl`. :rtype: APN...
Create an APNG from multiple files. This is a shortcut of:: im = APNG() for file in files: im.append_file(file, **options) :arg list files: A list of filename. See :meth:`PNG.open`. :arg dict options: Options for :class:`FrameControl`. :rtype: APNG
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L414-L430
eight04/pyAPNG
apng/__init__.py
APNG.from_bytes
def from_bytes(cls, b): """Create an APNG from raw bytes. :arg bytes b: The raw bytes of the APNG file. :rtype: APNG """ hdr = None head_chunks = [] end = ("IEND", make_chunk("IEND", b"")) frame_chunks = [] frames = [] num_plays = 0 frame_has_head_chunks = False control = None for ...
python
def from_bytes(cls, b): """Create an APNG from raw bytes. :arg bytes b: The raw bytes of the APNG file. :rtype: APNG """ hdr = None head_chunks = [] end = ("IEND", make_chunk("IEND", b"")) frame_chunks = [] frames = [] num_plays = 0 frame_has_head_chunks = False control = None for ...
Create an APNG from raw bytes. :arg bytes b: The raw bytes of the APNG file. :rtype: APNG
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/apng/__init__.py#L433-L494
eight04/pyAPNG
cute.py
readme
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
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")
Live reload readme
https://github.com/eight04/pyAPNG/blob/b4d2927f7892a1de967b5cf57d434ed65f6a017e/cute.py#L6-L11
ska-sa/katcp-python
bench/benchserver.py
BenchmarkServer.request_add_sensor
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
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')
add a sensor
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/bench/benchserver.py#L17-L22
ska-sa/katcp-python
katcp/resource.py
normalize_strategy_parameters
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
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 ...
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 is the name of the strategy. Returns ----...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L59-L84
ska-sa/katcp-python
katcp/resource.py
KATCPResource.wait
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
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 ...
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 If obj, sensor.value is compared with obj. If callable, ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L186-L222
ska-sa/katcp-python
katcp/resource.py
KATCPResource.list_sensors
def list_sensors(self, filter="", strategy=False, status="", use_python_identifiers=True, tuple=False, refresh=False): """List sensors available on this resource matching certain criteria. Parameters ---------- filter : string, optional Filter each retur...
python
def list_sensors(self, filter="", strategy=False, status="", use_python_identifiers=True, tuple=False, refresh=False): """List sensors available on this resource matching certain criteria. Parameters ---------- filter : string, optional Filter each retur...
List sensors available on this resource matching certain criteria. Parameters ---------- filter : string, optional Filter each returned sensor's name against this regexp if specified. To ease the dichotomy between Python identifier names and actual sensor nam...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L225-L259
ska-sa/katcp-python
katcp/resource.py
KATCPResource.set_sampling_strategies
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
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...
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 specified strategy. Use "" to match all sensors. Is matched using ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L262-L302
ska-sa/katcp-python
katcp/resource.py
KATCPResource.set_sampling_strategy
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
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>, [...
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>, [<strat_parm1>, ...]) where the strategy names and parameters are a...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L305-L340
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.set_strategy
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
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 ...
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 names and parameters are as defined by the KATC...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L704-L732
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.register_listener
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
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...
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 reading listener(katcp_sensor, reading) where ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L761-L779
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.unregister_listener
def unregister_listener(self, listener): """Remove a listener callback added with register_listener(). Parameters ---------- listener : function Reference to the callback function that should be removed """ listener_id = hashable_identity(listener) s...
python
def unregister_listener(self, listener): """Remove a listener callback added with register_listener(). Parameters ---------- listener : function Reference to the callback function that should be removed """ listener_id = hashable_identity(listener) s...
Remove a listener callback added with register_listener(). Parameters ---------- listener : function Reference to the callback function that should be removed
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L781-L791
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.set
def set(self, timestamp, status, value): """Set sensor with a given received value, matches :meth:`katcp.Sensor.set`""" received_timestamp = self._manager.time() reading = KATCPSensorReading(received_timestamp, timestamp, status, value) self._reading = reading self.call_listeners...
python
def set(self, timestamp, status, value): """Set sensor with a given received value, matches :meth:`katcp.Sensor.set`""" received_timestamp = self._manager.time() reading = KATCPSensorReading(received_timestamp, timestamp, status, value) self._reading = reading self.call_listeners...
Set sensor with a given received value, matches :meth:`katcp.Sensor.set`
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L817-L822
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.set_value
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
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)
Set sensor value with optinal specification of status and timestamp
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L824-L828
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.get_reading
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
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 ...
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 registered listeners being ...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L840-L855
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.get_value
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
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 ...
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 registered listeners being ca...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L858-L873
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.get_status
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
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 ...
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 registered listeners being c...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L876-L891
ska-sa/katcp-python
katcp/resource.py
KATCPSensor.wait
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
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...
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(reading) is called, and must return True if its cond...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/resource.py#L893-L964
ska-sa/katcp-python
katcp/fake_clients.py
fake_KATCP_client_resource_factory
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
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...
Create a fake KATCPClientResource-like class and a fake-manager Parameters ---------- KATCPClientResourceClass : class Subclass of :class:`katcp.resource_client.KATCPClientResource` fake_options : dict Options for the faking process. Keys: allow_any_request : bool, default F...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L16-L59
ska-sa/katcp-python
katcp/fake_clients.py
fake_KATCP_client_resource_container_factory
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
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...
Create a fake KATCPClientResourceContainer-like class and a fake-manager Parameters ---------- KATCPClientResourceContainerClass : class Subclass of :class:`katcp.resource_client.KATCPClientResourceContainer` fake_options : dict Options for the faking process. Keys: allow_an...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L61-L111
ska-sa/katcp-python
katcp/fake_clients.py
FakeInspectingClientManager.request_sensor_list
def request_sensor_list(self, req, msg): """Sensor list""" if msg.arguments: name = (msg.arguments[0],) keys = (name, ) if name not in self.fake_sensor_infos: return ("fail", "Unknown sensor name.") else: keys = self.fake_sensor_inf...
python
def request_sensor_list(self, req, msg): """Sensor list""" if msg.arguments: name = (msg.arguments[0],) keys = (name, ) if name not in self.fake_sensor_infos: return ("fail", "Unknown sensor name.") else: keys = self.fake_sensor_inf...
Sensor list
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L228-L244
ska-sa/katcp-python
katcp/fake_clients.py
FakeInspectingClientManager.add_sensors
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
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...
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 to a katcp.Message object, so some auto...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L253-L269
ska-sa/katcp-python
katcp/fake_clients.py
FakeInspectingClientManager.add_request_handlers_object
def add_request_handlers_object(self, rh_obj): """Add fake request handlers from an object with request_* method(s) See :meth:`FakeInspectingClientManager.add_request_handlers_dict` for more detail. """ rh_dict = {} for name in dir(rh_obj): if not callable(getattr(r...
python
def add_request_handlers_object(self, rh_obj): """Add fake request handlers from an object with request_* method(s) See :meth:`FakeInspectingClientManager.add_request_handlers_dict` for more detail. """ rh_dict = {} for name in dir(rh_obj): if not callable(getattr(r...
Add fake request handlers from an object with request_* method(s) See :meth:`FakeInspectingClientManager.add_request_handlers_dict` for more detail.
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L271-L286
ska-sa/katcp-python
katcp/fake_clients.py
FakeInspectingClientManager.add_request_handlers_dict
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
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 ...
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 in :class:`katcp.server.DeviceServerBase`. The fak...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L288-L303
ska-sa/katcp-python
katcp/fake_clients.py
FakeAsyncClient.future_request
def future_request(self, msg, timeout=None, use_mid=None): """Send a request messsage, with future replies. Parameters ---------- msg : Message object The request Message to send. timeout : float in seconds How long to wait for a reply. The default is the...
python
def future_request(self, msg, timeout=None, use_mid=None): """Send a request messsage, with future replies. Parameters ---------- msg : Message object The request Message to send. timeout : float in seconds How long to wait for a reply. The default is the...
Send a request messsage, with future replies. Parameters ---------- msg : Message object The request Message to send. timeout : float in seconds How long to wait for a reply. The default is the the timeout set when creating the AsyncClient. us...
https://github.com/ska-sa/katcp-python/blob/9127c826a1d030c53b84d0e95743e20e5c5ea153/katcp/fake_clients.py#L370-L406