volttron.platform package¶
Core package.
-
volttron.platform.
build_vip_address_string
(vip_root, serverkey, publickey, secretkey)[source]¶ Build a full vip address string based upon the passed arguments
All arguments are required to be non-None in order for the string to be created successfully.
:raises ValueError if one of the parameters is None.
-
volttron.platform.
get_address
()[source]¶ Return the VIP address of the platform If the VOLTTRON_VIP_ADDR environment variable is set, it used. Otherwise, it is derived from get_home().
-
volttron.platform.
get_config_path
() → str[source]¶ Returns the platforms main configuration file.
Returns:
-
volttron.platform.
get_home
()[source]¶ Return the home directory with user and variables expanded.
If the VOLTTRON_HOME environment variable is set, it used. Otherwise, the default value of ‘~/.volttron’ is used.
-
volttron.platform.
get_volttron_root
()[source]¶ Returns the root folder where the volttron code base resideds on disk.
Returns: absolute path to root folder
-
volttron.platform.
set_home
(home=None)[source]¶ Set the home directory with user and variables expanded.
If the home is sent in, it used. Otherwise, the default value of ‘~/.volttron’ is used.
Subpackages¶
- volttron.platform.agent package
- Subpackages
- volttron.platform.agent.base_market_agent package
- Submodules
- volttron.platform.agent.base_market_agent.buy_sell module
- volttron.platform.agent.base_market_agent.error_codes module
- volttron.platform.agent.base_market_agent.market_registration module
- volttron.platform.agent.base_market_agent.offer module
- volttron.platform.agent.base_market_agent.point module
- volttron.platform.agent.base_market_agent.poly_line module
- volttron.platform.agent.base_market_agent.poly_line_factory module
- volttron.platform.agent.base_market_agent.registration_manager module
- volttron.platform.agent.base_market_agent.rpc_proxy module
- volttron.platform.agent.base_market_agent package
- Submodules
- volttron.platform.agent.bacnet_proxy_reader module
- volttron.platform.agent.base module
- volttron.platform.agent.base_aggregate_historian module
- volttron.platform.agent.base_historian module
- volttron.platform.agent.base_tagging module
- volttron.platform.agent.base_weather module
- volttron.platform.agent.cron module
- volttron.platform.agent.driven module
- volttron.platform.agent.exit_codes module
- volttron.platform.agent.green module
- volttron.platform.agent.known_identities module
- volttron.platform.agent.matching module
- volttron.platform.agent.math_utils module
- volttron.platform.agent.multithreading module
- volttron.platform.agent.sched module
- volttron.platform.agent.utils module
- volttron.platform.agent.web module
- Subpackages
- volttron.platform.dbutils package
- Submodules
- volttron.platform.dbutils.basedb module
- volttron.platform.dbutils.crateutils module
- volttron.platform.dbutils.influxdbutils module
- volttron.platform.dbutils.mongoutils module
- volttron.platform.dbutils.mysqlfuncts module
- volttron.platform.dbutils.postgresqlfuncts module
- volttron.platform.dbutils.redshiftfuncts module
- volttron.platform.dbutils.sqlitefuncts module
- volttron.platform.dbutils.sqlutils module
- volttron.platform.lib package
- volttron.platform.messaging package
- volttron.platform.vip package
- Subpackages
- volttron.platform.vip.agent package
- Subpackages
- volttron.platform.vip.agent.subsystems package
- Submodules
- volttron.platform.vip.agent.subsystems.auth module
- volttron.platform.vip.agent.subsystems.base module
- volttron.platform.vip.agent.subsystems.channel module
- volttron.platform.vip.agent.subsystems.configstore module
- volttron.platform.vip.agent.subsystems.health module
- volttron.platform.vip.agent.subsystems.heartbeat module
- volttron.platform.vip.agent.subsystems.hello module
- volttron.platform.vip.agent.subsystems.peerlist module
- volttron.platform.vip.agent.subsystems.ping module
- volttron.platform.vip.agent.subsystems.pubsub module
- volttron.platform.vip.agent.subsystems.query module
- volttron.platform.vip.agent.subsystems.rmq_pubsub module
- volttron.platform.vip.agent.subsystems.rpc module
- volttron.platform.vip.agent.subsystems.volttronfncs module
- volttron.platform.vip.agent.subsystems.web module
- volttron.platform.vip.agent.subsystems package
- Submodules
- volttron.platform.vip.agent.compat module
- volttron.platform.vip.agent.connection module
- volttron.platform.vip.agent.core module
- volttron.platform.vip.agent.decorators module
- volttron.platform.vip.agent.dispatch module
- volttron.platform.vip.agent.errors module
- volttron.platform.vip.agent.example module
- volttron.platform.vip.agent.results module
- volttron.platform.vip.agent.utils module
- Subpackages
- volttron.platform.vip.agent package
- Submodules
- volttron.platform.vip.externalrpcservice module
- volttron.platform.vip.green module
- volttron.platform.vip.keydiscovery module
- volttron.platform.vip.proxy_zmq_router module
- volttron.platform.vip.pubsubservice module
- volttron.platform.vip.pubsubwrapper module
- volttron.platform.vip.rmq_connection module
- volttron.platform.vip.rmq_router module
- volttron.platform.vip.router module
- volttron.platform.vip.routingservice module
- volttron.platform.vip.socket module
- volttron.platform.vip.tracking module
- volttron.platform.vip.zmq_connection module
- Subpackages
- volttron.platform.web package
- Submodules
- volttron.platform.web.admin_endpoints module
- volttron.platform.web.authenticate_endpoint module
- volttron.platform.web.csr_endpoints module
- volttron.platform.web.discovery module
- volttron.platform.web.master_web_service module
- volttron.platform.web.webapp module
- volttron.platform.web.websocket module
Submodules¶
volttron.platform.aip module¶
volttron.platform.async_ module¶
Run gevent Greenlets in their own threads.
Supports killing threads and executing callbacks from other threads.
-
class
volttron.platform.async_.
AsyncCall
(hub=None)[source]¶ Bases:
object
Send functions to another thread’s gevent hub for execution.
-
send
(receiver, func, *args, **kwargs)[source]¶ Send a function to the hub to be called there.
All the arguments to this method are placed in a queue and the hub is signaled that a function is ready. When the hub switches to this handler, the functions are iterated over, each being called with its results sent to the receiver.
func is called with args and kwargs in the thread of the associated hub. If receiver is None, results are ignored and errors are printed when exceptions occur. Otherwise, receiver is called with the 2-tuple (exc_info, result). If an unhandled exception occurred, exc_info is the 3-tuple returned by sys.exc_info() and result is None. Otherwise exc_info is None and the result is func’s return value.
Note that receiver is called from the hub’s thread and may need to be injected into the thread of the receiver.
-
-
exception
volttron.platform.async_.
GreenletExit
¶ Bases:
BaseException
volttron.platform.auth module¶
-
class
volttron.platform.auth.
AuthEntry
(domain=None, address=None, mechanism='CURVE', credentials=None, user_id=None, groups=None, roles=None, capabilities=None, comments=None, enabled=True, **kwargs)[source]¶ Bases:
object
An authentication entry contains fields for authenticating and granting permissions to an agent that connects to the platform.
Parameters: - domain (str) – Name assigned to locally bound address
- address (str) – Remote address of the agent
- mechanism (str) – Authentication mechanism, valid options are ‘NULL’ (no authentication), ‘PLAIN’ (username/password), ‘CURVE’ (CurveMQ public/private keys)
- credentials (str) – Value depends on mechanism parameter:
None if mechanism is ‘NULL’; password if mechanism is
‘PLAIN’; encoded public key if mechanism is ‘CURVE’ (see
volttron.platform.vip.socket.encode_key()
for method to encode public key) - user_id (str) – Name to associate with agent (Note: this does not have to match the agent’s VIP identity)
- capabilities (list) – Authorized capabilities for this agent
- roles (list) – Authorized roles for this agent. (Role names map to a set of capabilities)
- groups (list) – Authorized groups for this agent. (Group names map to a set of roles)
- comments (str) – Comments to associate with entry
- enabled (bool) – Entry will only be used if this value is True
- kwargs – These extra arguments will be ignored
-
exception
volttron.platform.auth.
AuthEntryInvalid
[source]¶ Bases:
volttron.platform.auth.AuthException
Exception for invalid AuthEntry objects
-
exception
volttron.platform.auth.
AuthException
[source]¶ Bases:
Exception
General exception for any auth error
-
class
volttron.platform.auth.
AuthFile
(auth_file=None)[source]¶ Bases:
object
-
add
(auth_entry, overwrite=False)[source]¶ Adds an AuthEntry to the auth file
Parameters: Warning
If overwrite is set to False and if auth_entry matches an existing entry then this method will raise AuthFileEntryAlreadyExists
-
find_by_credentials
(credentials)[source]¶ Find all entries that have the given credentials
Parameters: credentials (str) – The credentials to search for Returns: list of entries Return type: list
-
read
()[source]¶ Gets the allowed entries, groups, and roles from the auth file.
Returns: tuple of allow-entries-list, groups-dict, roles-dict Return type: tuple
-
read_allow_entries
()[source]¶ Gets the allowed entries from the auth file.
Returns: list of allow-entries Return type: list
-
remove_by_credentials
(credentials)[source]¶ Removes entry from auth file by credential
Para credential: entries will this credential will be removed
-
remove_by_index
(index)[source]¶ Removes entry from auth file by index
Parameters: index (int) – index of entry to remove Warning
Calling with out-of-range index will raise AuthFileIndexError
-
remove_by_indices
(indices)[source]¶ Removes entry from auth file by indices
Parameters: indices (list) – list of indicies of entries to remove Warning
Calling with out-of-range index will raise AuthFileIndexError
-
set_groups
(groups)[source]¶ Define the mapping of group names to role lists
Parameters: groups (dict) – dict where the keys are group names and the values are lists of capability names Warning
Calling with invalid groups will raise ValueError
-
set_roles
(roles)[source]¶ Define the mapping of role names to capability lists
Parameters: roles – dict where the keys are role names and the values are lists of group names Warning
Calling with invalid roles will raise ValueError
-
update_by_index
(auth_entry, index)[source]¶ Updates entry will given auth entry at given index
Parameters: Warning
Calling with out-of-range index will raise AuthFileIndexError
-
version
¶
-
-
exception
volttron.platform.auth.
AuthFileEntryAlreadyExists
(indicies, message=None)[source]¶ Bases:
volttron.platform.auth.AuthFileIndexError
Exception if adding an entry that already exists
-
exception
volttron.platform.auth.
AuthFileIndexError
(indices, message=None)[source]¶ Bases:
volttron.platform.auth.AuthException
,IndexError
Exception for invalid indices provided to AuthFile
-
exception
volttron.platform.auth.
AuthFileUserIdAlreadyExists
(user_id, indicies, message=None)[source]¶ Bases:
volttron.platform.auth.AuthFileEntryAlreadyExists
Exception if adding an entry that has a taken user_id
-
class
volttron.platform.auth.
AuthService
(auth_file, protected_topics_file, setup_mode, aip, *args, **kwargs)[source]¶ Bases:
volttron.platform.vip.agent.Agent
RPC method
Approves a previously failed authorization
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol
RPC method
Denies a previously failed authorization
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol
RPC method
Denies a previously failed authorization
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol
RPC method
Gets capabilities, groups, and roles for a given user.
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol Returns: tuple of capabiliy-list, group-list, role-list Return type: tuple
-
get_capabilities
(user_id)[source]¶ RPC method
Gets capabilities for a given user.
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol Returns: list of capabilities Return type: list
-
get_groups
(user_id)[source]¶ RPC method
Gets groups for a given user.
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol Returns: list of groups Return type: list
-
get_roles
(user_id)[source]¶ RPC method
Gets roles for a given user.
Parameters: user_id (str) – user id field from VOLTTRON Interconnect Protocol Returns: list of roles Return type: list
-
get_user_to_capabilities
()[source]¶ RPC method
Gets a mapping of all users to their capabiliites.
Returns: mapping of users to capabilities Return type: dict
-
zap_loop
(sender, **kwargs)[source]¶ The zap loop is the starting of the authentication process for the VOLTTRON zmq message bus. It talks directly with the low level socket so all responses must be byte like objects, in this case we are going to send zmq frames across the wire.
Parameters: - sender –
- kwargs –
Returns:
volttron.platform.certs module¶
-
class
volttron.platform.certs.
CertWrapper
[source]¶ Bases:
object
This class is a wrapper around the building of certificates.
-
class
volttron.platform.certs.
Certs
(certificate_dir=None)[source]¶ Bases:
object
A wrapper class around certificate creation, retrieval and verification.
-
ca_cert
(public_bytes: bool = False)[source]¶ Get the X509 CA certificate. :return: the CA certificate of current volttron instance
-
ca_db_file
(name)[source]¶ return path to the ca db file of the passed name. Name passed should not contain any file extension :param name: name of the file :return: Full path the <name>_cadb.json file :rtype: str
-
ca_exists
()[source]¶ Returns true if the ca cert has been created already :return: True if CA cert exists, False otherwise
-
ca_serial_file
(name)[source]¶ return the file in which ca stores the next serial number to use :param name: name of the ca :return: Full path the <name>-serial file :rtype: str
-
cert
(name, remote=False, public_bytes: bool = False)[source]¶ Get the X509 certificate based upon the name :param public_bytes: :param name: name of the certificate to be loaded :param remote: determines correct path to search for the cert. :return: The certificate object by the given name :rtype: :class: x509._Certificate or byte PEM encoding
-
cert_exists
(cert_name, remote=False)[source]¶ Verifies that the cert exists by filename. :param cert_name: name of the cert to look up :return: True if cert exists, False otherwise
-
cert_file
(name, remote=False)[source]¶ Returns path to the certificate with passed name. .crt extension is added to the passed name be :param name: Name of the certificate file :param remote: Toggle between local and remote cert connections. :return: Full path the <name>.crt file :rtype: str
-
create_csr
(fully_qualified_identity, remote_instance_name)[source]¶ Create a csr with name as the common name.
The key that is used to sign the csr is <instance_name>.name.
Parameters: - fully_qualified_identity –
- target_volttron –
Returns:
-
create_root_ca
(overwrite=True, valid_days=365, **kwargs)[source]¶ Create a CA certificate with the given args and save it with the given name :param overwrite: boolan to indicate if we should overwrite
any existing CAParameters: - valid_days – Number of days for which the certificate should be valid. Defaults to 365 days
- kwargs –
Details about the certificate. Possible arguments:
C - Country ST - State L - Location O - Organization OU - Organizational Unit CN - Common Name
Returns:
-
create_signed_cert_files
(name, cert_type='client', ca_name=None, overwrite=True, valid_days=365, **kwargs)[source]¶ Create a new certificate and sign it with the volttron instance’s CA certificate. Save the created certificate and the private key of the certificate with the given name :param valid_days: number of days for which cert should be valid :param ca_name: name of the ca to sign this cert :param cert_type: client or server :param overwrite: boolean to denote if existing cert should be
overwrittenParameters: - name – name used to save the newly created certificate and private key. Files are saved as <name>.crt and <name>.pem
- kwargs –
dictionary object containing various details about who we are. Possible arguments:
C - Country ST - State L - Location O - Organization OU - Organizational Unit CN - Common Name
Returns: True if certificate creation was successful
-
static
get_admin_cert_names
(instance_name)[source]¶ Returns the name of the instance ca certificate(root ca), instance server certificate and instance client (admin user) certificate :param instance_name: name of the volttron instance :return: names of volttron instance certs
-
get_cert_public_key
(name, remote=False)[source]¶ Retrieves a publickey from the passed named certificate.
Traditional openssl format begins as follows
b’—–BEGIN PUBLIC KEY—–’
Parameters: - name – full instance and identity of the key
- remote –
Returns: serialized public key
-
get_cert_subject
(name)[source]¶ Retrieves the subject details of a certificate :param name: name of the certificate :return: dictionary object with the format {
‘country’:value, ‘state’: value, ‘location’: value, ‘organization’: value, ‘organization-unit’: value, ‘common-name’:value}
-
get_pk_bytes
(name)[source]¶ Serialize a private key in a traditional openssl manner to be able to use it with JWT and other technologies.
Traditional openssl format begins as follows
b’—–BEGIN RSA PRIVATE KEY—–’
Parameters: name – full instance and identity of the key Returns: serialized private key
-
private_key_file
(name)[source]¶ return path to the private key of the passed name. Name passed should not contain any file extension as .pem is prefixed :param name: name of the key file :return: Full path the <name>.pem file :rtype: str
-
save_agent_remote_info
(directory, local_keyname, remote_cert_name, remote_cert, remote_ca_name, remote_ca_cert)[source]¶ Save the remote info file, remote certificates and remote ca to the proper place in the remote_certificate directory.
Parameters: - local_keyname – identity of the local agent connected to the local messagebux
- remote_cert_name – identity of the dynamic agent connected to the remote message bus
- remote_cert – certificate returned from the remote instance
- remote_ca_name – name of the remote ca
- remote_ca_cert – certificate of the remote ca certificate
-
update_ca_db
(cert, ca_name, serial)[source]¶ Update the CA db with details of the file that the ca signed. :param cert: cert that was signed by ca_name :param ca_name: name of the ca that signed the cert
-
-
volttron.platform.certs.
get_passphrase
(verify=True, prompt1='Enter passphrase:', prompt2='Verify passphrase:')[source]¶ Prompt passphrase from user and return it :param verify: If user should be prompt twice for verification :param prompt1: Prompt to be used for initial input :param prompt2: Prompt to used for verification :return: The passphrase entered by user :type verify: bool :type prompt1: str :type prompt2: str
volttron.platform.config module¶
volttron.platform.control module¶
volttron.platform.deployment module¶
volttron.platform.instance_setup module¶
volttron.platform.jsonapi module¶
-
volttron.platform.jsonapi.
dump
(obj, fp, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)[source]¶ Serialize
obj
as a JSON formatted stream tofp
(a.write()
-supporting file-like object).If
skipkeys
is true thendict
keys that are not basic types (str
,int
,float
,bool
,None
) will be skipped instead of raising aTypeError
.If
ensure_ascii
is false, then the strings written tofp
can contain non-ASCII characters if they appear in strings contained inobj
. Otherwise, all such characters are escaped in JSON strings.If
check_circular
is false, then the circular reference check for container types will be skipped and a circular reference will result in anOverflowError
(or worse).If
allow_nan
is false, then it will be aValueError
to serialize out of rangefloat
values (nan
,inf
,-inf
) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN
,Infinity
,-Infinity
).If
indent
is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.None
is the most compact representation.If specified,
separators
should be an(item_separator, key_separator)
tuple. The default is(', ', ': ')
if indent isNone
and(',', ': ')
otherwise. To get the most compact JSON representation, you should specify(',', ':')
to eliminate whitespace.default(obj)
is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.If sort_keys is true (default:
False
), then the output of dictionaries will be sorted by key.To use a custom
JSONEncoder
subclass (e.g. one that overrides the.default()
method to serialize additional types), specify it with thecls
kwarg; otherwiseJSONEncoder
is used.
-
volttron.platform.jsonapi.
dumps
(obj, *, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, cls=None, indent=None, separators=None, default=None, sort_keys=False, **kw)[source]¶ Serialize
obj
to a JSON formattedstr
.If
skipkeys
is true thendict
keys that are not basic types (str
,int
,float
,bool
,None
) will be skipped instead of raising aTypeError
.If
ensure_ascii
is false, then the return value can contain non-ASCII characters if they appear in strings contained inobj
. Otherwise, all such characters are escaped in JSON strings.If
check_circular
is false, then the circular reference check for container types will be skipped and a circular reference will result in anOverflowError
(or worse).If
allow_nan
is false, then it will be aValueError
to serialize out of rangefloat
values (nan
,inf
,-inf
) in strict compliance of the JSON specification, instead of using the JavaScript equivalents (NaN
,Infinity
,-Infinity
).If
indent
is a non-negative integer, then JSON array elements and object members will be pretty-printed with that indent level. An indent level of 0 will only insert newlines.None
is the most compact representation.If specified,
separators
should be an(item_separator, key_separator)
tuple. The default is(', ', ': ')
if indent isNone
and(',', ': ')
otherwise. To get the most compact JSON representation, you should specify(',', ':')
to eliminate whitespace.default(obj)
is a function that should return a serializable version of obj or raise TypeError. The default simply raises TypeError.If sort_keys is true (default:
False
), then the output of dictionaries will be sorted by key.To use a custom
JSONEncoder
subclass (e.g. one that overrides the.default()
method to serialize additional types), specify it with thecls
kwarg; otherwiseJSONEncoder
is used.
-
volttron.platform.jsonapi.
load
(fp, *, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)[source]¶ Deserialize
fp
(a.read()
-supporting file-like object containing a JSON document) to a Python object.object_hook
is an optional function that will be called with the result of any object literal decode (adict
). The return value ofobject_hook
will be used instead of thedict
. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).object_pairs_hook
is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value ofobject_pairs_hook
will be used instead of thedict
. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). Ifobject_hook
is also defined, theobject_pairs_hook
takes priority.To use a custom
JSONDecoder
subclass, specify it with thecls
kwarg; otherwiseJSONDecoder
is used.
-
volttron.platform.jsonapi.
loads
(s, *, encoding=None, cls=None, object_hook=None, parse_float=None, parse_int=None, parse_constant=None, object_pairs_hook=None, **kw)[source]¶ Deserialize
s
(astr
,bytes
orbytearray
instance containing a JSON document) to a Python object.object_hook
is an optional function that will be called with the result of any object literal decode (adict
). The return value ofobject_hook
will be used instead of thedict
. This feature can be used to implement custom decoders (e.g. JSON-RPC class hinting).object_pairs_hook
is an optional function that will be called with the result of any object literal decoded with an ordered list of pairs. The return value ofobject_pairs_hook
will be used instead of thedict
. This feature can be used to implement custom decoders that rely on the order that the key and value pairs are decoded (for example, collections.OrderedDict will remember the order of insertion). Ifobject_hook
is also defined, theobject_pairs_hook
takes priority.parse_float
, if specified, will be called with the string of every JSON float to be decoded. By default this is equivalent to float(num_str). This can be used to use another datatype or parser for JSON floats (e.g. decimal.Decimal).parse_int
, if specified, will be called with the string of every JSON int to be decoded. By default this is equivalent to int(num_str). This can be used to use another datatype or parser for JSON integers (e.g. float).parse_constant
, if specified, will be called with one of the following strings: -Infinity, Infinity, NaN. This can be used to raise an exception if invalid JSON numbers are encountered.To use a custom
JSONDecoder
subclass, specify it with thecls
kwarg; otherwiseJSONDecoder
is used.The
encoding
argument is ignored and deprecated.
volttron.platform.jsonrpc module¶
Implementation of JSON-RPC 2.0 with support for bi-directional calls.
See http://www.jsonrpc.org/specification for the complete specification.
-
exception
volttron.platform.jsonrpc.
Error
(code, message, data=None)[source]¶ Bases:
Exception
Raised when a recoverable JSON-RPC protocol error occurs.
-
exception
volttron.platform.jsonrpc.
MethodNotFound
(code, message, data=None)[source]¶ Bases:
volttron.platform.jsonrpc.Error
Raised when remote method is not implemented.
-
exception
volttron.platform.jsonrpc.
RemoteError
(message, **exc_info)[source]¶ Bases:
Exception
Report the details of an error which occurred remotely.
Instances of this exception are usually created by exception_from_json(), which uses the ‘detail’ element of the JSON-RPC error for message, if it is set, otherwise the JSON-RPC error message. The exc_info argument is set from the ‘exception.py’ element associated with an error code of -32000 (UNHANDLED_EXCEPTION). Typical keys in exc_info are exc_type, exc_args, and exc_tb (if tracebacks are allowed) which are stringified versions of the tuple returned from sys.exc_info().
-
class
volttron.platform.jsonrpc.
Dispatcher
[source]¶ Bases:
object
Parses and directs JSON-RPC 2.0 requests/responses.
Parses a JSON-RPC message conatained in a dictionary (JavaScript object) or a batch of messages (list of dictionaries) and dispatches them appropriately.
Subclasses must implement the serialize and deserialize methods with the JSON library of choice. The exception, result, error, method and batch handling methods should also be implemented.
-
batch
(request, context=None)[source]¶ Context manager for batch requests.
Entered before processing a batch request and exited afterward.
-
batch_call
(requests)[source]¶ Create and return a request for a batch of method calls.
requests is an iterator of lists or tuples with 4 items each: ident, method, args, kwargs. These are the same 4 arguments required by the call() method. The first (ident) element may be None to indicate a notification.
-
call
(ident, method, args=None, kwargs=None)[source]¶ Create and return a request for a single method call.
-
dispatch
(message: (<class 'dict'>, <class 'list'>), context: str = None)[source]¶ Dispatch a JSON-RPC message and return a response or None.
-
error
(response, ident, code, message, data=None, context=None)[source]¶ Called when an error resposne is received.
-
exception
(response, ident, message, context=None)[source]¶ Called for response errors.
Typically called when a response, such as an error, does not contain all the necessary members and sending an error to the remote peer is not possible. Also called when serializing a response fails.
-
method
(request, ident, name, args, kwargs, batch=None, context=None)[source]¶ Called to get make method call and return results.
request is the original JSON request (as dict). name is the name of the method requested. Only one of args or kwargs will contain parameters. If method is being executed as part of a batch request, batch will be the value returned from the batch() context manager.
This method should raise NotImplementedError() if the method is unimplemented. Otherwise, it should return the result of the method call or raise an exception. If the raised exception has a traceback attribute, which should be a string (if set), it will be sent back in the returned error. An exc_info attribute may also be set which must be a dictionary and will be used as the basis for the exception.py member of the returned error.
-
volttron.platform.keystore module¶
Module for storing local public and secret keys and remote public keys
-
class
volttron.platform.keystore.
BaseJSONStore
(filename, permissions=384)[source]¶ Bases:
object
JSON-file-backed store for dictionaries
-
class
volttron.platform.keystore.
KeyStore
(filename=None, encoded_public=None, encoded_secret=None)[source]¶ Bases:
volttron.platform.keystore.BaseJSONStore
Handle generation, storage, and retrival of CURVE key pairs
-
public
¶ Return encoded public key
-
secret
¶ Return encoded secret key
-
volttron.platform.main module¶
volttron.platform.packages module¶
volttron.platform.packaging module¶
volttron.platform.resmon module¶
volttron.platform.scheduling module¶
Schedule generators.
-
volttron.platform.scheduling.
cron
(cron_string, start=None, stop=None, second=0)[source]¶ Return a schedule generator from a cron-style string.
cron_string is a cron-style time expression consisting of five whitespace-separated fields explained in further detail below. start and stop are used to bound the schedule and can be None, datetime.datetime or datetime.timedelta objects or numeric values, such as is returned by time.time(). If start is None, the current time is used. If it is a timedelta, it will be added to the current time. If stop is None, cron will generate values infinitely. If it is a timedelta, the end time is the start time plus stop. Each iteration yields a datetime.datetime object. Since the smallest cron unit is a minute, second may be passed in to offset the time within the minute.
The following description of the cron fields is taken from the crontab(5) man page (with slight modifications).
The time and date fields are:
field allowed values —– ————– minute 0-59 hour 0-23 day of month 1-31 month 1-12 (or names, see below) day of week 0-7 (0 or 7 is Sunday, or use names)A field may contain an asterisk (*), which always stands for “first-last”.
Ranges of numbers are allowed. Ranges are two numbers separated with a hyphen. The specified range is inclusive. For example, 8-11 for an ‘hours’ entry specifies execution at hours 8, 9, 10, and 11. If the range start or end value is left off, the first or last value will be used. For example, -8 for an ‘hours’ entry is equivalent to 0-8, 20- for a ‘days of month’ entry is equivalent to 20-31, and - for a ‘months’ entry is equivalent to 1-12.
Lists are allowed. A list is a set of numbers (or ranges) separated by commas. Examples: “1,2,5,9”, “0-4,8-12”.
Step values can be used in conjunction with ranges. Following a range with “/<number>” specifies skips of the number’s value through the range. For example, “0-23/2” can be used in the ‘hours’ field to specify every other hour. Step values are also permitted after an asterisk, “*/2” in the ‘hours’ field is equivalent to “0-23/2”.
Names can also be used for the ‘month’ and ‘day of week’ fields. Use at least the first three letters of the particular day or month (case does not matter).
Note: The day can be specified in the following two fields: ‘day of month’, and ‘day of week’. If both fields are restricted (i.e., do not contain the “*” character), then both are used to compute date/time values. For example, “30 4 1,15 * 5” is interpreted as “4:30 am on the 1st and 15th of each month, plus every Friday.”
-
volttron.platform.scheduling.
periodic
(period, start=None, stop=None)[source]¶ Generate periodic datetime objects.
Yields datetime objects increasing by the given period, which can be of type int, long, float, or datetime.timedelta. start and stop are used to bound the schedule and can be None, datetime.datetime or datetime.timedelta objects or numeric values, such as is returned by time.time(). If start is None, the current time is used. If it is a timedelta, it will be added to the current time. If stop is None, cron will generate values infinitely. If it is a timedelta, the end time is the start time plus stop. Each iteration yields a datetime.datetime object.
volttron.platform.store module¶
-
class
volttron.platform.store.
ConfigStoreService
(*args, **kwargs)[source]¶
volttron.platform.storeutils module¶
-
volttron.platform.storeutils.
check_for_recursion
(new_config_name, new_config, existing_configs)[source]¶