repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileInfo.get_data
def get_data(self): """Get the contents of this file :return: The contents of this file :rtype: six.binary_type """ target = DeviceTarget(self.device_id) return self._fssapi.get_file(target, self.path)[self.device_id]
python
def get_data(self): """Get the contents of this file :return: The contents of this file :rtype: six.binary_type """ target = DeviceTarget(self.device_id) return self._fssapi.get_file(target, self.path)[self.device_id]
[ "def", "get_data", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "get_file", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
Get the contents of this file :return: The contents of this file :rtype: six.binary_type
[ "Get", "the", "contents", "of", "this", "file" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L116-L124
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileInfo.delete
def delete(self): """Delete this file from the device .. note:: After deleting the file, this object will no longer contain valid information and further calls to delete or get_data will return :class:`~.ErrorInfo` objects """ target = DeviceTarget(self.device_id) ...
python
def delete(self): """Delete this file from the device .. note:: After deleting the file, this object will no longer contain valid information and further calls to delete or get_data will return :class:`~.ErrorInfo` objects """ target = DeviceTarget(self.device_id) ...
[ "def", "delete", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "delete_file", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
Delete this file from the device .. note:: After deleting the file, this object will no longer contain valid information and further calls to delete or get_data will return :class:`~.ErrorInfo` objects
[ "Delete", "this", "file", "from", "the", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L126-L134
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
DirectoryInfo.list_contents
def list_contents(self): """List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.lis...
python
def list_contents(self): """List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.lis...
[ "def", "list_contents", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "list_files", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.list_contents() if isinstan...
[ "List", "the", "contents", "of", "this", "directory" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L174-L197
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
LsCommand.parse_response
def parse_response(cls, response, device_id=None, fssapi=None, **kwargs): """Parse the server response for this ls command This will parse xml of the following form:: <ls hash="hash_type"> <file path="file_path" last_modified=last_modified_time ... /> ... ...
python
def parse_response(cls, response, device_id=None, fssapi=None, **kwargs): """Parse the server response for this ls command This will parse xml of the following form:: <ls hash="hash_type"> <file path="file_path" last_modified=last_modified_time ... /> ... ...
[ "def", "parse_response", "(", "cls", ",", "response", ",", "device_id", "=", "None", ",", "fssapi", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "tag", "!=", "cls", ".", "command_name", ":", "raise", "ResponseParseError", "(", ...
Parse the server response for this ls command This will parse xml of the following form:: <ls hash="hash_type"> <file path="file_path" last_modified=last_modified_time ... /> ... <dir path="dir_path" last_modified=last_modified_time /> ... ...
[ "Parse", "the", "server", "response", "for", "this", "ls", "command" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L282-L343
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
GetCommand.parse_response
def parse_response(cls, response, **kwargs): """Parse the server response for this get file command This will parse xml of the following form:: <get_file> <data> asdfasdfasdfasdfasf </data> </get_file> or with an error...
python
def parse_response(cls, response, **kwargs): """Parse the server response for this get file command This will parse xml of the following form:: <get_file> <data> asdfasdfasdfasdfasf </data> </get_file> or with an error...
[ "def", "parse_response", "(", "cls", ",", "response", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "tag", "!=", "cls", ".", "command_name", ":", "raise", "ResponseParseError", "(", "\"Received response of type {}, GetCommand can only parse responses of ty...
Parse the server response for this get file command This will parse xml of the following form:: <get_file> <data> asdfasdfasdfasdfasf </data> </get_file> or with an error:: <get_file> <error ... />...
[ "Parse", "the", "server", "response", "for", "this", "get", "file", "command" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L375-L409
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
PutCommand.parse_response
def parse_response(cls, response, **kwargs): """Parse the server response for this put file command This will parse xml of the following form:: <put_file /> or with an error:: <put_file> <error ... /> </put_file> :param response: T...
python
def parse_response(cls, response, **kwargs): """Parse the server response for this put file command This will parse xml of the following form:: <put_file /> or with an error:: <put_file> <error ... /> </put_file> :param response: T...
[ "def", "parse_response", "(", "cls", ",", "response", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "tag", "!=", "cls", ".", "command_name", ":", "raise", "ResponseParseError", "(", "\"Received response of type {}, PutCommand can only parse responses of ty...
Parse the server response for this put file command This will parse xml of the following form:: <put_file /> or with an error:: <put_file> <error ... /> </put_file> :param response: The XML root of the response for a put file command ...
[ "Parse", "the", "server", "response", "for", "this", "put", "file", "command" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L459-L484
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.send_command_block
def send_command_block(self, target, command_block): """Send an arbitrary file system command block The primary use for this method is to send multiple file system commands with a single web service request. This can help to avoid throttling. :param target: The device(s) to be targete...
python
def send_command_block(self, target, command_block): """Send an arbitrary file system command block The primary use for this method is to send multiple file system commands with a single web service request. This can help to avoid throttling. :param target: The device(s) to be targete...
[ "def", "send_command_block", "(", "self", ",", "target", ",", "command_block", ")", ":", "root", "=", "_parse_command_response", "(", "self", ".", "_sci_api", ".", "send_sci", "(", "\"file_system\"", ",", "target", ",", "command_block", ".", "get_command_string", ...
Send an arbitrary file system command block The primary use for this method is to send multiple file system commands with a single web service request. This can help to avoid throttling. :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sc...
[ "Send", "an", "arbitrary", "file", "system", "command", "block" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L542-L573
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.list_files
def list_files(self, target, path, hash='any'): """List all files and directories in the path on the target :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path:...
python
def list_files(self, target, path, hash='any'): """List all files and directories in the path on the target :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path:...
[ "def", "list_files", "(", "self", ",", "target", ",", "path", ",", "hash", "=", "'any'", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")", "command_block", ".", "add_command", "(", "LsCommand", "(", "path", ",", "hash", "=", "hash", ...
List all files and directories in the path on the target :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to list files and directories from ...
[ "List", "all", "files", "and", "directories", "in", "the", "path", "on", "the", "target" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L575-L660
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.get_file
def get_file(self, target, path, offset=None, length=None): """Get the contents of a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
python
def get_file(self, target, path, offset=None, length=None): """Get the contents of a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
[ "def", "get_file", "(", "self", ",", "target", ",", "path", ",", "offset", "=", "None", ",", "length", "=", "None", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")", "command_block", ".", "add_command", "(", "GetCommand", "(", "path"...
Get the contents of a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to retrieve :param offset: Star...
[ "Get", "the", "contents", "of", "a", "file", "on", "the", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L662-L687
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.put_file
def put_file(self, target, path, file_data=None, server_file=None, offset=None, truncate=False): """Put data into a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` ins...
python
def put_file(self, target, path, file_data=None, server_file=None, offset=None, truncate=False): """Put data into a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` ins...
[ "def", "put_file", "(", "self", ",", "target", ",", "path", ",", "file_data", "=", "None", ",", "server_file", "=", "None", ",", "offset", "=", "None", ",", "truncate", "=", "False", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")"...
Put data into a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to write to. If the file already exists it w...
[ "Put", "data", "into", "a", "file", "on", "the", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L689-L721
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.delete_file
def delete_file(self, target, path): """Delete a file from a device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to d...
python
def delete_file(self, target, path): """Delete a file from a device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to d...
[ "def", "delete_file", "(", "self", ",", "target", ",", "path", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")", "command_block", ".", "add_command", "(", "DeleteCommand", "(", "path", ")", ")", "root", "=", "_parse_command_response", "(...
Delete a file from a device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to delete. :return: A dictionary with keys b...
[ "Delete", "a", "file", "from", "a", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L723-L745
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.get_modified_items
def get_modified_items(self, target, path, last_modified_cutoff): """Get all files and directories from a path on the device modified since a given time :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud....
python
def get_modified_items(self, target, path, last_modified_cutoff): """Get all files and directories from a path on the device modified since a given time :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud....
[ "def", "get_modified_items", "(", "self", ",", "target", ",", "path", ",", "last_modified_cutoff", ")", ":", "file_list", "=", "self", ".", "list_files", "(", "target", ",", "path", ")", "out_dict", "=", "{", "}", "for", "device_id", ",", "device_data", "i...
Get all files and directories from a path on the device modified since a given time :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the d...
[ "Get", "all", "files", "and", "directories", "from", "a", "path", "on", "the", "device", "modified", "since", "a", "given", "time" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L747-L776
train
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.exists
def exists(self, target, path, path_sep="/"): """Check if path refers to an existing path on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
python
def exists(self, target, path, path_sep="/"): """Check if path refers to an existing path on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
[ "def", "exists", "(", "self", ",", "target", ",", "path", ",", "path_sep", "=", "\"/\"", ")", ":", "if", "path", ".", "endswith", "(", "path_sep", ")", ":", "path", "=", "path", "[", ":", "-", "len", "(", "path_sep", ")", "]", "par_dir", ",", "fi...
Check if path refers to an existing path on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to check for existence. :para...
[ "Check", "if", "path", "refers", "to", "an", "existing", "path", "on", "the", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L778-L805
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.get_devices
def get_devices(self, condition=None, page_size=1000): """Iterates over each :class:`Device` for this device cloud account Examples:: # get a list of all devices all_devices = list(dc.devicecore.get_devices()) # build a mapping of devices by their vendor id using a...
python
def get_devices(self, condition=None, page_size=1000): """Iterates over each :class:`Device` for this device cloud account Examples:: # get a list of all devices all_devices = list(dc.devicecore.get_devices()) # build a mapping of devices by their vendor id using a...
[ "def", "get_devices", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "condition", "=", "validate_type", "(", "condition", ",", "type", "(", "None", ")", ",", "Expression", ",", "*", "six", ".", "string_types", ")", ...
Iterates over each :class:`Device` for this device cloud account Examples:: # get a list of all devices all_devices = list(dc.devicecore.get_devices()) # build a mapping of devices by their vendor id using a # dict comprehension devices = dc.devicec...
[ "Iterates", "over", "each", ":", "class", ":", "Device", "for", "this", "device", "cloud", "account" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L48-L83
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.get_group_tree_root
def get_group_tree_root(self, page_size=1000): r"""Return the root group for this accounts' group tree This will return the root group for this tree but with all links between nodes (i.e. children starting from root) populated. Examples:: # print the group hierarchy to std...
python
def get_group_tree_root(self, page_size=1000): r"""Return the root group for this accounts' group tree This will return the root group for this tree but with all links between nodes (i.e. children starting from root) populated. Examples:: # print the group hierarchy to std...
[ "def", "get_group_tree_root", "(", "self", ",", "page_size", "=", "1000", ")", ":", "# first pass, build mapping", "group_map", "=", "{", "}", "# map id -> group", "page_size", "=", "validate_type", "(", "page_size", ",", "*", "six", ".", "integer_types", ")", "...
r"""Return the root group for this accounts' group tree This will return the root group for this tree but with all links between nodes (i.e. children starting from root) populated. Examples:: # print the group hierarchy to stdout dc.devicecore.get_group_tree_root().pri...
[ "r", "Return", "the", "root", "group", "for", "this", "accounts", "group", "tree" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L85-L134
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.get_groups
def get_groups(self, condition=None, page_size=1000): """Return an iterator over all groups in this device cloud account Optionally, a condition can be specified to limit the number of groups returned. Examples:: # Get all groups and print information about them ...
python
def get_groups(self, condition=None, page_size=1000): """Return an iterator over all groups in this device cloud account Optionally, a condition can be specified to limit the number of groups returned. Examples:: # Get all groups and print information about them ...
[ "def", "get_groups", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "query_kwargs", "=", "{", "}", "if", "condition", "is", "not", "None", ":", "query_kwargs", "[", "\"condition\"", "]", "=", "condition", ".", "compi...
Return an iterator over all groups in this device cloud account Optionally, a condition can be specified to limit the number of groups returned. Examples:: # Get all groups and print information about them for group in dc.devicecore.get_groups(): print ...
[ "Return", "an", "iterator", "over", "all", "groups", "in", "this", "device", "cloud", "account" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L136-L167
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.provision_devices
def provision_devices(self, devices): """Provision multiple devices with a single API call This method takes an iterable of dictionaries where the values in the dictionary are expected to match the arguments of a call to :meth:`provision_device`. The contents of each dictionary will be...
python
def provision_devices(self, devices): """Provision multiple devices with a single API call This method takes an iterable of dictionaries where the values in the dictionary are expected to match the arguments of a call to :meth:`provision_device`. The contents of each dictionary will be...
[ "def", "provision_devices", "(", "self", ",", "devices", ")", ":", "# Validate all the input for each device provided", "sio", "=", "six", ".", "StringIO", "(", ")", "def", "write_tag", "(", "tag", ",", "val", ")", ":", "sio", ".", "write", "(", "\"<{tag}>{val...
Provision multiple devices with a single API call This method takes an iterable of dictionaries where the values in the dictionary are expected to match the arguments of a call to :meth:`provision_device`. The contents of each dictionary will be validated. :param list devices: An iter...
[ "Provision", "multiple", "devices", "with", "a", "single", "API", "call" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L237-L312
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Group.from_json
def from_json(cls, json_data): """Build and return a new Group object from json data (used internally)""" # Example Data: # { "grpId": "11817", "grpName": "7603_Digi", "grpDescription": "7603_Digi root group", # "grpPath": "\/7603_Digi\/", "grpParentId": "1"} return cls( ...
python
def from_json(cls, json_data): """Build and return a new Group object from json data (used internally)""" # Example Data: # { "grpId": "11817", "grpName": "7603_Digi", "grpDescription": "7603_Digi root group", # "grpPath": "\/7603_Digi\/", "grpParentId": "1"} return cls( ...
[ "def", "from_json", "(", "cls", ",", "json_data", ")", ":", "# Example Data:", "# { \"grpId\": \"11817\", \"grpName\": \"7603_Digi\", \"grpDescription\": \"7603_Digi root group\",", "# \"grpPath\": \"\\/7603_Digi\\/\", \"grpParentId\": \"1\"}", "return", "cls", "(", "group_id", "=", ...
Build and return a new Group object from json data (used internally)
[ "Build", "and", "return", "a", "new", "Group", "object", "from", "json", "data", "(", "used", "internally", ")" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L335-L346
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Group.print_subtree
def print_subtree(self, fobj=sys.stdout, level=0): """Print this group node and the subtree rooted at it""" fobj.write("{}{!r}\n".format(" " * (level * 2), self)) for child in self.get_children(): child.print_subtree(fobj, level + 1)
python
def print_subtree(self, fobj=sys.stdout, level=0): """Print this group node and the subtree rooted at it""" fobj.write("{}{!r}\n".format(" " * (level * 2), self)) for child in self.get_children(): child.print_subtree(fobj, level + 1)
[ "def", "print_subtree", "(", "self", ",", "fobj", "=", "sys", ".", "stdout", ",", "level", "=", "0", ")", ":", "fobj", ".", "write", "(", "\"{}{!r}\\n\"", ".", "format", "(", "\" \"", "*", "(", "level", "*", "2", ")", ",", "self", ")", ")", "for"...
Print this group node and the subtree rooted at it
[ "Print", "this", "group", "node", "and", "the", "subtree", "rooted", "at", "it" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L353-L357
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_device_json
def get_device_json(self, use_cached=True): """Get the JSON metadata for this device as a python data structure If ``use_cached`` is not True, then a web services request will be made synchronously in order to get the latest device metatdata. This will update the cached data for this d...
python
def get_device_json(self, use_cached=True): """Get the JSON metadata for this device as a python data structure If ``use_cached`` is not True, then a web services request will be made synchronously in order to get the latest device metatdata. This will update the cached data for this d...
[ "def", "get_device_json", "(", "self", ",", "use_cached", "=", "True", ")", ":", "if", "not", "use_cached", ":", "devicecore_data", "=", "self", ".", "_conn", ".", "get_json", "(", "\"/ws/DeviceCore/{}\"", ".", "format", "(", "self", ".", "get_device_id", "(...
Get the JSON metadata for this device as a python data structure If ``use_cached`` is not True, then a web services request will be made synchronously in order to get the latest device metatdata. This will update the cached data for this device.
[ "Get", "the", "JSON", "metadata", "for", "this", "device", "as", "a", "python", "data", "structure" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L405-L417
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_tags
def get_tags(self, use_cached=True): """Get the list of tags for this device""" device_json = self.get_device_json(use_cached) potential_tags = device_json.get("dpTags") if potential_tags: return list(filter(None, potential_tags.split(","))) else: return [...
python
def get_tags(self, use_cached=True): """Get the list of tags for this device""" device_json = self.get_device_json(use_cached) potential_tags = device_json.get("dpTags") if potential_tags: return list(filter(None, potential_tags.split(","))) else: return [...
[ "def", "get_tags", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "potential_tags", "=", "device_json", ".", "get", "(", "\"dpTags\"", ")", "if", "potential_tags", ":", "retu...
Get the list of tags for this device
[ "Get", "the", "list", "of", "tags", "for", "this", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L419-L426
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.is_connected
def is_connected(self, use_cached=True): """Return True if the device is currrently connect and False if not""" device_json = self.get_device_json(use_cached) return int(device_json.get("dpConnectionStatus")) > 0
python
def is_connected(self, use_cached=True): """Return True if the device is currrently connect and False if not""" device_json = self.get_device_json(use_cached) return int(device_json.get("dpConnectionStatus")) > 0
[ "def", "is_connected", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "int", "(", "device_json", ".", "get", "(", "\"dpConnectionStatus\"", ")", ")", ">", "0" ]
Return True if the device is currrently connect and False if not
[ "Return", "True", "if", "the", "device", "is", "currrently", "connect", "and", "False", "if", "not" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L428-L431
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_connectware_id
def get_connectware_id(self, use_cached=True): """Get the connectware id of this device (primary key)""" device_json = self.get_device_json(use_cached) return device_json.get("devConnectwareId")
python
def get_connectware_id(self, use_cached=True): """Get the connectware id of this device (primary key)""" device_json = self.get_device_json(use_cached) return device_json.get("devConnectwareId")
[ "def", "get_connectware_id", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", ".", "get", "(", "\"devConnectwareId\"", ")" ]
Get the connectware id of this device (primary key)
[ "Get", "the", "connectware", "id", "of", "this", "device", "(", "primary", "key", ")" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L433-L436
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_device_id
def get_device_id(self, use_cached=True): """Get this device's device id""" device_json = self.get_device_json(use_cached) return device_json["id"].get("devId")
python
def get_device_id(self, use_cached=True): """Get this device's device id""" device_json = self.get_device_json(use_cached) return device_json["id"].get("devId")
[ "def", "get_device_id", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", "[", "\"id\"", "]", ".", "get", "(", "\"devId\"", ")" ]
Get this device's device id
[ "Get", "this", "device", "s", "device", "id" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L438-L441
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_ip
def get_ip(self, use_cached=True): """Get the last known IP of this device""" device_json = self.get_device_json(use_cached) return device_json.get("dpLastKnownIp")
python
def get_ip(self, use_cached=True): """Get the last known IP of this device""" device_json = self.get_device_json(use_cached) return device_json.get("dpLastKnownIp")
[ "def", "get_ip", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", ".", "get", "(", "\"dpLastKnownIp\"", ")" ]
Get the last known IP of this device
[ "Get", "the", "last", "known", "IP", "of", "this", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L443-L446
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_mac
def get_mac(self, use_cached=True): """Get the MAC address of this device""" device_json = self.get_device_json(use_cached) return device_json.get("devMac")
python
def get_mac(self, use_cached=True): """Get the MAC address of this device""" device_json = self.get_device_json(use_cached) return device_json.get("devMac")
[ "def", "get_mac", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", ".", "get", "(", "\"devMac\"", ")" ]
Get the MAC address of this device
[ "Get", "the", "MAC", "address", "of", "this", "device" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L448-L451
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_mac_last4
def get_mac_last4(self, use_cached=True): """Get the last 4 characters in the device mac address hex (e.g. 00:40:9D:58:17:5B -> 175B) This is useful for use as a short reference to the device. It is not guaranteed to be unique (obviously) but will often be if you don't have too many devices. ...
python
def get_mac_last4(self, use_cached=True): """Get the last 4 characters in the device mac address hex (e.g. 00:40:9D:58:17:5B -> 175B) This is useful for use as a short reference to the device. It is not guaranteed to be unique (obviously) but will often be if you don't have too many devices. ...
[ "def", "get_mac_last4", "(", "self", ",", "use_cached", "=", "True", ")", ":", "chunks", "=", "self", ".", "get_mac", "(", "use_cached", ")", ".", "split", "(", "\":\"", ")", "mac4", "=", "\"%s%s\"", "%", "(", "chunks", "[", "-", "2", "]", ",", "ch...
Get the last 4 characters in the device mac address hex (e.g. 00:40:9D:58:17:5B -> 175B) This is useful for use as a short reference to the device. It is not guaranteed to be unique (obviously) but will often be if you don't have too many devices.
[ "Get", "the", "last", "4", "characters", "in", "the", "device", "mac", "address", "hex", "(", "e", ".", "g", ".", "00", ":", "40", ":", "9D", ":", "58", ":", "17", ":", "5B", "-", ">", "175B", ")" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L453-L462
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_registration_dt
def get_registration_dt(self, use_cached=True): """Get the datetime of when this device was added to Device Cloud""" device_json = self.get_device_json(use_cached) start_date_iso8601 = device_json.get("devRecordStartDate") if start_date_iso8601: return iso8601_to_dt(start_dat...
python
def get_registration_dt(self, use_cached=True): """Get the datetime of when this device was added to Device Cloud""" device_json = self.get_device_json(use_cached) start_date_iso8601 = device_json.get("devRecordStartDate") if start_date_iso8601: return iso8601_to_dt(start_dat...
[ "def", "get_registration_dt", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "start_date_iso8601", "=", "device_json", ".", "get", "(", "\"devRecordStartDate\"", ")", "if", "star...
Get the datetime of when this device was added to Device Cloud
[ "Get", "the", "datetime", "of", "when", "this", "device", "was", "added", "to", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L464-L471
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_latlon
def get_latlon(self, use_cached=True): """Get a tuple with device latitude and longitude... these may be None""" device_json = self.get_device_json(use_cached) lat = device_json.get("dpMapLat") lon = device_json.get("dpMapLong") return (float(lat) if lat else None, ...
python
def get_latlon(self, use_cached=True): """Get a tuple with device latitude and longitude... these may be None""" device_json = self.get_device_json(use_cached) lat = device_json.get("dpMapLat") lon = device_json.get("dpMapLong") return (float(lat) if lat else None, ...
[ "def", "get_latlon", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "lat", "=", "device_json", ".", "get", "(", "\"dpMapLat\"", ")", "lon", "=", "device_json", ".", "get", ...
Get a tuple with device latitude and longitude... these may be None
[ "Get", "a", "tuple", "with", "device", "latitude", "and", "longitude", "...", "these", "may", "be", "None" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L542-L548
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.add_to_group
def add_to_group(self, group_path): """Add a device to a group, if the group doesn't exist it is created :param group_path: Path or "name" of the group """ if self.get_group_path() != group_path: post_data = ADD_GROUP_TEMPLATE.format(connectware_id=self.get_connectware_id()...
python
def add_to_group(self, group_path): """Add a device to a group, if the group doesn't exist it is created :param group_path: Path or "name" of the group """ if self.get_group_path() != group_path: post_data = ADD_GROUP_TEMPLATE.format(connectware_id=self.get_connectware_id()...
[ "def", "add_to_group", "(", "self", ",", "group_path", ")", ":", "if", "self", ".", "get_group_path", "(", ")", "!=", "group_path", ":", "post_data", "=", "ADD_GROUP_TEMPLATE", ".", "format", "(", "connectware_id", "=", "self", ".", "get_connectware_id", "(", ...
Add a device to a group, if the group doesn't exist it is created :param group_path: Path or "name" of the group
[ "Add", "a", "device", "to", "a", "group", "if", "the", "group", "doesn", "t", "exist", "it", "is", "created" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L576-L588
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.add_tag
def add_tag(self, new_tags): """Add a tag to existing device tags. This method will not add a duplicate, if already in the list. :param new_tags: the tag(s) to be added. new_tags can be a comma-separated string or list """ tags = self.get_tags() orig_tag_cnt = len(tags) ...
python
def add_tag(self, new_tags): """Add a tag to existing device tags. This method will not add a duplicate, if already in the list. :param new_tags: the tag(s) to be added. new_tags can be a comma-separated string or list """ tags = self.get_tags() orig_tag_cnt = len(tags) ...
[ "def", "add_tag", "(", "self", ",", "new_tags", ")", ":", "tags", "=", "self", ".", "get_tags", "(", ")", "orig_tag_cnt", "=", "len", "(", "tags", ")", "# print(\"self.get_tags() {}\".format(tags))", "if", "isinstance", "(", "new_tags", ",", "six", ".", "str...
Add a tag to existing device tags. This method will not add a duplicate, if already in the list. :param new_tags: the tag(s) to be added. new_tags can be a comma-separated string or list
[ "Add", "a", "tag", "to", "existing", "device", "tags", ".", "This", "method", "will", "not", "add", "a", "duplicate", "if", "already", "in", "the", "list", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L601-L626
train
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.remove_tag
def remove_tag(self, tag): """Remove tag from existing device tags :param tag: the tag to be removed from the list :raises ValueError: If tag does not exist in list """ tags = self.get_tags() tags.remove(tag) post_data = TAGS_TEMPLATE.format(connectware_id=sel...
python
def remove_tag(self, tag): """Remove tag from existing device tags :param tag: the tag to be removed from the list :raises ValueError: If tag does not exist in list """ tags = self.get_tags() tags.remove(tag) post_data = TAGS_TEMPLATE.format(connectware_id=sel...
[ "def", "remove_tag", "(", "self", ",", "tag", ")", ":", "tags", "=", "self", ".", "get_tags", "(", ")", "tags", ".", "remove", "(", "tag", ")", "post_data", "=", "TAGS_TEMPLATE", ".", "format", "(", "connectware_id", "=", "self", ".", "get_connectware_id...
Remove tag from existing device tags :param tag: the tag to be removed from the list :raises ValueError: If tag does not exist in list
[ "Remove", "tag", "from", "existing", "device", "tags" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L630-L646
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.hostname
def hostname(self): """Get the hostname that this connection is associated with""" from six.moves.urllib.parse import urlparse return urlparse(self._base_url).netloc.split(':', 1)[0]
python
def hostname(self): """Get the hostname that this connection is associated with""" from six.moves.urllib.parse import urlparse return urlparse(self._base_url).netloc.split(':', 1)[0]
[ "def", "hostname", "(", "self", ")", ":", "from", "six", ".", "moves", ".", "urllib", ".", "parse", "import", "urlparse", "return", "urlparse", "(", "self", ".", "_base_url", ")", ".", "netloc", ".", "split", "(", "':'", ",", "1", ")", "[", "0", "]...
Get the hostname that this connection is associated with
[ "Get", "the", "hostname", "that", "this", "connection", "is", "associated", "with" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L131-L134
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.iter_json_pages
def iter_json_pages(self, path, page_size=1000, **params): """Return an iterator over JSON items from a paginated resource Legacy resources (prior to V1) implemented a common paging interfaces for several different resources. This method handles the details of iterating over the paged ...
python
def iter_json_pages(self, path, page_size=1000, **params): """Return an iterator over JSON items from a paginated resource Legacy resources (prior to V1) implemented a common paging interfaces for several different resources. This method handles the details of iterating over the paged ...
[ "def", "iter_json_pages", "(", "self", ",", "path", ",", "page_size", "=", "1000", ",", "*", "*", "params", ")", ":", "path", "=", "validate_type", "(", "path", ",", "*", "six", ".", "string_types", ")", "page_size", "=", "validate_type", "(", "page_size...
Return an iterator over JSON items from a paginated resource Legacy resources (prior to V1) implemented a common paging interfaces for several different resources. This method handles the details of iterating over the paged result set, yielding only the JSON data for each item within t...
[ "Return", "an", "iterator", "over", "JSON", "items", "from", "a", "paginated", "resource" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L181-L209
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.get
def get(self, path, **kwargs): """Perform an HTTP GET request of the specified path in Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `...
python
def get(self, path, **kwargs): """Perform an HTTP GET request of the specified path in Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `...
[ "def", "get", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"GET\"", ",", "url", ",", "*", "*", "kwargs", ")" ]
Perform an HTTP GET request of the specified path in Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-request...
[ "Perform", "an", "HTTP", "GET", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L220-L238
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.get_json
def get_json(self, path, **kwargs): """Perform an HTTP GET request with JSON headers of the specified path against Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/...
python
def get_json(self, path, **kwargs): """Perform an HTTP GET request with JSON headers of the specified path against Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/...
[ "def", "get_json", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "headers", "=", "kwargs", ".", "setdefault", "(", "'headers'", ",", "{", "}", ")", "headers", ".", "update", "("...
Perform an HTTP GET request with JSON headers of the specified path against Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <htt...
[ "Perform", "an", "HTTP", "GET", "request", "with", "JSON", "headers", "of", "the", "specified", "path", "against", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L240-L266
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.post
def post(self, path, data, **kwargs): """Perform an HTTP POST request of the specified path in Device Cloud Make an HTTP POST request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
python
def post(self, path, data, **kwargs): """Perform an HTTP POST request of the specified path in Device Cloud Make an HTTP POST request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
[ "def", "post", "(", "self", ",", "path", ",", "data", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"POST\"", ",", "url", ",", "data", "=", "data", ",", "...
Perform an HTTP POST request of the specified path in Device Cloud Make an HTTP POST request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-reque...
[ "Perform", "an", "HTTP", "POST", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L268-L288
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.put
def put(self, path, data, **kwargs): """Perform an HTTP PUT request of the specified path in Device Cloud Make an HTTP PUT request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
python
def put(self, path, data, **kwargs): """Perform an HTTP PUT request of the specified path in Device Cloud Make an HTTP PUT request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
[ "def", "put", "(", "self", ",", "path", ",", "data", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"PUT\"", ",", "url", ",", "data", "=", "data", ",", "*"...
Perform an HTTP PUT request of the specified path in Device Cloud Make an HTTP PUT request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-request...
[ "Perform", "an", "HTTP", "PUT", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L290-L311
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.delete
def delete(self, path, retries=DEFAULT_THROTTLE_RETRIES, **kwargs): """Perform an HTTP DELETE request of the specified path in Device Cloud Make an HTTP DELETE request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-r...
python
def delete(self, path, retries=DEFAULT_THROTTLE_RETRIES, **kwargs): """Perform an HTTP DELETE request of the specified path in Device Cloud Make an HTTP DELETE request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-r...
[ "def", "delete", "(", "self", ",", "path", ",", "retries", "=", "DEFAULT_THROTTLE_RETRIES", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"DELETE\"", ",", "url", ...
Perform an HTTP DELETE request of the specified path in Device Cloud Make an HTTP DELETE request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-r...
[ "Perform", "an", "HTTP", "DELETE", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L313-L331
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.streams
def streams(self): """Property providing access to the :class:`.StreamsAPI`""" if self._streams_api is None: self._streams_api = self.get_streams_api() return self._streams_api
python
def streams(self): """Property providing access to the :class:`.StreamsAPI`""" if self._streams_api is None: self._streams_api = self.get_streams_api() return self._streams_api
[ "def", "streams", "(", "self", ")", ":", "if", "self", ".", "_streams_api", "is", "None", ":", "self", ".", "_streams_api", "=", "self", ".", "get_streams_api", "(", ")", "return", "self", ".", "_streams_api" ]
Property providing access to the :class:`.StreamsAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "StreamsAPI" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L394-L398
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.filedata
def filedata(self): """Property providing access to the :class:`.FileDataAPI`""" if self._filedata_api is None: self._filedata_api = self.get_filedata_api() return self._filedata_api
python
def filedata(self): """Property providing access to the :class:`.FileDataAPI`""" if self._filedata_api is None: self._filedata_api = self.get_filedata_api() return self._filedata_api
[ "def", "filedata", "(", "self", ")", ":", "if", "self", ".", "_filedata_api", "is", "None", ":", "self", ".", "_filedata_api", "=", "self", ".", "get_filedata_api", "(", ")", "return", "self", ".", "_filedata_api" ]
Property providing access to the :class:`.FileDataAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "FileDataAPI" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L401-L405
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.devicecore
def devicecore(self): """Property providing access to the :class:`.DeviceCoreAPI`""" if self._devicecore_api is None: self._devicecore_api = self.get_devicecore_api() return self._devicecore_api
python
def devicecore(self): """Property providing access to the :class:`.DeviceCoreAPI`""" if self._devicecore_api is None: self._devicecore_api = self.get_devicecore_api() return self._devicecore_api
[ "def", "devicecore", "(", "self", ")", ":", "if", "self", ".", "_devicecore_api", "is", "None", ":", "self", ".", "_devicecore_api", "=", "self", ".", "get_devicecore_api", "(", ")", "return", "self", ".", "_devicecore_api" ]
Property providing access to the :class:`.DeviceCoreAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "DeviceCoreAPI" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L408-L412
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.sci
def sci(self): """Property providing access to the :class:`.ServerCommandInterfaceAPI`""" if self._sci_api is None: self._sci_api = self.get_sci_api() return self._sci_api
python
def sci(self): """Property providing access to the :class:`.ServerCommandInterfaceAPI`""" if self._sci_api is None: self._sci_api = self.get_sci_api() return self._sci_api
[ "def", "sci", "(", "self", ")", ":", "if", "self", ".", "_sci_api", "is", "None", ":", "self", ".", "_sci_api", "=", "self", ".", "get_sci_api", "(", ")", "return", "self", ".", "_sci_api" ]
Property providing access to the :class:`.ServerCommandInterfaceAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "ServerCommandInterfaceAPI" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L415-L419
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.file_system_service
def file_system_service(self): """Property providing access to the :class:`.FileSystemServiceAPI`""" if self._fss_api is None: self._fss_api = self.get_fss_api() return self._fss_api
python
def file_system_service(self): """Property providing access to the :class:`.FileSystemServiceAPI`""" if self._fss_api is None: self._fss_api = self.get_fss_api() return self._fss_api
[ "def", "file_system_service", "(", "self", ")", ":", "if", "self", ".", "_fss_api", "is", "None", ":", "self", ".", "_fss_api", "=", "self", ".", "get_fss_api", "(", ")", "return", "self", ".", "_fss_api" ]
Property providing access to the :class:`.FileSystemServiceAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "FileSystemServiceAPI" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L422-L426
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.monitor
def monitor(self): """Property providing access to the :class:`.MonitorAPI`""" if self._monitor_api is None: self._monitor_api = self.get_monitor_api() return self._monitor_api
python
def monitor(self): """Property providing access to the :class:`.MonitorAPI`""" if self._monitor_api is None: self._monitor_api = self.get_monitor_api() return self._monitor_api
[ "def", "monitor", "(", "self", ")", ":", "if", "self", ".", "_monitor_api", "is", "None", ":", "self", ".", "_monitor_api", "=", "self", ".", "get_monitor_api", "(", ")", "return", "self", ".", "_monitor_api" ]
Property providing access to the :class:`.MonitorAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "MonitorAPI" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L429-L433
train
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.get_devicecore_api
def get_devicecore_api(self): """Returns a :class:`.DeviceCoreAPI` bound to this device cloud instance This provides access to the same API as :attr:`.DeviceCloud.devicecore` but will create a new object (with a new cache) each time called. :return: devicecore API object bound to this ...
python
def get_devicecore_api(self): """Returns a :class:`.DeviceCoreAPI` bound to this device cloud instance This provides access to the same API as :attr:`.DeviceCloud.devicecore` but will create a new object (with a new cache) each time called. :return: devicecore API object bound to this ...
[ "def", "get_devicecore_api", "(", "self", ")", ":", "from", "devicecloud", ".", "devicecore", "import", "DeviceCoreAPI", "return", "DeviceCoreAPI", "(", "self", ".", "_conn", ",", "self", ".", "get_sci_api", "(", ")", ")" ]
Returns a :class:`.DeviceCoreAPI` bound to this device cloud instance This provides access to the same API as :attr:`.DeviceCloud.devicecore` but will create a new object (with a new cache) each time called. :return: devicecore API object bound to this device cloud account :rtype: :cla...
[ "Returns", "a", ":", "class", ":", ".", "DeviceCoreAPI", "bound", "to", "this", "device", "cloud", "instance" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L477-L489
train
digidotcom/python-devicecloud
devicecloud/sci.py
ServerCommandInterfaceAPI.get_async_job
def get_async_job(self, job_id): """Query an asynchronous SCI job by ID This is useful if the job was not created with send_sci_async(). :param int job_id: The job ID to query :returns: The SCI response from GETting the job information """ uri = "/ws/sci/{0}".format(job...
python
def get_async_job(self, job_id): """Query an asynchronous SCI job by ID This is useful if the job was not created with send_sci_async(). :param int job_id: The job ID to query :returns: The SCI response from GETting the job information """ uri = "/ws/sci/{0}".format(job...
[ "def", "get_async_job", "(", "self", ",", "job_id", ")", ":", "uri", "=", "\"/ws/sci/{0}\"", ".", "format", "(", "job_id", ")", "# TODO: do parsing here?", "return", "self", ".", "_conn", ".", "get", "(", "uri", ")" ]
Query an asynchronous SCI job by ID This is useful if the job was not created with send_sci_async(). :param int job_id: The job ID to query :returns: The SCI response from GETting the job information
[ "Query", "an", "asynchronous", "SCI", "job", "by", "ID" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L100-L110
train
digidotcom/python-devicecloud
devicecloud/sci.py
ServerCommandInterfaceAPI.send_sci_async
def send_sci_async(self, operation, target, payload, **sci_options): """Send an asynchronous SCI request, and wraps the job in an object to manage it :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_s...
python
def send_sci_async(self, operation, target, payload, **sci_options): """Send an asynchronous SCI request, and wraps the job in an object to manage it :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_s...
[ "def", "send_sci_async", "(", "self", ",", "operation", ",", "target", ",", "payload", ",", "*", "*", "sci_options", ")", ":", "sci_options", "[", "'synchronous'", "]", "=", "False", "resp", "=", "self", ".", "send_sci", "(", "operation", ",", "target", ...
Send an asynchronous SCI request, and wraps the job in an object to manage it :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_service, and reboot} :param target: The device(s) to be targeted with thi...
[ "Send", "an", "asynchronous", "SCI", "request", "and", "wraps", "the", "job", "in", "an", "object", "to", "manage", "it" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L112-L131
train
digidotcom/python-devicecloud
devicecloud/sci.py
ServerCommandInterfaceAPI.send_sci
def send_sci(self, operation, target, payload, reply=None, synchronous=None, sync_timeout=None, cache=None, allow_offline=None, wait_for_reconnect=None): """Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, q...
python
def send_sci(self, operation, target, payload, reply=None, synchronous=None, sync_timeout=None, cache=None, allow_offline=None, wait_for_reconnect=None): """Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, q...
[ "def", "send_sci", "(", "self", ",", "operation", ",", "target", ",", "payload", ",", "reply", "=", "None", ",", "synchronous", "=", "None", ",", "sync_timeout", "=", "None", ",", "cache", "=", "None", ",", "allow_offline", "=", "None", ",", "wait_for_re...
Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_service, and reboot} :param target: The device(s) to be targeted with this request :type target: :class:`~.Target...
[ "Send", "SCI", "request", "to", "1", "or", "more", "targets" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L133-L220
train
digidotcom/python-devicecloud
devicecloud/util.py
conditional_write
def conditional_write(strm, fmt, value, *args, **kwargs): """Write to stream using fmt and value if value is not None""" if value is not None: strm.write(fmt.format(value, *args, **kwargs))
python
def conditional_write(strm, fmt, value, *args, **kwargs): """Write to stream using fmt and value if value is not None""" if value is not None: strm.write(fmt.format(value, *args, **kwargs))
[ "def", "conditional_write", "(", "strm", ",", "fmt", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "value", "is", "not", "None", ":", "strm", ".", "write", "(", "fmt", ".", "format", "(", "value", ",", "*", "args", ",",...
Write to stream using fmt and value if value is not None
[ "Write", "to", "stream", "using", "fmt", "and", "value", "if", "value", "is", "not", "None" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L13-L16
train
digidotcom/python-devicecloud
devicecloud/util.py
iso8601_to_dt
def iso8601_to_dt(iso8601): """Given an ISO8601 string as returned by Device Cloud, convert to a datetime object""" # We could just use arrow.get() but that is more permissive than we actually want. # Internal (but still public) to arrow is the actual parser where we can be # a bit more specific par...
python
def iso8601_to_dt(iso8601): """Given an ISO8601 string as returned by Device Cloud, convert to a datetime object""" # We could just use arrow.get() but that is more permissive than we actually want. # Internal (but still public) to arrow is the actual parser where we can be # a bit more specific par...
[ "def", "iso8601_to_dt", "(", "iso8601", ")", ":", "# We could just use arrow.get() but that is more permissive than we actually want.", "# Internal (but still public) to arrow is the actual parser where we can be", "# a bit more specific", "parser", "=", "DateTimeParser", "(", ")", "try"...
Given an ISO8601 string as returned by Device Cloud, convert to a datetime object
[ "Given", "an", "ISO8601", "string", "as", "returned", "by", "Device", "Cloud", "convert", "to", "a", "datetime", "object" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L19-L29
train
digidotcom/python-devicecloud
devicecloud/util.py
to_none_or_dt
def to_none_or_dt(input): """Convert ``input`` to either None or a datetime object If the input is None, None will be returned. If the input is a datetime object, it will be converted to a datetime object with UTC timezone info. If the datetime object is naive, then this method will assume the obj...
python
def to_none_or_dt(input): """Convert ``input`` to either None or a datetime object If the input is None, None will be returned. If the input is a datetime object, it will be converted to a datetime object with UTC timezone info. If the datetime object is naive, then this method will assume the obj...
[ "def", "to_none_or_dt", "(", "input", ")", ":", "if", "input", "is", "None", ":", "return", "input", "elif", "isinstance", "(", "input", ",", "datetime", ".", "datetime", ")", ":", "arrow_dt", "=", "arrow", ".", "Arrow", ".", "fromdatetime", "(", "input"...
Convert ``input`` to either None or a datetime object If the input is None, None will be returned. If the input is a datetime object, it will be converted to a datetime object with UTC timezone info. If the datetime object is naive, then this method will assume the object is specified according to UTC...
[ "Convert", "input", "to", "either", "None", "or", "a", "datetime", "object" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L32-L57
train
digidotcom/python-devicecloud
devicecloud/util.py
isoformat
def isoformat(dt): """Return an ISO-8601 formatted string from the provided datetime object""" if not isinstance(dt, datetime.datetime): raise TypeError("Must provide datetime.datetime object to isoformat") if dt.tzinfo is None: raise ValueError("naive datetime objects are not allowed beyon...
python
def isoformat(dt): """Return an ISO-8601 formatted string from the provided datetime object""" if not isinstance(dt, datetime.datetime): raise TypeError("Must provide datetime.datetime object to isoformat") if dt.tzinfo is None: raise ValueError("naive datetime objects are not allowed beyon...
[ "def", "isoformat", "(", "dt", ")", ":", "if", "not", "isinstance", "(", "dt", ",", "datetime", ".", "datetime", ")", ":", "raise", "TypeError", "(", "\"Must provide datetime.datetime object to isoformat\"", ")", "if", "dt", ".", "tzinfo", "is", "None", ":", ...
Return an ISO-8601 formatted string from the provided datetime object
[ "Return", "an", "ISO", "-", "8601", "formatted", "string", "from", "the", "provided", "datetime", "object" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L72-L80
train
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.get_filedata
def get_filedata(self, condition=None, page_size=1000): """Return a generator over all results matching the provided condition :param condition: An :class:`.Expression` which defines the condition which must be matched on the filedata that will be retrieved from file data store....
python
def get_filedata(self, condition=None, page_size=1000): """Return a generator over all results matching the provided condition :param condition: An :class:`.Expression` which defines the condition which must be matched on the filedata that will be retrieved from file data store....
[ "def", "get_filedata", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "condition", "=", "validate_type", "(", "condition", ",", "type", "(", "None", ")", ",", "Expression", ",", "*", "six", ".", "string_types", ")", ...
Return a generator over all results matching the provided condition :param condition: An :class:`.Expression` which defines the condition which must be matched on the filedata that will be retrieved from file data store. If a condition is unspecified, the following condition ...
[ "Return", "a", "generator", "over", "all", "results", "matching", "the", "provided", "condition" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L30-L54
train
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.write_file
def write_file(self, path, name, data, content_type=None, archive=False, raw=False): """Write a file to the file data store at the given path :param str path: The path (directory) into which the file should be written. :param str name: The name of the file to be written. ...
python
def write_file(self, path, name, data, content_type=None, archive=False, raw=False): """Write a file to the file data store at the given path :param str path: The path (directory) into which the file should be written. :param str name: The name of the file to be written. ...
[ "def", "write_file", "(", "self", ",", "path", ",", "name", ",", "data", ",", "content_type", "=", "None", ",", "archive", "=", "False", ",", "raw", "=", "False", ")", ":", "path", "=", "validate_type", "(", "path", ",", "*", "six", ".", "string_type...
Write a file to the file data store at the given path :param str path: The path (directory) into which the file should be written. :param str name: The name of the file to be written. :param data: The binary data that should be written into the file. :type data: str (Python2) or bytes (...
[ "Write", "a", "file", "to", "the", "file", "data", "store", "at", "the", "given", "path" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L56-L108
train
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.delete_file
def delete_file(self, path): """Delete a file or directory from the filedata store This method removes a file or directory (recursively) from the filedata store. :param path: The path of the file or directory to remove from the file data store. """ path = v...
python
def delete_file(self, path): """Delete a file or directory from the filedata store This method removes a file or directory (recursively) from the filedata store. :param path: The path of the file or directory to remove from the file data store. """ path = v...
[ "def", "delete_file", "(", "self", ",", "path", ")", ":", "path", "=", "validate_type", "(", "path", ",", "*", "six", ".", "string_types", ")", "if", "not", "path", ".", "startswith", "(", "\"/\"", ")", ":", "path", "=", "\"/\"", "+", "path", "self",...
Delete a file or directory from the filedata store This method removes a file or directory (recursively) from the filedata store. :param path: The path of the file or directory to remove from the file data store.
[ "Delete", "a", "file", "or", "directory", "from", "the", "filedata", "store" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L110-L124
train
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.walk
def walk(self, root="~/"): """Emulation of os.walk behavior against Device Cloud filedata store This method will yield tuples in the form ``(dirpath, FileDataDirectory's, FileData's)`` recursively in pre-order (depth first from top down). :param str root: The root path from which the s...
python
def walk(self, root="~/"): """Emulation of os.walk behavior against Device Cloud filedata store This method will yield tuples in the form ``(dirpath, FileDataDirectory's, FileData's)`` recursively in pre-order (depth first from top down). :param str root: The root path from which the s...
[ "def", "walk", "(", "self", ",", "root", "=", "\"~/\"", ")", ":", "root", "=", "validate_type", "(", "root", ",", "*", "six", ".", "string_types", ")", "directories", "=", "[", "]", "files", "=", "[", "]", "# fd_path is real picky", "query_fd_path", "=",...
Emulation of os.walk behavior against Device Cloud filedata store This method will yield tuples in the form ``(dirpath, FileDataDirectory's, FileData's)`` recursively in pre-order (depth first from top down). :param str root: The root path from which the search should commence. By default, th...
[ "Emulation", "of", "os", ".", "walk", "behavior", "against", "Device", "Cloud", "filedata", "store" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L126-L160
train
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataObject.get_data
def get_data(self): """Get the data associated with this filedata object :returns: Data associated with this object or None if none exists :rtype: str (Python2)/bytes (Python3) or None """ # NOTE: we assume that the "embed" option is used base64_data = self._json_data.g...
python
def get_data(self): """Get the data associated with this filedata object :returns: Data associated with this object or None if none exists :rtype: str (Python2)/bytes (Python3) or None """ # NOTE: we assume that the "embed" option is used base64_data = self._json_data.g...
[ "def", "get_data", "(", "self", ")", ":", "# NOTE: we assume that the \"embed\" option is used", "base64_data", "=", "self", ".", "_json_data", ".", "get", "(", "\"fdData\"", ")", "if", "base64_data", "is", "None", ":", "return", "None", "else", ":", "# need to co...
Get the data associated with this filedata object :returns: Data associated with this object or None if none exists :rtype: str (Python2)/bytes (Python3) or None
[ "Get", "the", "data", "associated", "with", "this", "filedata", "object" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L182-L195
train
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataDirectory.write_file
def write_file(self, *args, **kwargs): """Write a file into this directory This method takes the same arguments as :meth:`.FileDataAPI.write_file` with the exception of the ``path`` argument which is not needed here. """ return self._fdapi.write_file(self.get_path(), *args, **k...
python
def write_file(self, *args, **kwargs): """Write a file into this directory This method takes the same arguments as :meth:`.FileDataAPI.write_file` with the exception of the ``path`` argument which is not needed here. """ return self._fdapi.write_file(self.get_path(), *args, **k...
[ "def", "write_file", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_fdapi", ".", "write_file", "(", "self", ".", "get_path", "(", ")", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Write a file into this directory This method takes the same arguments as :meth:`.FileDataAPI.write_file` with the exception of the ``path`` argument which is not needed here.
[ "Write", "a", "file", "into", "this", "directory" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L259-L266
train
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.create_tcp_monitor
def create_tcp_monitor(self, topics, batch_size=1, batch_duration=0, compression='gzip', format_type='json'): """Creates a TCP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDat...
python
def create_tcp_monitor(self, topics, batch_size=1, batch_duration=0, compression='gzip', format_type='json'): """Creates a TCP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDat...
[ "def", "create_tcp_monitor", "(", "self", ",", "topics", ",", "batch_size", "=", "1", ",", "batch_duration", "=", "0", ",", "compression", "=", "'gzip'", ",", "format_type", "=", "'json'", ")", ":", "monitor_xml", "=", "\"\"\"\\\n <Monitor>\n <mo...
Creates a TCP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDataCore']). :param batch_size: How many Msgs received before sending data. :param batch_duration: How long to wait before sending batc...
[ "Creates", "a", "TCP", "Monitor", "instance", "in", "Device", "Cloud", "for", "a", "given", "list", "of", "topics" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L176-L211
train
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.create_http_monitor
def create_http_monitor(self, topics, transport_url, transport_token=None, transport_method='PUT', connect_timeout=0, response_timeout=0, batch_size=1, batch_duration=0, compression='none', format_type='json'): """Creates a HTTP Monitor instance in Device Cloud for a given list of to...
python
def create_http_monitor(self, topics, transport_url, transport_token=None, transport_method='PUT', connect_timeout=0, response_timeout=0, batch_size=1, batch_duration=0, compression='none', format_type='json'): """Creates a HTTP Monitor instance in Device Cloud for a given list of to...
[ "def", "create_http_monitor", "(", "self", ",", "topics", ",", "transport_url", ",", "transport_token", "=", "None", ",", "transport_method", "=", "'PUT'", ",", "connect_timeout", "=", "0", ",", "response_timeout", "=", "0", ",", "batch_size", "=", "1", ",", ...
Creates a HTTP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDataCore']). :param transport_url: URL of the customer web server. :param transport_token: Credentials for basic authentication in the...
[ "Creates", "a", "HTTP", "Monitor", "instance", "in", "Device", "Cloud", "for", "a", "given", "list", "of", "topics" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L213-L263
train
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.get_monitors
def get_monitors(self, condition=None, page_size=1000): """Return an iterator over all monitors matching the provided condition Get all inactive monitors and print id:: for mon in dc.monitor.get_monitors(MON_STATUS_ATTR == "DISABLED"): print(mon.get_id()) Get all t...
python
def get_monitors(self, condition=None, page_size=1000): """Return an iterator over all monitors matching the provided condition Get all inactive monitors and print id:: for mon in dc.monitor.get_monitors(MON_STATUS_ATTR == "DISABLED"): print(mon.get_id()) Get all t...
[ "def", "get_monitors", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "req_kwargs", "=", "{", "}", "if", "condition", ":", "req_kwargs", "[", "'condition'", "]", "=", "condition", ".", "compile", "(", ")", "for", "...
Return an iterator over all monitors matching the provided condition Get all inactive monitors and print id:: for mon in dc.monitor.get_monitors(MON_STATUS_ATTR == "DISABLED"): print(mon.get_id()) Get all the HTTP monitors and print id:: for mon in dc.monitor....
[ "Return", "an", "iterator", "over", "all", "monitors", "matching", "the", "provided", "condition" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L265-L294
train
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.get_monitor
def get_monitor(self, topics): """Attempts to find a Monitor in device cloud that matches the provided topics :param topics: a string list of topics (e.g. ``['DeviceCore[U]', 'FileDataCore'])``) Returns a :class:`DeviceCloudMonitor` if found, otherwise None. """ for monitor in ...
python
def get_monitor(self, topics): """Attempts to find a Monitor in device cloud that matches the provided topics :param topics: a string list of topics (e.g. ``['DeviceCore[U]', 'FileDataCore'])``) Returns a :class:`DeviceCloudMonitor` if found, otherwise None. """ for monitor in ...
[ "def", "get_monitor", "(", "self", ",", "topics", ")", ":", "for", "monitor", "in", "self", ".", "get_monitors", "(", "MON_TOPIC_ATTR", "==", "\",\"", ".", "join", "(", "topics", ")", ")", ":", "return", "monitor", "# return the first one, even if there are mult...
Attempts to find a Monitor in device cloud that matches the provided topics :param topics: a string list of topics (e.g. ``['DeviceCore[U]', 'FileDataCore'])``) Returns a :class:`DeviceCloudMonitor` if found, otherwise None.
[ "Attempts", "to", "find", "a", "Monitor", "in", "device", "cloud", "that", "matches", "the", "provided", "topics" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L296-L305
train
digidotcom/python-devicecloud
devicecloud/streams.py
_get_encoder_method
def _get_encoder_method(stream_type): """A function to get the python type to device cloud type converter function. :param stream_type: The streams data type :return: A function that when called with the python object will return the serializable type for sending to the cloud. If there is no function f...
python
def _get_encoder_method(stream_type): """A function to get the python type to device cloud type converter function. :param stream_type: The streams data type :return: A function that when called with the python object will return the serializable type for sending to the cloud. If there is no function f...
[ "def", "_get_encoder_method", "(", "stream_type", ")", ":", "if", "stream_type", "is", "not", "None", ":", "return", "DSTREAM_TYPE_MAP", ".", "get", "(", "stream_type", ".", "upper", "(", ")", ",", "(", "lambda", "x", ":", "x", ",", "lambda", "x", ":", ...
A function to get the python type to device cloud type converter function. :param stream_type: The streams data type :return: A function that when called with the python object will return the serializable type for sending to the cloud. If there is no function for the given type, or the `stream_type` i...
[ "A", "function", "to", "get", "the", "python", "type", "to", "device", "cloud", "type", "converter", "function", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L66-L77
train
digidotcom/python-devicecloud
devicecloud/streams.py
_get_decoder_method
def _get_decoder_method(stream_type): """ A function to get Device Cloud type to python type converter function. :param stream_type: The streams data type :return: A function that when called with Device Cloud object will return the python native type. If there is no function for the given type, or the...
python
def _get_decoder_method(stream_type): """ A function to get Device Cloud type to python type converter function. :param stream_type: The streams data type :return: A function that when called with Device Cloud object will return the python native type. If there is no function for the given type, or the...
[ "def", "_get_decoder_method", "(", "stream_type", ")", ":", "if", "stream_type", "is", "not", "None", ":", "return", "DSTREAM_TYPE_MAP", ".", "get", "(", "stream_type", ".", "upper", "(", ")", ",", "(", "lambda", "x", ":", "x", ",", "lambda", "x", ":", ...
A function to get Device Cloud type to python type converter function. :param stream_type: The streams data type :return: A function that when called with Device Cloud object will return the python native type. If there is no function for the given type, or the `stream_type` is `None` the returned func...
[ "A", "function", "to", "get", "Device", "Cloud", "type", "to", "python", "type", "converter", "function", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L80-L91
train
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI._get_streams
def _get_streams(self, uri_suffix=None): """Clear and update internal cache of stream objects""" # TODO: handle paging, perhaps change this to be a generator if uri_suffix is not None and not uri_suffix.startswith('/'): uri_suffix = '/' + uri_suffix elif uri_suffix is None: ...
python
def _get_streams(self, uri_suffix=None): """Clear and update internal cache of stream objects""" # TODO: handle paging, perhaps change this to be a generator if uri_suffix is not None and not uri_suffix.startswith('/'): uri_suffix = '/' + uri_suffix elif uri_suffix is None: ...
[ "def", "_get_streams", "(", "self", ",", "uri_suffix", "=", "None", ")", ":", "# TODO: handle paging, perhaps change this to be a generator", "if", "uri_suffix", "is", "not", "None", "and", "not", "uri_suffix", ".", "startswith", "(", "'/'", ")", ":", "uri_suffix", ...
Clear and update internal cache of stream objects
[ "Clear", "and", "update", "internal", "cache", "of", "stream", "objects" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L116-L129
train
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI.create_stream
def create_stream(self, stream_id, data_type, description=None, data_ttl=None, rollup_ttl=None, units=None): """Create a new data stream on Device Cloud This method will attempt to create a new data stream on Device Cloud. This method will only succeed if the stream does n...
python
def create_stream(self, stream_id, data_type, description=None, data_ttl=None, rollup_ttl=None, units=None): """Create a new data stream on Device Cloud This method will attempt to create a new data stream on Device Cloud. This method will only succeed if the stream does n...
[ "def", "create_stream", "(", "self", ",", "stream_id", ",", "data_type", ",", "description", "=", "None", ",", "data_ttl", "=", "None", ",", "rollup_ttl", "=", "None", ",", "units", "=", "None", ")", ":", "stream_id", "=", "validate_type", "(", "stream_id"...
Create a new data stream on Device Cloud This method will attempt to create a new data stream on Device Cloud. This method will only succeed if the stream does not already exist. :param str stream_id: The path/id of the stream being created on Device Cloud. :param str data_type: The ty...
[ "Create", "a", "new", "data", "stream", "on", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L131-L173
train
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI.get_stream_if_exists
def get_stream_if_exists(self, stream_id): """Return a reference to a stream with the given ``stream_id`` if it exists This works similar to :py:meth:`get_stream` but will return None if the stream is not already created. :param stream_id: The path of the stream on Device Cloud ...
python
def get_stream_if_exists(self, stream_id): """Return a reference to a stream with the given ``stream_id`` if it exists This works similar to :py:meth:`get_stream` but will return None if the stream is not already created. :param stream_id: The path of the stream on Device Cloud ...
[ "def", "get_stream_if_exists", "(", "self", ",", "stream_id", ")", ":", "stream", "=", "self", ".", "get_stream", "(", "stream_id", ")", "try", ":", "stream", ".", "get_data_type", "(", "use_cached", "=", "True", ")", "except", "NoSuchStreamException", ":", ...
Return a reference to a stream with the given ``stream_id`` if it exists This works similar to :py:meth:`get_stream` but will return None if the stream is not already created. :param stream_id: The path of the stream on Device Cloud :raises TypeError: if the stream_id provided is the w...
[ "Return", "a", "reference", "to", "a", "stream", "with", "the", "given", "stream_id", "if", "it", "exists" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L203-L222
train
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI.bulk_write_datapoints
def bulk_write_datapoints(self, datapoints): """Perform a bulk write (or set of writes) of a collection of data points This method takes a list (or other iterable) of datapoints and writes them to Device Cloud in an efficient manner, minimizing the number of HTTP requests that need to b...
python
def bulk_write_datapoints(self, datapoints): """Perform a bulk write (or set of writes) of a collection of data points This method takes a list (or other iterable) of datapoints and writes them to Device Cloud in an efficient manner, minimizing the number of HTTP requests that need to b...
[ "def", "bulk_write_datapoints", "(", "self", ",", "datapoints", ")", ":", "datapoints", "=", "list", "(", "datapoints", ")", "# effectively performs validation that we have the right type", "for", "dp", "in", "datapoints", ":", "if", "not", "isinstance", "(", "dp", ...
Perform a bulk write (or set of writes) of a collection of data points This method takes a list (or other iterable) of datapoints and writes them to Device Cloud in an efficient manner, minimizing the number of HTTP requests that need to be made. As this call is performed from outside ...
[ "Perform", "a", "bulk", "write", "(", "or", "set", "of", "writes", ")", "of", "a", "collection", "of", "data", "points" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L224-L283
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.from_json
def from_json(cls, stream, json_data): """Create a new DataPoint object from device cloud JSON data :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: i...
python
def from_json(cls, stream, json_data): """Create a new DataPoint object from device cloud JSON data :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: i...
[ "def", "from_json", "(", "cls", ",", "stream", ",", "json_data", ")", ":", "type_converter", "=", "_get_decoder_method", "(", "stream", ".", "get_data_type", "(", ")", ")", "data", "=", "type_converter", "(", "json_data", ".", "get", "(", "\"data\"", ")", ...
Create a new DataPoint object from device cloud JSON data :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: if the data is malformed :return: (:class:`...
[ "Create", "a", "new", "DataPoint", "object", "from", "device", "cloud", "JSON", "data" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L296-L321
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.from_rollup_json
def from_rollup_json(cls, stream, json_data): """Rollup json data from the server looks slightly different :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueE...
python
def from_rollup_json(cls, stream, json_data): """Rollup json data from the server looks slightly different :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueE...
[ "def", "from_rollup_json", "(", "cls", ",", "stream", ",", "json_data", ")", ":", "dp", "=", "cls", ".", "from_json", "(", "stream", ",", "json_data", ")", "# Special handling for timestamp", "timestamp", "=", "isoformat", "(", "dc_utc_timestamp_to_dt", "(", "in...
Rollup json data from the server looks slightly different :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: if the data is malformed :return: (:class:`...
[ "Rollup", "json", "data", "from", "the", "server", "looks", "slightly", "different" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L324-L344
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_stream_id
def set_stream_id(self, stream_id): """Set the stream id associated with this data point""" stream_id = validate_type(stream_id, type(None), *six.string_types) if stream_id is not None: stream_id = stream_id.lstrip('/') self._stream_id = stream_id
python
def set_stream_id(self, stream_id): """Set the stream id associated with this data point""" stream_id = validate_type(stream_id, type(None), *six.string_types) if stream_id is not None: stream_id = stream_id.lstrip('/') self._stream_id = stream_id
[ "def", "set_stream_id", "(", "self", ",", "stream_id", ")", ":", "stream_id", "=", "validate_type", "(", "stream_id", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")", "if", "stream_id", "is", "not", "None", ":", "stream_id", "=",...
Set the stream id associated with this data point
[ "Set", "the", "stream", "id", "associated", "with", "this", "data", "point" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L429-L434
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_description
def set_description(self, description): """Set the description for this data point""" self._description = validate_type(description, type(None), *six.string_types)
python
def set_description(self, description): """Set the description for this data point""" self._description = validate_type(description, type(None), *six.string_types)
[ "def", "set_description", "(", "self", ",", "description", ")", ":", "self", ".", "_description", "=", "validate_type", "(", "description", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")" ]
Set the description for this data point
[ "Set", "the", "description", "for", "this", "data", "point" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L440-L442
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_quality
def set_quality(self, quality): """Set the quality for this sample Quality is stored on Device Cloud as a 32-bit integer, so the input to this function should be either None, an integer, or a string that can be converted to an integer. """ if isinstance(quality, *six.st...
python
def set_quality(self, quality): """Set the quality for this sample Quality is stored on Device Cloud as a 32-bit integer, so the input to this function should be either None, an integer, or a string that can be converted to an integer. """ if isinstance(quality, *six.st...
[ "def", "set_quality", "(", "self", ",", "quality", ")", ":", "if", "isinstance", "(", "quality", ",", "*", "six", ".", "string_types", ")", ":", "quality", "=", "int", "(", "quality", ")", "elif", "isinstance", "(", "quality", ",", "float", ")", ":", ...
Set the quality for this sample Quality is stored on Device Cloud as a 32-bit integer, so the input to this function should be either None, an integer, or a string that can be converted to an integer.
[ "Set", "the", "quality", "for", "this", "sample" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L475-L488
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_location
def set_location(self, location): """Set the location for this data point The location must be either None (if no location data is known) or a 3-tuple of floating point values in the form (latitude-degrees, longitude-degrees, altitude-meters). """ if location is None: ...
python
def set_location(self, location): """Set the location for this data point The location must be either None (if no location data is known) or a 3-tuple of floating point values in the form (latitude-degrees, longitude-degrees, altitude-meters). """ if location is None: ...
[ "def", "set_location", "(", "self", ",", "location", ")", ":", "if", "location", "is", "None", ":", "self", ".", "_location", "=", "location", "elif", "isinstance", "(", "location", ",", "*", "six", ".", "string_types", ")", ":", "# from device cloud, conver...
Set the location for this data point The location must be either None (if no location data is known) or a 3-tuple of floating point values in the form (latitude-degrees, longitude-degrees, altitude-meters).
[ "Set", "the", "location", "for", "this", "data", "point" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L499-L526
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_data_type
def set_data_type(self, data_type): """Set the data type for ths data point The data type is actually associated with the stream itself and should not (generally) vary on a point-per-point basis. That being said, if creating a new stream by writing a datapoint, it may be beneficial to ...
python
def set_data_type(self, data_type): """Set the data type for ths data point The data type is actually associated with the stream itself and should not (generally) vary on a point-per-point basis. That being said, if creating a new stream by writing a datapoint, it may be beneficial to ...
[ "def", "set_data_type", "(", "self", ",", "data_type", ")", ":", "validate_type", "(", "data_type", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")", "if", "isinstance", "(", "data_type", ",", "*", "six", ".", "string_types", ")",...
Set the data type for ths data point The data type is actually associated with the stream itself and should not (generally) vary on a point-per-point basis. That being said, if creating a new stream by writing a datapoint, it may be beneficial to include this information. The ...
[ "Set", "the", "data", "type", "for", "ths", "data", "point" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L539-L556
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_units
def set_units(self, unit): """Set the unit for this data point Unit, as with data_type, are actually associated with the stream and not the individual data point. As such, changing this within a stream is not encouraged. Setting the unit on the data point is useful when the st...
python
def set_units(self, unit): """Set the unit for this data point Unit, as with data_type, are actually associated with the stream and not the individual data point. As such, changing this within a stream is not encouraged. Setting the unit on the data point is useful when the st...
[ "def", "set_units", "(", "self", ",", "unit", ")", ":", "self", ".", "_units", "=", "validate_type", "(", "unit", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")" ]
Set the unit for this data point Unit, as with data_type, are actually associated with the stream and not the individual data point. As such, changing this within a stream is not encouraged. Setting the unit on the data point is useful when the stream might be created with the write o...
[ "Set", "the", "unit", "for", "this", "data", "point" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L562-L571
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.to_xml
def to_xml(self): """Convert this datapoint into a form suitable for pushing to device cloud An XML string will be returned that will contain all pieces of information set on this datapoint. Values not set (e.g. quality) will be ommitted. """ type_converter = _get_encoder_meth...
python
def to_xml(self): """Convert this datapoint into a form suitable for pushing to device cloud An XML string will be returned that will contain all pieces of information set on this datapoint. Values not set (e.g. quality) will be ommitted. """ type_converter = _get_encoder_meth...
[ "def", "to_xml", "(", "self", ")", ":", "type_converter", "=", "_get_encoder_method", "(", "self", ".", "_data_type", ")", "# Convert from python native to device cloud", "encoded_data", "=", "type_converter", "(", "self", ".", "_data", ")", "out", "=", "StringIO", ...
Convert this datapoint into a form suitable for pushing to device cloud An XML string will be returned that will contain all pieces of information set on this datapoint. Values not set (e.g. quality) will be ommitted.
[ "Convert", "this", "datapoint", "into", "a", "form", "suitable", "for", "pushing", "to", "device", "cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L573-L597
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream._get_stream_metadata
def _get_stream_metadata(self, use_cached): """Retrieve metadata about this stream from Device Cloud""" if self._cached_data is None or not use_cached: try: self._cached_data = self._conn.get_json("/ws/DataStream/%s" % self._stream_id)["items"][0] except DeviceClo...
python
def _get_stream_metadata(self, use_cached): """Retrieve metadata about this stream from Device Cloud""" if self._cached_data is None or not use_cached: try: self._cached_data = self._conn.get_json("/ws/DataStream/%s" % self._stream_id)["items"][0] except DeviceClo...
[ "def", "_get_stream_metadata", "(", "self", ",", "use_cached", ")", ":", "if", "self", ".", "_cached_data", "is", "None", "or", "not", "use_cached", ":", "try", ":", "self", ".", "_cached_data", "=", "self", ".", "_conn", ".", "get_json", "(", "\"/ws/DataS...
Retrieve metadata about this stream from Device Cloud
[ "Retrieve", "metadata", "about", "this", "stream", "from", "Device", "Cloud" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L640-L649
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_data_type
def get_data_type(self, use_cached=True): """Get the data type of this stream if it exists The data type is the type of data stored in this data stream. Valid types include: * INTEGER - data can be represented with a network (= big-endian) 32-bit two's-complement integer. Data with ...
python
def get_data_type(self, use_cached=True): """Get the data type of this stream if it exists The data type is the type of data stored in this data stream. Valid types include: * INTEGER - data can be represented with a network (= big-endian) 32-bit two's-complement integer. Data with ...
[ "def", "get_data_type", "(", "self", ",", "use_cached", "=", "True", ")", ":", "dtype", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"dataType\"", ")", "if", "dtype", "is", "not", "None", ":", "dtype", "=", "dtype"...
Get the data type of this stream if it exists The data type is the type of data stored in this data stream. Valid types include: * INTEGER - data can be represented with a network (= big-endian) 32-bit two's-complement integer. Data with this type maps to a python int. * LONG - data...
[ "Get", "the", "data", "type", "of", "this", "stream", "if", "it", "exists" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L660-L686
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_data_ttl
def get_data_ttl(self, use_cached=True): """Retrieve the dataTTL for this stream The dataTtl is the time to live (TTL) in seconds for data points stored in the data stream. A data point expires after the configured amount of time and is automatically deleted. :param bool use_cached: If...
python
def get_data_ttl(self, use_cached=True): """Retrieve the dataTTL for this stream The dataTtl is the time to live (TTL) in seconds for data points stored in the data stream. A data point expires after the configured amount of time and is automatically deleted. :param bool use_cached: If...
[ "def", "get_data_ttl", "(", "self", ",", "use_cached", "=", "True", ")", ":", "data_ttl_text", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"dataTtl\"", ")", "return", "int", "(", "data_ttl_text", ")" ]
Retrieve the dataTTL for this stream The dataTtl is the time to live (TTL) in seconds for data points stored in the data stream. A data point expires after the configured amount of time and is automatically deleted. :param bool use_cached: If False, the function will always request the latest ...
[ "Retrieve", "the", "dataTTL", "for", "this", "stream" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L714-L730
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_rollup_ttl
def get_rollup_ttl(self, use_cached=True): """Retrieve the rollupTtl for this stream The rollupTtl is the time to live (TTL) in seconds for the aggregate roll-ups of data points stored in the stream. A roll-up expires after the configured amount of time and is automatically deleted. ...
python
def get_rollup_ttl(self, use_cached=True): """Retrieve the rollupTtl for this stream The rollupTtl is the time to live (TTL) in seconds for the aggregate roll-ups of data points stored in the stream. A roll-up expires after the configured amount of time and is automatically deleted. ...
[ "def", "get_rollup_ttl", "(", "self", ",", "use_cached", "=", "True", ")", ":", "rollup_ttl_text", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"rollupTtl\"", ")", "return", "int", "(", "rollup_ttl_text", ")" ]
Retrieve the rollupTtl for this stream The rollupTtl is the time to live (TTL) in seconds for the aggregate roll-ups of data points stored in the stream. A roll-up expires after the configured amount of time and is automatically deleted. :param bool use_cached: If False, the function w...
[ "Retrieve", "the", "rollupTtl", "for", "this", "stream" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L732-L748
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.get_current_value
def get_current_value(self, use_cached=False): """Return the most recent DataPoint value written to a stream The current value is the last recorded data point for this stream. :param bool use_cached: If False, the function will always request the latest from Device Cloud. If True, ...
python
def get_current_value(self, use_cached=False): """Return the most recent DataPoint value written to a stream The current value is the last recorded data point for this stream. :param bool use_cached: If False, the function will always request the latest from Device Cloud. If True, ...
[ "def", "get_current_value", "(", "self", ",", "use_cached", "=", "False", ")", ":", "current_value", "=", "self", ".", "_get_stream_metadata", "(", "use_cached", ")", ".", "get", "(", "\"currentValue\"", ")", "if", "current_value", ":", "return", "DataPoint", ...
Return the most recent DataPoint value written to a stream The current value is the last recorded data point for this stream. :param bool use_cached: If False, the function will always request the latest from Device Cloud. If True, the device will not make a request if it already has cache...
[ "Return", "the", "most", "recent", "DataPoint", "value", "written", "to", "a", "stream" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L750-L767
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.delete
def delete(self): """Delete this stream from Device Cloud along with its history This call will return None on success and raise an exception in the event of an error performing the deletion. :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error ...
python
def delete(self): """Delete this stream from Device Cloud along with its history This call will return None on success and raise an exception in the event of an error performing the deletion. :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error ...
[ "def", "delete", "(", "self", ")", ":", "try", ":", "self", ".", "_conn", ".", "delete", "(", "\"/ws/DataStream/{}\"", ".", "format", "(", "self", ".", "get_stream_id", "(", ")", ")", ")", "except", "DeviceCloudHttpException", "as", "http_excpeption", ":", ...
Delete this stream from Device Cloud along with its history This call will return None on success and raise an exception in the event of an error performing the deletion. :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error :raises devicecloud.streams.N...
[ "Delete", "this", "stream", "from", "Device", "Cloud", "along", "with", "its", "history" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L769-L785
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.delete_datapoint
def delete_datapoint(self, datapoint): """Delete the provided datapoint from this stream :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error """ datapoint = validate_type(datapoint, DataPoint) self._conn.delete("/ws/DataPoint/{stream_id}/{datap...
python
def delete_datapoint(self, datapoint): """Delete the provided datapoint from this stream :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error """ datapoint = validate_type(datapoint, DataPoint) self._conn.delete("/ws/DataPoint/{stream_id}/{datap...
[ "def", "delete_datapoint", "(", "self", ",", "datapoint", ")", ":", "datapoint", "=", "validate_type", "(", "datapoint", ",", "DataPoint", ")", "self", ".", "_conn", ".", "delete", "(", "\"/ws/DataPoint/{stream_id}/{datapoint_id}\"", ".", "format", "(", "stream_id...
Delete the provided datapoint from this stream :raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error
[ "Delete", "the", "provided", "datapoint", "from", "this", "stream" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L787-L797
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.delete_datapoints_in_time_range
def delete_datapoints_in_time_range(self, start_dt=None, end_dt=None): """Delete datapoints from this stream between the provided start and end times If neither a start or end time is specified, all data points in the stream will be deleted. :param start_dt: The datetime after which da...
python
def delete_datapoints_in_time_range(self, start_dt=None, end_dt=None): """Delete datapoints from this stream between the provided start and end times If neither a start or end time is specified, all data points in the stream will be deleted. :param start_dt: The datetime after which da...
[ "def", "delete_datapoints_in_time_range", "(", "self", ",", "start_dt", "=", "None", ",", "end_dt", "=", "None", ")", ":", "start_dt", "=", "to_none_or_dt", "(", "validate_type", "(", "start_dt", ",", "datetime", ".", "datetime", ",", "type", "(", "None", ")...
Delete datapoints from this stream between the provided start and end times If neither a start or end time is specified, all data points in the stream will be deleted. :param start_dt: The datetime after which data points should be deleted or None if all data points from the beginn...
[ "Delete", "datapoints", "from", "this", "stream", "between", "the", "provided", "start", "and", "end", "times" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L799-L824
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.write
def write(self, datapoint): """Write some raw data to a stream using the DataPoint API This method will mutate the datapoint provided to populate it with information available from the stream as it is available (but without making any new HTTP requests). For instance, we will add in in...
python
def write(self, datapoint): """Write some raw data to a stream using the DataPoint API This method will mutate the datapoint provided to populate it with information available from the stream as it is available (but without making any new HTTP requests). For instance, we will add in in...
[ "def", "write", "(", "self", ",", "datapoint", ")", ":", "if", "not", "isinstance", "(", "datapoint", ",", "DataPoint", ")", ":", "raise", "TypeError", "(", "\"First argument must be a DataPoint object\"", ")", "datapoint", ".", "_stream_id", "=", "self", ".", ...
Write some raw data to a stream using the DataPoint API This method will mutate the datapoint provided to populate it with information available from the stream as it is available (but without making any new HTTP requests). For instance, we will add in information about the stream data ...
[ "Write", "some", "raw", "data", "to", "a", "stream", "using", "the", "DataPoint", "API" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L865-L885
train
digidotcom/python-devicecloud
devicecloud/streams.py
DataStream.read
def read(self, start_time=None, end_time=None, use_client_timeline=True, newest_first=True, rollup_interval=None, rollup_method=None, timezone=None, page_size=1000): """Read one or more DataPoints from a stream .. warning:: The data points from Device Cloud is a paged data set. ...
python
def read(self, start_time=None, end_time=None, use_client_timeline=True, newest_first=True, rollup_interval=None, rollup_method=None, timezone=None, page_size=1000): """Read one or more DataPoints from a stream .. warning:: The data points from Device Cloud is a paged data set. ...
[ "def", "read", "(", "self", ",", "start_time", "=", "None", ",", "end_time", "=", "None", ",", "use_client_timeline", "=", "True", ",", "newest_first", "=", "True", ",", "rollup_interval", "=", "None", ",", "rollup_method", "=", "None", ",", "timezone", "=...
Read one or more DataPoints from a stream .. warning:: The data points from Device Cloud is a paged data set. When iterating over the result set there could be delays when we hit the end of a page. If this is undesirable, the caller should collect all results into a data stru...
[ "Read", "one", "or", "more", "DataPoints", "from", "a", "stream" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L887-L1017
train
digidotcom/python-devicecloud
devicecloud/conditions.py
_quoted
def _quoted(value): """Return a single-quoted and escaped (percent-encoded) version of value This function will also perform transforms of known data types to a representation that will be handled by Device Cloud. For instance, datetime objects will be converted to ISO8601. """ if isinstance(...
python
def _quoted(value): """Return a single-quoted and escaped (percent-encoded) version of value This function will also perform transforms of known data types to a representation that will be handled by Device Cloud. For instance, datetime objects will be converted to ISO8601. """ if isinstance(...
[ "def", "_quoted", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "datetime", ".", "datetime", ")", ":", "value", "=", "isoformat", "(", "to_none_or_dt", "(", "value", ")", ")", "else", ":", "value", "=", "str", "(", "value", ")", "ret...
Return a single-quoted and escaped (percent-encoded) version of value This function will also perform transforms of known data types to a representation that will be handled by Device Cloud. For instance, datetime objects will be converted to ISO8601.
[ "Return", "a", "single", "-", "quoted", "and", "escaped", "(", "percent", "-", "encoded", ")", "version", "of", "value" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L19-L32
train
digidotcom/python-devicecloud
devicecloud/conditions.py
Combination.compile
def compile(self): """Compile this expression into a query string""" return "{lhs}{sep}{rhs}".format( lhs=self.lhs.compile(), sep=self.sep, rhs=self.rhs.compile(), )
python
def compile(self): """Compile this expression into a query string""" return "{lhs}{sep}{rhs}".format( lhs=self.lhs.compile(), sep=self.sep, rhs=self.rhs.compile(), )
[ "def", "compile", "(", "self", ")", ":", "return", "\"{lhs}{sep}{rhs}\"", ".", "format", "(", "lhs", "=", "self", ".", "lhs", ".", "compile", "(", ")", ",", "sep", "=", "self", ".", "sep", ",", "rhs", "=", "self", ".", "rhs", ".", "compile", "(", ...
Compile this expression into a query string
[ "Compile", "this", "expression", "into", "a", "query", "string" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L75-L81
train
digidotcom/python-devicecloud
devicecloud/conditions.py
Comparison.compile
def compile(self): """Compile this expression into a query string""" return "{attribute}{sep}{value}".format( attribute=self.attribute, sep=self.sep, value=_quoted(self.value) )
python
def compile(self): """Compile this expression into a query string""" return "{attribute}{sep}{value}".format( attribute=self.attribute, sep=self.sep, value=_quoted(self.value) )
[ "def", "compile", "(", "self", ")", ":", "return", "\"{attribute}{sep}{value}\"", ".", "format", "(", "attribute", "=", "self", ".", "attribute", ",", "sep", "=", "self", ".", "sep", ",", "value", "=", "_quoted", "(", "self", ".", "value", ")", ")" ]
Compile this expression into a query string
[ "Compile", "this", "expression", "into", "a", "query", "string" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L96-L102
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
_read_msg_header
def _read_msg_header(session): """ Perform a read on input socket to consume headers and then return a tuple of message type, message length. :param session: Push Session to read data for. Returns response type (i.e. PUBLISH_MESSAGE) if header was completely read, otherwise None if header was ...
python
def _read_msg_header(session): """ Perform a read on input socket to consume headers and then return a tuple of message type, message length. :param session: Push Session to read data for. Returns response type (i.e. PUBLISH_MESSAGE) if header was completely read, otherwise None if header was ...
[ "def", "_read_msg_header", "(", "session", ")", ":", "try", ":", "data", "=", "session", ".", "socket", ".", "recv", "(", "6", "-", "len", "(", "session", ".", "data", ")", ")", "if", "len", "(", "data", ")", "==", "0", ":", "# No Data on Socket. Lik...
Perform a read on input socket to consume headers and then return a tuple of message type, message length. :param session: Push Session to read data for. Returns response type (i.e. PUBLISH_MESSAGE) if header was completely read, otherwise None if header was not completely read.
[ "Perform", "a", "read", "on", "input", "socket", "to", "consume", "headers", "and", "then", "return", "a", "tuple", "of", "message", "type", "message", "length", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L47-L77
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
_read_msg
def _read_msg(session): """ Perform a read on input socket to consume message and then return the payload and block_id in a tuple. :param session: Push Session to read data for. """ if len(session.data) == session.message_length: # Data Already completely read. Return return Tr...
python
def _read_msg(session): """ Perform a read on input socket to consume message and then return the payload and block_id in a tuple. :param session: Push Session to read data for. """ if len(session.data) == session.message_length: # Data Already completely read. Return return Tr...
[ "def", "_read_msg", "(", "session", ")", ":", "if", "len", "(", "session", ".", "data", ")", "==", "session", ".", "message_length", ":", "# Data Already completely read. Return", "return", "True", "try", ":", "data", "=", "session", ".", "socket", ".", "re...
Perform a read on input socket to consume message and then return the payload and block_id in a tuple. :param session: Push Session to read data for.
[ "Perform", "a", "read", "on", "input", "socket", "to", "consume", "message", "and", "then", "return", "the", "payload", "and", "block_id", "in", "a", "tuple", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L80-L103
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
PushSession.send_connection_request
def send_connection_request(self): """ Sends a ConnectionRequest to the iDigi server using the credentials established with the id of the monitor as defined in the monitor member. """ try: self.log.info("Sending ConnectionRequest for Monitor %s." ...
python
def send_connection_request(self): """ Sends a ConnectionRequest to the iDigi server using the credentials established with the id of the monitor as defined in the monitor member. """ try: self.log.info("Sending ConnectionRequest for Monitor %s." ...
[ "def", "send_connection_request", "(", "self", ")", ":", "try", ":", "self", ".", "log", ".", "info", "(", "\"Sending ConnectionRequest for Monitor %s.\"", "%", "self", ".", "monitor_id", ")", "# Send connection request and perform a receive to ensure", "# request is authen...
Sends a ConnectionRequest to the iDigi server using the credentials established with the id of the monitor as defined in the monitor member.
[ "Sends", "a", "ConnectionRequest", "to", "the", "iDigi", "server", "using", "the", "credentials", "established", "with", "the", "id", "of", "the", "monitor", "as", "defined", "in", "the", "monitor", "member", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L135-L201
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
PushSession.start
def start(self): """Creates a TCP connection to Device Cloud and sends a ConnectionRequest message""" self.log.info("Starting Insecure Session for Monitor %s" % self.monitor_id) if self.socket is not None: raise Exception("Socket already established for %s." % self) try: ...
python
def start(self): """Creates a TCP connection to Device Cloud and sends a ConnectionRequest message""" self.log.info("Starting Insecure Session for Monitor %s" % self.monitor_id) if self.socket is not None: raise Exception("Socket already established for %s." % self) try: ...
[ "def", "start", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Starting Insecure Session for Monitor %s\"", "%", "self", ".", "monitor_id", ")", "if", "self", ".", "socket", "is", "not", "None", ":", "raise", "Exception", "(", "\"Socket alre...
Creates a TCP connection to Device Cloud and sends a ConnectionRequest message
[ "Creates", "a", "TCP", "connection", "to", "Device", "Cloud", "and", "sends", "a", "ConnectionRequest", "message" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L203-L218
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
PushSession.stop
def stop(self): """Stop/Close this session Close the socket associated with this session and puts Session into a state such that it can be re-established later. """ if self.socket is not None: self.socket.close() self.socket = None self.data =...
python
def stop(self): """Stop/Close this session Close the socket associated with this session and puts Session into a state such that it can be re-established later. """ if self.socket is not None: self.socket.close() self.socket = None self.data =...
[ "def", "stop", "(", "self", ")", ":", "if", "self", ".", "socket", "is", "not", "None", ":", "self", ".", "socket", ".", "close", "(", ")", "self", ".", "socket", "=", "None", "self", ".", "data", "=", "None" ]
Stop/Close this session Close the socket associated with this session and puts Session into a state such that it can be re-established later.
[ "Stop", "/", "Close", "this", "session" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L220-L229
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
SecurePushSession.start
def start(self): """ Creates a SSL connection to the iDigi Server and sends a ConnectionRequest message. """ self.log.info("Starting SSL Session for Monitor %s." % self.monitor_id) if self.socket is not None: raise Exception("Socket alrea...
python
def start(self): """ Creates a SSL connection to the iDigi Server and sends a ConnectionRequest message. """ self.log.info("Starting SSL Session for Monitor %s." % self.monitor_id) if self.socket is not None: raise Exception("Socket alrea...
[ "def", "start", "(", "self", ")", ":", "self", ".", "log", ".", "info", "(", "\"Starting SSL Session for Monitor %s.\"", "%", "self", ".", "monitor_id", ")", "if", "self", ".", "socket", "is", "not", "None", ":", "raise", "Exception", "(", "\"Socket already ...
Creates a SSL connection to the iDigi Server and sends a ConnectionRequest message.
[ "Creates", "a", "SSL", "connection", "to", "the", "iDigi", "Server", "and", "sends", "a", "ConnectionRequest", "message", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L260-L288
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
CallbackWorkerPool._consume_queue
def _consume_queue(self): """ Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True. """ while True: session, block_id, raw_data = self._queue.get() ...
python
def _consume_queue(self): """ Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True. """ while True: session, block_id, raw_data = self._queue.get() ...
[ "def", "_consume_queue", "(", "self", ")", ":", "while", "True", ":", "session", ",", "block_id", ",", "raw_data", "=", "self", ".", "_queue", ".", "get", "(", ")", "data", "=", "json", ".", "loads", "(", "raw_data", ".", "decode", "(", "'utf-8'", ")...
Continually blocks until data is on the internal queue, then calls the session's registered callback and sends a PublishMessageReceived if callback returned True.
[ "Continually", "blocks", "until", "data", "is", "on", "the", "internal", "queue", "then", "calls", "the", "session", "s", "registered", "callback", "and", "sends", "a", "PublishMessageReceived", "if", "callback", "returned", "True", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L320-L345
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
CallbackWorkerPool.queue_callback
def queue_callback(self, session, block_id, data): """ Queues up a callback event to occur for a session with the given payload data. Will block if the queue is full. :param session: the session with a defined callback function to call. :param block_id: the block_id of the mess...
python
def queue_callback(self, session, block_id, data): """ Queues up a callback event to occur for a session with the given payload data. Will block if the queue is full. :param session: the session with a defined callback function to call. :param block_id: the block_id of the mess...
[ "def", "queue_callback", "(", "self", ",", "session", ",", "block_id", ",", "data", ")", ":", "self", ".", "_queue", ".", "put", "(", "(", "session", ",", "block_id", ",", "data", ")", ")" ]
Queues up a callback event to occur for a session with the given payload data. Will block if the queue is full. :param session: the session with a defined callback function to call. :param block_id: the block_id of the message received. :param data: the data payload of the message rece...
[ "Queues", "up", "a", "callback", "event", "to", "occur", "for", "a", "session", "with", "the", "given", "payload", "data", ".", "Will", "block", "if", "the", "queue", "is", "full", "." ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L347-L356
train
digidotcom/python-devicecloud
devicecloud/monitor_tcp.py
TCPClientManager._restart_session
def _restart_session(self, session): """Restarts and re-establishes session :param session: The session to restart """ # remove old session key, if socket is None, that means the # session was closed by user and there is no need to restart. if session.socket is not None:...
python
def _restart_session(self, session): """Restarts and re-establishes session :param session: The session to restart """ # remove old session key, if socket is None, that means the # session was closed by user and there is no need to restart. if session.socket is not None:...
[ "def", "_restart_session", "(", "self", ",", "session", ")", ":", "# remove old session key, if socket is None, that means the", "# session was closed by user and there is no need to restart.", "if", "session", ".", "socket", "is", "not", "None", ":", "self", ".", "log", "....
Restarts and re-establishes session :param session: The session to restart
[ "Restarts", "and", "re", "-", "establishes", "session" ]
32529684a348a7830a269c32601604c78036bcb8
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L403-L416
train