partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Device.get_ip | Get the last known IP of this device | devicecloud/devicecore.py | 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):
"""Get the last known IP of this device"""
device_json = self.get_device_json(use_cached)
return device_json.get("dpLastKnownIp") | [
"Get",
"the",
"last",
"known",
"IP",
"of",
"this",
"device"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L443-L446 | [
"def",
"get_ip",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"device_json",
"=",
"self",
".",
"get_device_json",
"(",
"use_cached",
")",
"return",
"device_json",
".",
"get",
"(",
"\"dpLastKnownIp\"",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.get_mac | Get the MAC address of this device | devicecloud/devicecore.py | 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):
"""Get the MAC address of this device"""
device_json = self.get_device_json(use_cached)
return device_json.get("devMac") | [
"Get",
"the",
"MAC",
"address",
"of",
"this",
"device"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L448-L451 | [
"def",
"get_mac",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"device_json",
"=",
"self",
".",
"get_device_json",
"(",
"use_cached",
")",
"return",
"device_json",
".",
"get",
"(",
"\"devMac\"",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.get_mac_last4 | 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. | devicecloud/devicecore.py | 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):
"""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",
")"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L453-L462 | [
"def",
"get_mac_last4",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"chunks",
"=",
"self",
".",
"get_mac",
"(",
"use_cached",
")",
".",
"split",
"(",
"\":\"",
")",
"mac4",
"=",
"\"%s%s\"",
"%",
"(",
"chunks",
"[",
"-",
"2",
"]",
",",
"ch... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.get_registration_dt | Get the datetime of when this device was added to Device Cloud | devicecloud/devicecore.py | 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):
"""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... | [
"Get",
"the",
"datetime",
"of",
"when",
"this",
"device",
"was",
"added",
"to",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L464-L471 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.get_latlon | Get a tuple with device latitude and longitude... these may be None | devicecloud/devicecore.py | 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):
"""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,
... | [
"Get",
"a",
"tuple",
"with",
"device",
"latitude",
"and",
"longitude",
"...",
"these",
"may",
"be",
"None"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L542-L548 | [
"def",
"get_latlon",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"device_json",
"=",
"self",
".",
"get_device_json",
"(",
"use_cached",
")",
"lat",
"=",
"device_json",
".",
"get",
"(",
"\"dpMapLat\"",
")",
"lon",
"=",
"device_json",
".",
"get",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.add_to_group | Add a device to a group, if the group doesn't exist it is created
:param group_path: Path or "name" of the group | devicecloud/devicecore.py | 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):
"""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()... | [
"Add",
"a",
"device",
"to",
"a",
"group",
"if",
"the",
"group",
"doesn",
"t",
"exist",
"it",
"is",
"created"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L576-L588 | [
"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",
"(",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.add_tag | 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 | devicecloud/devicecore.py | 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):
"""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)
... | [
"Add",
"a",
"tag",
"to",
"existing",
"device",
"tags",
".",
"This",
"method",
"will",
"not",
"add",
"a",
"duplicate",
"if",
"already",
"in",
"the",
"list",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L601-L626 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Device.remove_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 | devicecloud/devicecore.py | 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):
"""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... | [
"Remove",
"tag",
"from",
"existing",
"device",
"tags"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L630-L646 | [
"def",
"remove_tag",
"(",
"self",
",",
"tag",
")",
":",
"tags",
"=",
"self",
".",
"get_tags",
"(",
")",
"tags",
".",
"remove",
"(",
"tag",
")",
"post_data",
"=",
"TAGS_TEMPLATE",
".",
"format",
"(",
"connectware_id",
"=",
"self",
".",
"get_connectware_id... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.hostname | Get the hostname that this connection is associated with | devicecloud/__init__.py | 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):
"""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] | [
"Get",
"the",
"hostname",
"that",
"this",
"connection",
"is",
"associated",
"with"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L131-L134 | [
"def",
"hostname",
"(",
"self",
")",
":",
"from",
"six",
".",
"moves",
".",
"urllib",
".",
"parse",
"import",
"urlparse",
"return",
"urlparse",
"(",
"self",
".",
"_base_url",
")",
".",
"netloc",
".",
"split",
"(",
"':'",
",",
"1",
")",
"[",
"0",
"]... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.iter_json_pages | 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... | devicecloud/__init__.py | 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):
"""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 ... | [
"Return",
"an",
"iterator",
"over",
"JSON",
"items",
"from",
"a",
"paginated",
"resource"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L181-L209 | [
"def",
"iter_json_pages",
"(",
"self",
",",
"path",
",",
"page_size",
"=",
"1000",
",",
"*",
"*",
"params",
")",
":",
"path",
"=",
"validate_type",
"(",
"path",
",",
"*",
"six",
".",
"string_types",
")",
"page_size",
"=",
"validate_type",
"(",
"page_size... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.get | 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... | devicecloud/__init__.py | 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):
"""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
`... | [
"Perform",
"an",
"HTTP",
"GET",
"request",
"of",
"the",
"specified",
"path",
"in",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L220-L238 | [
"def",
"get",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_make_url",
"(",
"path",
")",
"return",
"self",
".",
"_make_request",
"(",
"\"GET\"",
",",
"url",
",",
"*",
"*",
"kwargs",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.get_json | 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... | devicecloud/__init__.py | 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):
"""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/... | [
"Perform",
"an",
"HTTP",
"GET",
"request",
"with",
"JSON",
"headers",
"of",
"the",
"specified",
"path",
"against",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L240-L266 | [
"def",
"get_json",
"(",
"self",
",",
"path",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_make_url",
"(",
"path",
")",
"headers",
"=",
"kwargs",
".",
"setdefault",
"(",
"'headers'",
",",
"{",
"}",
")",
"headers",
".",
"update",
"("... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.post | 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... | devicecloud/__init__.py | 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):
"""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
... | [
"Perform",
"an",
"HTTP",
"POST",
"request",
"of",
"the",
"specified",
"path",
"in",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L268-L288 | [
"def",
"post",
"(",
"self",
",",
"path",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_make_url",
"(",
"path",
")",
"return",
"self",
".",
"_make_request",
"(",
"\"POST\"",
",",
"url",
",",
"data",
"=",
"data",
",",
"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.put | 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... | devicecloud/__init__.py | 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):
"""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
... | [
"Perform",
"an",
"HTTP",
"PUT",
"request",
"of",
"the",
"specified",
"path",
"in",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L290-L311 | [
"def",
"put",
"(",
"self",
",",
"path",
",",
"data",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_make_url",
"(",
"path",
")",
"return",
"self",
".",
"_make_request",
"(",
"\"PUT\"",
",",
"url",
",",
"data",
"=",
"data",
",",
"*"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloudConnection.delete | 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... | devicecloud/__init__.py | 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):
"""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... | [
"Perform",
"an",
"HTTP",
"DELETE",
"request",
"of",
"the",
"specified",
"path",
"in",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L313-L331 | [
"def",
"delete",
"(",
"self",
",",
"path",
",",
"retries",
"=",
"DEFAULT_THROTTLE_RETRIES",
",",
"*",
"*",
"kwargs",
")",
":",
"url",
"=",
"self",
".",
"_make_url",
"(",
"path",
")",
"return",
"self",
".",
"_make_request",
"(",
"\"DELETE\"",
",",
"url",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.streams | Property providing access to the :class:`.StreamsAPI` | devicecloud/__init__.py | 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):
"""Property providing access to the :class:`.StreamsAPI`"""
if self._streams_api is None:
self._streams_api = self.get_streams_api()
return self._streams_api | [
"Property",
"providing",
"access",
"to",
"the",
":",
"class",
":",
".",
"StreamsAPI"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L394-L398 | [
"def",
"streams",
"(",
"self",
")",
":",
"if",
"self",
".",
"_streams_api",
"is",
"None",
":",
"self",
".",
"_streams_api",
"=",
"self",
".",
"get_streams_api",
"(",
")",
"return",
"self",
".",
"_streams_api"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.filedata | Property providing access to the :class:`.FileDataAPI` | devicecloud/__init__.py | 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):
"""Property providing access to the :class:`.FileDataAPI`"""
if self._filedata_api is None:
self._filedata_api = self.get_filedata_api()
return self._filedata_api | [
"Property",
"providing",
"access",
"to",
"the",
":",
"class",
":",
".",
"FileDataAPI"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L401-L405 | [
"def",
"filedata",
"(",
"self",
")",
":",
"if",
"self",
".",
"_filedata_api",
"is",
"None",
":",
"self",
".",
"_filedata_api",
"=",
"self",
".",
"get_filedata_api",
"(",
")",
"return",
"self",
".",
"_filedata_api"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.devicecore | Property providing access to the :class:`.DeviceCoreAPI` | devicecloud/__init__.py | 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):
"""Property providing access to the :class:`.DeviceCoreAPI`"""
if self._devicecore_api is None:
self._devicecore_api = self.get_devicecore_api()
return self._devicecore_api | [
"Property",
"providing",
"access",
"to",
"the",
":",
"class",
":",
".",
"DeviceCoreAPI"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L408-L412 | [
"def",
"devicecore",
"(",
"self",
")",
":",
"if",
"self",
".",
"_devicecore_api",
"is",
"None",
":",
"self",
".",
"_devicecore_api",
"=",
"self",
".",
"get_devicecore_api",
"(",
")",
"return",
"self",
".",
"_devicecore_api"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.sci | Property providing access to the :class:`.ServerCommandInterfaceAPI` | devicecloud/__init__.py | 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):
"""Property providing access to the :class:`.ServerCommandInterfaceAPI`"""
if self._sci_api is None:
self._sci_api = self.get_sci_api()
return self._sci_api | [
"Property",
"providing",
"access",
"to",
"the",
":",
"class",
":",
".",
"ServerCommandInterfaceAPI"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L415-L419 | [
"def",
"sci",
"(",
"self",
")",
":",
"if",
"self",
".",
"_sci_api",
"is",
"None",
":",
"self",
".",
"_sci_api",
"=",
"self",
".",
"get_sci_api",
"(",
")",
"return",
"self",
".",
"_sci_api"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.file_system_service | Property providing access to the :class:`.FileSystemServiceAPI` | devicecloud/__init__.py | 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):
"""Property providing access to the :class:`.FileSystemServiceAPI`"""
if self._fss_api is None:
self._fss_api = self.get_fss_api()
return self._fss_api | [
"Property",
"providing",
"access",
"to",
"the",
":",
"class",
":",
".",
"FileSystemServiceAPI"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L422-L426 | [
"def",
"file_system_service",
"(",
"self",
")",
":",
"if",
"self",
".",
"_fss_api",
"is",
"None",
":",
"self",
".",
"_fss_api",
"=",
"self",
".",
"get_fss_api",
"(",
")",
"return",
"self",
".",
"_fss_api"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.monitor | Property providing access to the :class:`.MonitorAPI` | devicecloud/__init__.py | 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):
"""Property providing access to the :class:`.MonitorAPI`"""
if self._monitor_api is None:
self._monitor_api = self.get_monitor_api()
return self._monitor_api | [
"Property",
"providing",
"access",
"to",
"the",
":",
"class",
":",
".",
"MonitorAPI"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L429-L433 | [
"def",
"monitor",
"(",
"self",
")",
":",
"if",
"self",
".",
"_monitor_api",
"is",
"None",
":",
"self",
".",
"_monitor_api",
"=",
"self",
".",
"get_monitor_api",
"(",
")",
"return",
"self",
".",
"_monitor_api"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DeviceCloud.get_devicecore_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... | devicecloud/__init__.py | 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):
"""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 ... | [
"Returns",
"a",
":",
"class",
":",
".",
"DeviceCoreAPI",
"bound",
"to",
"this",
"device",
"cloud",
"instance"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L477-L489 | [
"def",
"get_devicecore_api",
"(",
"self",
")",
":",
"from",
"devicecloud",
".",
"devicecore",
"import",
"DeviceCoreAPI",
"return",
"DeviceCoreAPI",
"(",
"self",
".",
"_conn",
",",
"self",
".",
"get_sci_api",
"(",
")",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | ServerCommandInterfaceAPI.get_async_job | 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 | devicecloud/sci.py | 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):
"""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... | [
"Query",
"an",
"asynchronous",
"SCI",
"job",
"by",
"ID"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L100-L110 | [
"def",
"get_async_job",
"(",
"self",
",",
"job_id",
")",
":",
"uri",
"=",
"\"/ws/sci/{0}\"",
".",
"format",
"(",
"job_id",
")",
"# TODO: do parsing here?",
"return",
"self",
".",
"_conn",
".",
"get",
"(",
"uri",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | ServerCommandInterfaceAPI.send_sci_async | 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... | devicecloud/sci.py | 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):
"""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... | [
"Send",
"an",
"asynchronous",
"SCI",
"request",
"and",
"wraps",
"the",
"job",
"in",
"an",
"object",
"to",
"manage",
"it"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L112-L131 | [
"def",
"send_sci_async",
"(",
"self",
",",
"operation",
",",
"target",
",",
"payload",
",",
"*",
"*",
"sci_options",
")",
":",
"sci_options",
"[",
"'synchronous'",
"]",
"=",
"False",
"resp",
"=",
"self",
".",
"send_sci",
"(",
"operation",
",",
"target",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | ServerCommandInterfaceAPI.send_sci | 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... | devicecloud/sci.py | 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_reconnect=None):
"""Send SCI request to 1 or more targets
:param str operation: The operation is one of {send_message, update_firmware, disconnect, q... | [
"Send",
"SCI",
"request",
"to",
"1",
"or",
"more",
"targets"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L133-L220 | [
"def",
"send_sci",
"(",
"self",
",",
"operation",
",",
"target",
",",
"payload",
",",
"reply",
"=",
"None",
",",
"synchronous",
"=",
"None",
",",
"sync_timeout",
"=",
"None",
",",
"cache",
"=",
"None",
",",
"allow_offline",
"=",
"None",
",",
"wait_for_re... | 32529684a348a7830a269c32601604c78036bcb8 |
train | conditional_write | Write to stream using fmt and value if value is not None | devicecloud/util.py | 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):
"""Write to stream using fmt and value if value is not None"""
if value is not None:
strm.write(fmt.format(value, *args, **kwargs)) | [
"Write",
"to",
"stream",
"using",
"fmt",
"and",
"value",
"if",
"value",
"is",
"not",
"None"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L13-L16 | [
"def",
"conditional_write",
"(",
"strm",
",",
"fmt",
",",
"value",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"value",
"is",
"not",
"None",
":",
"strm",
".",
"write",
"(",
"fmt",
".",
"format",
"(",
"value",
",",
"*",
"args",
",",... | 32529684a348a7830a269c32601604c78036bcb8 |
train | iso8601_to_dt | Given an ISO8601 string as returned by Device Cloud, convert to a datetime object | devicecloud/util.py | 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):
"""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... | [
"Given",
"an",
"ISO8601",
"string",
"as",
"returned",
"by",
"Device",
"Cloud",
"convert",
"to",
"a",
"datetime",
"object"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L19-L29 | [
"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"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | to_none_or_dt | 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... | devicecloud/util.py | 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):
"""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... | [
"Convert",
"input",
"to",
"either",
"None",
"or",
"a",
"datetime",
"object"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L32-L57 | [
"def",
"to_none_or_dt",
"(",
"input",
")",
":",
"if",
"input",
"is",
"None",
":",
"return",
"input",
"elif",
"isinstance",
"(",
"input",
",",
"datetime",
".",
"datetime",
")",
":",
"arrow_dt",
"=",
"arrow",
".",
"Arrow",
".",
"fromdatetime",
"(",
"input"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | isoformat | Return an ISO-8601 formatted string from the provided datetime object | devicecloud/util.py | 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):
"""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... | [
"Return",
"an",
"ISO",
"-",
"8601",
"formatted",
"string",
"from",
"the",
"provided",
"datetime",
"object"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L72-L80 | [
"def",
"isoformat",
"(",
"dt",
")",
":",
"if",
"not",
"isinstance",
"(",
"dt",
",",
"datetime",
".",
"datetime",
")",
":",
"raise",
"TypeError",
"(",
"\"Must provide datetime.datetime object to isoformat\"",
")",
"if",
"dt",
".",
"tzinfo",
"is",
"None",
":",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | FileDataAPI.get_filedata | 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
... | devicecloud/filedata.py | 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):
"""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.... | [
"Return",
"a",
"generator",
"over",
"all",
"results",
"matching",
"the",
"provided",
"condition"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L30-L54 | [
"def",
"get_filedata",
"(",
"self",
",",
"condition",
"=",
"None",
",",
"page_size",
"=",
"1000",
")",
":",
"condition",
"=",
"validate_type",
"(",
"condition",
",",
"type",
"(",
"None",
")",
",",
"Expression",
",",
"*",
"six",
".",
"string_types",
")",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | FileDataAPI.write_file | 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 (... | devicecloud/filedata.py | 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):
"""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.
... | [
"Write",
"a",
"file",
"to",
"the",
"file",
"data",
"store",
"at",
"the",
"given",
"path"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L56-L108 | [
"def",
"write_file",
"(",
"self",
",",
"path",
",",
"name",
",",
"data",
",",
"content_type",
"=",
"None",
",",
"archive",
"=",
"False",
",",
"raw",
"=",
"False",
")",
":",
"path",
"=",
"validate_type",
"(",
"path",
",",
"*",
"six",
".",
"string_type... | 32529684a348a7830a269c32601604c78036bcb8 |
train | FileDataAPI.delete_file | 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. | devicecloud/filedata.py | 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):
"""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... | [
"Delete",
"a",
"file",
"or",
"directory",
"from",
"the",
"filedata",
"store"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L110-L124 | [
"def",
"delete_file",
"(",
"self",
",",
"path",
")",
":",
"path",
"=",
"validate_type",
"(",
"path",
",",
"*",
"six",
".",
"string_types",
")",
"if",
"not",
"path",
".",
"startswith",
"(",
"\"/\"",
")",
":",
"path",
"=",
"\"/\"",
"+",
"path",
"self",... | 32529684a348a7830a269c32601604c78036bcb8 |
train | FileDataAPI.walk | 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... | devicecloud/filedata.py | 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="~/"):
"""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... | [
"Emulation",
"of",
"os",
".",
"walk",
"behavior",
"against",
"Device",
"Cloud",
"filedata",
"store"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L126-L160 | [
"def",
"walk",
"(",
"self",
",",
"root",
"=",
"\"~/\"",
")",
":",
"root",
"=",
"validate_type",
"(",
"root",
",",
"*",
"six",
".",
"string_types",
")",
"directories",
"=",
"[",
"]",
"files",
"=",
"[",
"]",
"# fd_path is real picky",
"query_fd_path",
"=",... | 32529684a348a7830a269c32601604c78036bcb8 |
train | FileDataObject.get_data | 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 | devicecloud/filedata.py | 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):
"""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... | [
"Get",
"the",
"data",
"associated",
"with",
"this",
"filedata",
"object"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L182-L195 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | FileDataDirectory.write_file | 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. | devicecloud/filedata.py | 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):
"""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... | [
"Write",
"a",
"file",
"into",
"this",
"directory"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L259-L266 | [
"def",
"write_file",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"_fdapi",
".",
"write_file",
"(",
"self",
".",
"get_path",
"(",
")",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | MonitorAPI.create_tcp_monitor | 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... | devicecloud/monitor.py | 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'):
"""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... | [
"Creates",
"a",
"TCP",
"Monitor",
"instance",
"in",
"Device",
"Cloud",
"for",
"a",
"given",
"list",
"of",
"topics"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L176-L211 | [
"def",
"create_tcp_monitor",
"(",
"self",
",",
"topics",
",",
"batch_size",
"=",
"1",
",",
"batch_duration",
"=",
"0",
",",
"compression",
"=",
"'gzip'",
",",
"format_type",
"=",
"'json'",
")",
":",
"monitor_xml",
"=",
"\"\"\"\\\n <Monitor>\n <mo... | 32529684a348a7830a269c32601604c78036bcb8 |
train | MonitorAPI.create_http_monitor | 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... | devicecloud/monitor.py | 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, batch_duration=0, compression='none', format_type='json'):
"""Creates a HTTP Monitor instance in Device Cloud for a given list of to... | [
"Creates",
"a",
"HTTP",
"Monitor",
"instance",
"in",
"Device",
"Cloud",
"for",
"a",
"given",
"list",
"of",
"topics"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L213-L263 | [
"def",
"create_http_monitor",
"(",
"self",
",",
"topics",
",",
"transport_url",
",",
"transport_token",
"=",
"None",
",",
"transport_method",
"=",
"'PUT'",
",",
"connect_timeout",
"=",
"0",
",",
"response_timeout",
"=",
"0",
",",
"batch_size",
"=",
"1",
",",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | MonitorAPI.get_monitors | 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.... | devicecloud/monitor.py | 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):
"""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... | [
"Return",
"an",
"iterator",
"over",
"all",
"monitors",
"matching",
"the",
"provided",
"condition"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L265-L294 | [
"def",
"get_monitors",
"(",
"self",
",",
"condition",
"=",
"None",
",",
"page_size",
"=",
"1000",
")",
":",
"req_kwargs",
"=",
"{",
"}",
"if",
"condition",
":",
"req_kwargs",
"[",
"'condition'",
"]",
"=",
"condition",
".",
"compile",
"(",
")",
"for",
"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | MonitorAPI.get_monitor | 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. | devicecloud/monitor.py | 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):
"""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 ... | [
"Attempts",
"to",
"find",
"a",
"Monitor",
"in",
"device",
"cloud",
"that",
"matches",
"the",
"provided",
"topics"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L296-L305 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | _get_encoder_method | 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... | devicecloud/streams.py | 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):
"""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... | [
"A",
"function",
"to",
"get",
"the",
"python",
"type",
"to",
"device",
"cloud",
"type",
"converter",
"function",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L66-L77 | [
"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",
":",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | _get_decoder_method | 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... | devicecloud/streams.py | 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):
""" 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... | [
"A",
"function",
"to",
"get",
"Device",
"Cloud",
"type",
"to",
"python",
"type",
"converter",
"function",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L80-L91 | [
"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",
":",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | StreamsAPI._get_streams | Clear and update internal cache of stream objects | devicecloud/streams.py | 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):
"""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:
... | [
"Clear",
"and",
"update",
"internal",
"cache",
"of",
"stream",
"objects"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L116-L129 | [
"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",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | StreamsAPI.create_stream | 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... | devicecloud/streams.py | 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):
"""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... | [
"Create",
"a",
"new",
"data",
"stream",
"on",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L131-L173 | [
"def",
"create_stream",
"(",
"self",
",",
"stream_id",
",",
"data_type",
",",
"description",
"=",
"None",
",",
"data_ttl",
"=",
"None",
",",
"rollup_ttl",
"=",
"None",
",",
"units",
"=",
"None",
")",
":",
"stream_id",
"=",
"validate_type",
"(",
"stream_id"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | StreamsAPI.get_stream_if_exists | 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... | devicecloud/streams.py | 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):
"""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
... | [
"Return",
"a",
"reference",
"to",
"a",
"stream",
"with",
"the",
"given",
"stream_id",
"if",
"it",
"exists"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L203-L222 | [
"def",
"get_stream_if_exists",
"(",
"self",
",",
"stream_id",
")",
":",
"stream",
"=",
"self",
".",
"get_stream",
"(",
"stream_id",
")",
"try",
":",
"stream",
".",
"get_data_type",
"(",
"use_cached",
"=",
"True",
")",
"except",
"NoSuchStreamException",
":",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | StreamsAPI.bulk_write_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 be made.
As this call is performed from outside ... | devicecloud/streams.py | 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):
"""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... | [
"Perform",
"a",
"bulk",
"write",
"(",
"or",
"set",
"of",
"writes",
")",
"of",
"a",
"collection",
"of",
"data",
"points"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L224-L283 | [
"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",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.from_json | 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:`... | devicecloud/streams.py | 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):
"""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... | [
"Create",
"a",
"new",
"DataPoint",
"object",
"from",
"device",
"cloud",
"JSON",
"data"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L296-L321 | [
"def",
"from_json",
"(",
"cls",
",",
"stream",
",",
"json_data",
")",
":",
"type_converter",
"=",
"_get_decoder_method",
"(",
"stream",
".",
"get_data_type",
"(",
")",
")",
"data",
"=",
"type_converter",
"(",
"json_data",
".",
"get",
"(",
"\"data\"",
")",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.from_rollup_json | 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:`... | devicecloud/streams.py | 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):
"""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... | [
"Rollup",
"json",
"data",
"from",
"the",
"server",
"looks",
"slightly",
"different"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L324-L344 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.set_stream_id | Set the stream id associated with this data point | devicecloud/streams.py | 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):
"""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 | [
"Set",
"the",
"stream",
"id",
"associated",
"with",
"this",
"data",
"point"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L429-L434 | [
"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",
"=",... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.set_description | Set the description for this data point | devicecloud/streams.py | 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):
"""Set the description for this data point"""
self._description = validate_type(description, type(None), *six.string_types) | [
"Set",
"the",
"description",
"for",
"this",
"data",
"point"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L440-L442 | [
"def",
"set_description",
"(",
"self",
",",
"description",
")",
":",
"self",
".",
"_description",
"=",
"validate_type",
"(",
"description",
",",
"type",
"(",
"None",
")",
",",
"*",
"six",
".",
"string_types",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.set_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. | devicecloud/streams.py | 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):
"""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... | [
"Set",
"the",
"quality",
"for",
"this",
"sample"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L475-L488 | [
"def",
"set_quality",
"(",
"self",
",",
"quality",
")",
":",
"if",
"isinstance",
"(",
"quality",
",",
"*",
"six",
".",
"string_types",
")",
":",
"quality",
"=",
"int",
"(",
"quality",
")",
"elif",
"isinstance",
"(",
"quality",
",",
"float",
")",
":",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.set_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). | devicecloud/streams.py | 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):
"""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:
... | [
"Set",
"the",
"location",
"for",
"this",
"data",
"point"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L499-L526 | [
"def",
"set_location",
"(",
"self",
",",
"location",
")",
":",
"if",
"location",
"is",
"None",
":",
"self",
".",
"_location",
"=",
"location",
"elif",
"isinstance",
"(",
"location",
",",
"*",
"six",
".",
"string_types",
")",
":",
"# from device cloud, conver... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.set_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
include this information.
The ... | devicecloud/streams.py | 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):
"""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
... | [
"Set",
"the",
"data",
"type",
"for",
"ths",
"data",
"point"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L539-L556 | [
"def",
"set_data_type",
"(",
"self",
",",
"data_type",
")",
":",
"validate_type",
"(",
"data_type",
",",
"type",
"(",
"None",
")",
",",
"*",
"six",
".",
"string_types",
")",
"if",
"isinstance",
"(",
"data_type",
",",
"*",
"six",
".",
"string_types",
")",... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.set_units | 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... | devicecloud/streams.py | 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):
"""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... | [
"Set",
"the",
"unit",
"for",
"this",
"data",
"point"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L562-L571 | [
"def",
"set_units",
"(",
"self",
",",
"unit",
")",
":",
"self",
".",
"_units",
"=",
"validate_type",
"(",
"unit",
",",
"type",
"(",
"None",
")",
",",
"*",
"six",
".",
"string_types",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataPoint.to_xml | 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. | devicecloud/streams.py | 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):
"""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... | [
"Convert",
"this",
"datapoint",
"into",
"a",
"form",
"suitable",
"for",
"pushing",
"to",
"device",
"cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L573-L597 | [
"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",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream._get_stream_metadata | Retrieve metadata about this stream from Device Cloud | devicecloud/streams.py | 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):
"""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... | [
"Retrieve",
"metadata",
"about",
"this",
"stream",
"from",
"Device",
"Cloud"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L640-L649 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.get_data_type | 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... | devicecloud/streams.py | 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):
"""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 ... | [
"Get",
"the",
"data",
"type",
"of",
"this",
"stream",
"if",
"it",
"exists"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L660-L686 | [
"def",
"get_data_type",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"dtype",
"=",
"self",
".",
"_get_stream_metadata",
"(",
"use_cached",
")",
".",
"get",
"(",
"\"dataType\"",
")",
"if",
"dtype",
"is",
"not",
"None",
":",
"dtype",
"=",
"dtype"... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.get_data_ttl | 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 ... | devicecloud/streams.py | 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):
"""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... | [
"Retrieve",
"the",
"dataTTL",
"for",
"this",
"stream"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L714-L730 | [
"def",
"get_data_ttl",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"data_ttl_text",
"=",
"self",
".",
"_get_stream_metadata",
"(",
"use_cached",
")",
".",
"get",
"(",
"\"dataTtl\"",
")",
"return",
"int",
"(",
"data_ttl_text",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.get_rollup_ttl | 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... | devicecloud/streams.py | 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):
"""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.
... | [
"Retrieve",
"the",
"rollupTtl",
"for",
"this",
"stream"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L732-L748 | [
"def",
"get_rollup_ttl",
"(",
"self",
",",
"use_cached",
"=",
"True",
")",
":",
"rollup_ttl_text",
"=",
"self",
".",
"_get_stream_metadata",
"(",
"use_cached",
")",
".",
"get",
"(",
"\"rollupTtl\"",
")",
"return",
"int",
"(",
"rollup_ttl_text",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.get_current_value | 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... | devicecloud/streams.py | 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):
"""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, ... | [
"Return",
"the",
"most",
"recent",
"DataPoint",
"value",
"written",
"to",
"a",
"stream"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L750-L767 | [
"def",
"get_current_value",
"(",
"self",
",",
"use_cached",
"=",
"False",
")",
":",
"current_value",
"=",
"self",
".",
"_get_stream_metadata",
"(",
"use_cached",
")",
".",
"get",
"(",
"\"currentValue\"",
")",
"if",
"current_value",
":",
"return",
"DataPoint",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.delete | 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... | devicecloud/streams.py | 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):
"""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
... | [
"Delete",
"this",
"stream",
"from",
"Device",
"Cloud",
"along",
"with",
"its",
"history"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L769-L785 | [
"def",
"delete",
"(",
"self",
")",
":",
"try",
":",
"self",
".",
"_conn",
".",
"delete",
"(",
"\"/ws/DataStream/{}\"",
".",
"format",
"(",
"self",
".",
"get_stream_id",
"(",
")",
")",
")",
"except",
"DeviceCloudHttpException",
"as",
"http_excpeption",
":",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.delete_datapoint | Delete the provided datapoint from this stream
:raises devicecloud.DeviceCloudHttpException: in the case of an unexpected http error | devicecloud/streams.py | 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):
"""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... | [
"Delete",
"the",
"provided",
"datapoint",
"from",
"this",
"stream"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L787-L797 | [
"def",
"delete_datapoint",
"(",
"self",
",",
"datapoint",
")",
":",
"datapoint",
"=",
"validate_type",
"(",
"datapoint",
",",
"DataPoint",
")",
"self",
".",
"_conn",
".",
"delete",
"(",
"\"/ws/DataPoint/{stream_id}/{datapoint_id}\"",
".",
"format",
"(",
"stream_id... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.delete_datapoints_in_time_range | 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... | devicecloud/streams.py | 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):
"""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... | [
"Delete",
"datapoints",
"from",
"this",
"stream",
"between",
"the",
"provided",
"start",
"and",
"end",
"times"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L799-L824 | [
"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",
")... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.write | 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
... | devicecloud/streams.py | 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):
"""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... | [
"Write",
"some",
"raw",
"data",
"to",
"a",
"stream",
"using",
"the",
"DataPoint",
"API"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L865-L885 | [
"def",
"write",
"(",
"self",
",",
"datapoint",
")",
":",
"if",
"not",
"isinstance",
"(",
"datapoint",
",",
"DataPoint",
")",
":",
"raise",
"TypeError",
"(",
"\"First argument must be a DataPoint object\"",
")",
"datapoint",
".",
"_stream_id",
"=",
"self",
".",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | DataStream.read | 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... | devicecloud/streams.py | 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=None, page_size=1000):
"""Read one or more DataPoints from a stream
.. warning::
The data points from Device Cloud is a paged data set. ... | [
"Read",
"one",
"or",
"more",
"DataPoints",
"from",
"a",
"stream"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L887-L1017 | [
"def",
"read",
"(",
"self",
",",
"start_time",
"=",
"None",
",",
"end_time",
"=",
"None",
",",
"use_client_timeline",
"=",
"True",
",",
"newest_first",
"=",
"True",
",",
"rollup_interval",
"=",
"None",
",",
"rollup_method",
"=",
"None",
",",
"timezone",
"=... | 32529684a348a7830a269c32601604c78036bcb8 |
train | _quoted | 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. | devicecloud/conditions.py | 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):
"""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(... | [
"Return",
"a",
"single",
"-",
"quoted",
"and",
"escaped",
"(",
"percent",
"-",
"encoded",
")",
"version",
"of",
"value"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L19-L32 | [
"def",
"_quoted",
"(",
"value",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"datetime",
".",
"datetime",
")",
":",
"value",
"=",
"isoformat",
"(",
"to_none_or_dt",
"(",
"value",
")",
")",
"else",
":",
"value",
"=",
"str",
"(",
"value",
")",
"ret... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Combination.compile | Compile this expression into a query string | devicecloud/conditions.py | 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):
"""Compile this expression into a query string"""
return "{lhs}{sep}{rhs}".format(
lhs=self.lhs.compile(),
sep=self.sep,
rhs=self.rhs.compile(),
) | [
"Compile",
"this",
"expression",
"into",
"a",
"query",
"string"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L75-L81 | [
"def",
"compile",
"(",
"self",
")",
":",
"return",
"\"{lhs}{sep}{rhs}\"",
".",
"format",
"(",
"lhs",
"=",
"self",
".",
"lhs",
".",
"compile",
"(",
")",
",",
"sep",
"=",
"self",
".",
"sep",
",",
"rhs",
"=",
"self",
".",
"rhs",
".",
"compile",
"(",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | Comparison.compile | Compile this expression into a query string | devicecloud/conditions.py | 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):
"""Compile this expression into a query string"""
return "{attribute}{sep}{value}".format(
attribute=self.attribute,
sep=self.sep,
value=_quoted(self.value)
) | [
"Compile",
"this",
"expression",
"into",
"a",
"query",
"string"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/conditions.py#L96-L102 | [
"def",
"compile",
"(",
"self",
")",
":",
"return",
"\"{attribute}{sep}{value}\"",
".",
"format",
"(",
"attribute",
"=",
"self",
".",
"attribute",
",",
"sep",
"=",
"self",
".",
"sep",
",",
"value",
"=",
"_quoted",
"(",
"self",
".",
"value",
")",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | _read_msg_header | 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. | devicecloud/monitor_tcp.py | 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):
"""
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 ... | [
"Perform",
"a",
"read",
"on",
"input",
"socket",
"to",
"consume",
"headers",
"and",
"then",
"return",
"a",
"tuple",
"of",
"message",
"type",
"message",
"length",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L47-L77 | [
"def",
"_read_msg_header",
"(",
"session",
")",
":",
"try",
":",
"data",
"=",
"session",
".",
"socket",
".",
"recv",
"(",
"6",
"-",
"len",
"(",
"session",
".",
"data",
")",
")",
"if",
"len",
"(",
"data",
")",
"==",
"0",
":",
"# No Data on Socket. Lik... | 32529684a348a7830a269c32601604c78036bcb8 |
train | _read_msg | 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. | devicecloud/monitor_tcp.py | 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):
"""
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... | [
"Perform",
"a",
"read",
"on",
"input",
"socket",
"to",
"consume",
"message",
"and",
"then",
"return",
"the",
"payload",
"and",
"block_id",
"in",
"a",
"tuple",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L80-L103 | [
"def",
"_read_msg",
"(",
"session",
")",
":",
"if",
"len",
"(",
"session",
".",
"data",
")",
"==",
"session",
".",
"message_length",
":",
"# Data Already completely read. Return",
"return",
"True",
"try",
":",
"data",
"=",
"session",
".",
"socket",
".",
"re... | 32529684a348a7830a269c32601604c78036bcb8 |
train | PushSession.send_connection_request | Sends a ConnectionRequest to the iDigi server using the credentials
established with the id of the monitor as defined in the monitor
member. | devicecloud/monitor_tcp.py | 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):
"""
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."
... | [
"Sends",
"a",
"ConnectionRequest",
"to",
"the",
"iDigi",
"server",
"using",
"the",
"credentials",
"established",
"with",
"the",
"id",
"of",
"the",
"monitor",
"as",
"defined",
"in",
"the",
"monitor",
"member",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L135-L201 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | PushSession.start | Creates a TCP connection to Device Cloud and sends a ConnectionRequest message | devicecloud/monitor_tcp.py | 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):
"""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:
... | [
"Creates",
"a",
"TCP",
"connection",
"to",
"Device",
"Cloud",
"and",
"sends",
"a",
"ConnectionRequest",
"message"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L203-L218 | [
"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... | 32529684a348a7830a269c32601604c78036bcb8 |
train | PushSession.stop | 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. | devicecloud/monitor_tcp.py | 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):
"""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 =... | [
"Stop",
"/",
"Close",
"this",
"session"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L220-L229 | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"socket",
"is",
"not",
"None",
":",
"self",
".",
"socket",
".",
"close",
"(",
")",
"self",
".",
"socket",
"=",
"None",
"self",
".",
"data",
"=",
"None"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | SecurePushSession.start | Creates a SSL connection to the iDigi Server and sends a
ConnectionRequest message. | devicecloud/monitor_tcp.py | 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):
"""
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... | [
"Creates",
"a",
"SSL",
"connection",
"to",
"the",
"iDigi",
"Server",
"and",
"sends",
"a",
"ConnectionRequest",
"message",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L260-L288 | [
"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 ... | 32529684a348a7830a269c32601604c78036bcb8 |
train | CallbackWorkerPool._consume_queue | Continually blocks until data is on the internal queue, then calls
the session's registered callback and sends a PublishMessageReceived
if callback returned True. | devicecloud/monitor_tcp.py | 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):
"""
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()
... | [
"Continually",
"blocks",
"until",
"data",
"is",
"on",
"the",
"internal",
"queue",
"then",
"calls",
"the",
"session",
"s",
"registered",
"callback",
"and",
"sends",
"a",
"PublishMessageReceived",
"if",
"callback",
"returned",
"True",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L320-L345 | [
"def",
"_consume_queue",
"(",
"self",
")",
":",
"while",
"True",
":",
"session",
",",
"block_id",
",",
"raw_data",
"=",
"self",
".",
"_queue",
".",
"get",
"(",
")",
"data",
"=",
"json",
".",
"loads",
"(",
"raw_data",
".",
"decode",
"(",
"'utf-8'",
")... | 32529684a348a7830a269c32601604c78036bcb8 |
train | CallbackWorkerPool.queue_callback | 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... | devicecloud/monitor_tcp.py | 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):
"""
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... | [
"Queues",
"up",
"a",
"callback",
"event",
"to",
"occur",
"for",
"a",
"session",
"with",
"the",
"given",
"payload",
"data",
".",
"Will",
"block",
"if",
"the",
"queue",
"is",
"full",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L347-L356 | [
"def",
"queue_callback",
"(",
"self",
",",
"session",
",",
"block_id",
",",
"data",
")",
":",
"self",
".",
"_queue",
".",
"put",
"(",
"(",
"session",
",",
"block_id",
",",
"data",
")",
")"
] | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager._restart_session | Restarts and re-establishes session
:param session: The session to restart | devicecloud/monitor_tcp.py | 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):
"""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:... | [
"Restarts",
"and",
"re",
"-",
"establishes",
"session"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L403-L416 | [
"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",
".... | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager._writer | Indefinitely checks the writer queue for data to write
to socket. | devicecloud/monitor_tcp.py | def _writer(self):
"""
Indefinitely checks the writer queue for data to write
to socket.
"""
while not self.closed:
try:
sock, data = self._write_queue.get(timeout=0.1)
self._write_queue.task_done()
sock.send(data)
... | def _writer(self):
"""
Indefinitely checks the writer queue for data to write
to socket.
"""
while not self.closed:
try:
sock, data = self._write_queue.get(timeout=0.1)
self._write_queue.task_done()
sock.send(data)
... | [
"Indefinitely",
"checks",
"the",
"writer",
"queue",
"for",
"data",
"to",
"write",
"to",
"socket",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L418-L432 | [
"def",
"_writer",
"(",
"self",
")",
":",
"while",
"not",
"self",
".",
"closed",
":",
"try",
":",
"sock",
",",
"data",
"=",
"self",
".",
"_write_queue",
".",
"get",
"(",
"timeout",
"=",
"0.1",
")",
"self",
".",
"_write_queue",
".",
"task_done",
"(",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager._clean_dead_sessions | Traverses sessions to determine if any sockets
were removed (indicates a stopped session).
In these cases, remove the session. | devicecloud/monitor_tcp.py | def _clean_dead_sessions(self):
"""
Traverses sessions to determine if any sockets
were removed (indicates a stopped session).
In these cases, remove the session.
"""
for sck in list(self.sessions.keys()):
session = self.sessions[sck]
if session.so... | def _clean_dead_sessions(self):
"""
Traverses sessions to determine if any sockets
were removed (indicates a stopped session).
In these cases, remove the session.
"""
for sck in list(self.sessions.keys()):
session = self.sessions[sck]
if session.so... | [
"Traverses",
"sessions",
"to",
"determine",
"if",
"any",
"sockets",
"were",
"removed",
"(",
"indicates",
"a",
"stopped",
"session",
")",
".",
"In",
"these",
"cases",
"remove",
"the",
"session",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L434-L443 | [
"def",
"_clean_dead_sessions",
"(",
"self",
")",
":",
"for",
"sck",
"in",
"list",
"(",
"self",
".",
"sessions",
".",
"keys",
"(",
")",
")",
":",
"session",
"=",
"self",
".",
"sessions",
"[",
"sck",
"]",
"if",
"session",
".",
"socket",
"is",
"None",
... | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager._select | While the client is not marked as closed, performs a socket select
on all PushSession sockets. If any data is received, parses and
forwards it on to the callback function. If the callback is
successful, a PublishMessageReceived message is sent. | devicecloud/monitor_tcp.py | def _select(self):
"""
While the client is not marked as closed, performs a socket select
on all PushSession sockets. If any data is received, parses and
forwards it on to the callback function. If the callback is
successful, a PublishMessageReceived message is sent.
""... | def _select(self):
"""
While the client is not marked as closed, performs a socket select
on all PushSession sockets. If any data is received, parses and
forwards it on to the callback function. If the callback is
successful, a PublishMessageReceived message is sent.
""... | [
"While",
"the",
"client",
"is",
"not",
"marked",
"as",
"closed",
"performs",
"a",
"socket",
"select",
"on",
"all",
"PushSession",
"sockets",
".",
"If",
"any",
"data",
"is",
"received",
"parses",
"and",
"forwards",
"it",
"on",
"to",
"the",
"callback",
"func... | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L445-L528 | [
"def",
"_select",
"(",
"self",
")",
":",
"try",
":",
"while",
"not",
"self",
".",
"closed",
":",
"try",
":",
"inputready",
"=",
"select",
".",
"select",
"(",
"self",
".",
"sessions",
".",
"keys",
"(",
")",
",",
"[",
"]",
",",
"[",
"]",
",",
"0.... | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager._init_threads | Initializes the IO and Writer threads | devicecloud/monitor_tcp.py | def _init_threads(self):
"""Initializes the IO and Writer threads"""
if self._io_thread is None:
self._io_thread = Thread(target=self._select)
self._io_thread.start()
if self._writer_thread is None:
self._writer_thread = Thread(target=self._writer)
... | def _init_threads(self):
"""Initializes the IO and Writer threads"""
if self._io_thread is None:
self._io_thread = Thread(target=self._select)
self._io_thread.start()
if self._writer_thread is None:
self._writer_thread = Thread(target=self._writer)
... | [
"Initializes",
"the",
"IO",
"and",
"Writer",
"threads"
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L530-L538 | [
"def",
"_init_threads",
"(",
"self",
")",
":",
"if",
"self",
".",
"_io_thread",
"is",
"None",
":",
"self",
".",
"_io_thread",
"=",
"Thread",
"(",
"target",
"=",
"self",
".",
"_select",
")",
"self",
".",
"_io_thread",
".",
"start",
"(",
")",
"if",
"se... | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager.create_session | Creates and Returns a PushSession instance based on the input monitor
and callback. When data is received, callback will be invoked.
If neither monitor or monitor_id are specified, throws an Exception.
:param callback: Callback function to call when PublishMessage
messages are rece... | devicecloud/monitor_tcp.py | def create_session(self, callback, monitor_id):
"""
Creates and Returns a PushSession instance based on the input monitor
and callback. When data is received, callback will be invoked.
If neither monitor or monitor_id are specified, throws an Exception.
:param callback: Callbac... | def create_session(self, callback, monitor_id):
"""
Creates and Returns a PushSession instance based on the input monitor
and callback. When data is received, callback will be invoked.
If neither monitor or monitor_id are specified, throws an Exception.
:param callback: Callbac... | [
"Creates",
"and",
"Returns",
"a",
"PushSession",
"instance",
"based",
"on",
"the",
"input",
"monitor",
"and",
"callback",
".",
"When",
"data",
"is",
"received",
"callback",
"will",
"be",
"invoked",
".",
"If",
"neither",
"monitor",
"or",
"monitor_id",
"are",
... | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L540-L562 | [
"def",
"create_session",
"(",
"self",
",",
"callback",
",",
"monitor_id",
")",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Creating Session for Monitor %s.\"",
"%",
"monitor_id",
")",
"session",
"=",
"SecurePushSession",
"(",
"callback",
",",
"monitor_id",
","... | 32529684a348a7830a269c32601604c78036bcb8 |
train | TCPClientManager.stop | Stops all session activity.
Blocks until io and writer thread dies | devicecloud/monitor_tcp.py | def stop(self):
"""Stops all session activity.
Blocks until io and writer thread dies
"""
if self._io_thread is not None:
self.log.info("Waiting for I/O thread to stop...")
self.closed = True
self._io_thread.join()
if self._writer_thread is n... | def stop(self):
"""Stops all session activity.
Blocks until io and writer thread dies
"""
if self._io_thread is not None:
self.log.info("Waiting for I/O thread to stop...")
self.closed = True
self._io_thread.join()
if self._writer_thread is n... | [
"Stops",
"all",
"session",
"activity",
"."
] | digidotcom/python-devicecloud | python | https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor_tcp.py#L564-L579 | [
"def",
"stop",
"(",
"self",
")",
":",
"if",
"self",
".",
"_io_thread",
"is",
"not",
"None",
":",
"self",
".",
"log",
".",
"info",
"(",
"\"Waiting for I/O thread to stop...\"",
")",
"self",
".",
"closed",
"=",
"True",
"self",
".",
"_io_thread",
".",
"join... | 32529684a348a7830a269c32601604c78036bcb8 |
train | plotF0 | Plots the original data in a graph above the plot of the dtw'ed data | promo/morph_utils/plot_morphed_data.py | def plotF0(fromTuple, toTuple, mergeTupleList, fnFullPath):
'''
Plots the original data in a graph above the plot of the dtw'ed data
'''
_matplotlibCheck()
plt.hold(True)
fig, (ax0) = plt.subplots(nrows=1)
# Old data
plot1 = ax0.plot(fromTuple[0], fromTuple[1], color='red',
... | def plotF0(fromTuple, toTuple, mergeTupleList, fnFullPath):
'''
Plots the original data in a graph above the plot of the dtw'ed data
'''
_matplotlibCheck()
plt.hold(True)
fig, (ax0) = plt.subplots(nrows=1)
# Old data
plot1 = ax0.plot(fromTuple[0], fromTuple[1], color='red',
... | [
"Plots",
"the",
"original",
"data",
"in",
"a",
"graph",
"above",
"the",
"plot",
"of",
"the",
"dtw",
"ed",
"data"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/plot_morphed_data.py#L74-L109 | [
"def",
"plotF0",
"(",
"fromTuple",
",",
"toTuple",
",",
"mergeTupleList",
",",
"fnFullPath",
")",
":",
"_matplotlibCheck",
"(",
")",
"plt",
".",
"hold",
"(",
"True",
")",
"fig",
",",
"(",
"ax0",
")",
"=",
"plt",
".",
"subplots",
"(",
"nrows",
"=",
"1... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | getPitchForIntervals | Preps data for use in f0Morph | promo/f0_morph.py | def getPitchForIntervals(data, tgFN, tierName):
'''
Preps data for use in f0Morph
'''
tg = tgio.openTextgrid(tgFN)
data = tg.tierDict[tierName].getValuesInIntervals(data)
data = [dataList for _, dataList in data]
return data | def getPitchForIntervals(data, tgFN, tierName):
'''
Preps data for use in f0Morph
'''
tg = tgio.openTextgrid(tgFN)
data = tg.tierDict[tierName].getValuesInIntervals(data)
data = [dataList for _, dataList in data]
return data | [
"Preps",
"data",
"for",
"use",
"in",
"f0Morph"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/f0_morph.py#L35-L43 | [
"def",
"getPitchForIntervals",
"(",
"data",
",",
"tgFN",
",",
"tierName",
")",
":",
"tg",
"=",
"tgio",
".",
"openTextgrid",
"(",
"tgFN",
")",
"data",
"=",
"tg",
".",
"tierDict",
"[",
"tierName",
"]",
".",
"getValuesInIntervals",
"(",
"data",
")",
"data",... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | f0Morph | Resynthesizes the pitch track from a source to a target wav file
fromPitchData and toPitchData should be segmented according to the
portions that you want to morph. The two lists must have the same
number of sublists.
Occurs over a three-step process.
This function can act as a template for how ... | promo/f0_morph.py | def f0Morph(fromWavFN, pitchPath, stepList,
outputName, doPlotPitchSteps, fromPitchData, toPitchData,
outputMinPitch, outputMaxPitch, praatEXE, keepPitchRange=False,
keepAveragePitch=False, sourcePitchDataList=None,
minIntervalLength=0.3):
'''
Resynthesizes the pi... | def f0Morph(fromWavFN, pitchPath, stepList,
outputName, doPlotPitchSteps, fromPitchData, toPitchData,
outputMinPitch, outputMaxPitch, praatEXE, keepPitchRange=False,
keepAveragePitch=False, sourcePitchDataList=None,
minIntervalLength=0.3):
'''
Resynthesizes the pi... | [
"Resynthesizes",
"the",
"pitch",
"track",
"from",
"a",
"source",
"to",
"a",
"target",
"wav",
"file"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/f0_morph.py#L46-L156 | [
"def",
"f0Morph",
"(",
"fromWavFN",
",",
"pitchPath",
",",
"stepList",
",",
"outputName",
",",
"doPlotPitchSteps",
",",
"fromPitchData",
",",
"toPitchData",
",",
"outputMinPitch",
",",
"outputMaxPitch",
",",
"praatEXE",
",",
"keepPitchRange",
"=",
"False",
",",
... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | decode | Converts text in the numbering format of pinyin ("ni3hao3") to text with the
appropriate tone marks ("nǐhǎo"). | mafan/pinyin.py | def decode(s):
"""
Converts text in the numbering format of pinyin ("ni3hao3") to text with the
appropriate tone marks ("nǐhǎo").
"""
s = s.lower()
r = ""
t = ""
for c in s:
if c >= 'a' and c <= 'z':
t += c
elif c == ':':
try:
if ... | def decode(s):
"""
Converts text in the numbering format of pinyin ("ni3hao3") to text with the
appropriate tone marks ("nǐhǎo").
"""
s = s.lower()
r = ""
t = ""
for c in s:
if c >= 'a' and c <= 'z':
t += c
elif c == ':':
try:
if ... | [
"Converts",
"text",
"in",
"the",
"numbering",
"format",
"of",
"pinyin",
"(",
"ni3hao3",
")",
"to",
"text",
"with",
"the",
"appropriate",
"tone",
"marks",
"(",
"nǐhǎo",
")",
"."
] | hermanschaaf/mafan | python | https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/pinyin.py#L14-L57 | [
"def",
"decode",
"(",
"s",
")",
":",
"s",
"=",
"s",
".",
"lower",
"(",
")",
"r",
"=",
"\"\"",
"t",
"=",
"\"\"",
"for",
"c",
"in",
"s",
":",
"if",
"c",
">=",
"'a'",
"and",
"c",
"<=",
"'z'",
":",
"t",
"+=",
"c",
"elif",
"c",
"==",
"':'",
... | 373ddf299aeb2bd8413bf921c71768af7a8170ea |
train | PitchAccent.adjustPeakHeight | Adjust peak height
The foot of the accent is left unchanged and intermediate
values are linearly scaled | promo/morph_utils/modify_pitch_accent.py | def adjustPeakHeight(self, heightAmount):
'''
Adjust peak height
The foot of the accent is left unchanged and intermediate
values are linearly scaled
'''
if heightAmount == 0:
return
pitchList = [f0V for _, f0V in self.pointList]
... | def adjustPeakHeight(self, heightAmount):
'''
Adjust peak height
The foot of the accent is left unchanged and intermediate
values are linearly scaled
'''
if heightAmount == 0:
return
pitchList = [f0V for _, f0V in self.pointList]
... | [
"Adjust",
"peak",
"height",
"The",
"foot",
"of",
"the",
"accent",
"is",
"left",
"unchanged",
"and",
"intermediate",
"values",
"are",
"linearly",
"scaled"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L47-L63 | [
"def",
"adjustPeakHeight",
"(",
"self",
",",
"heightAmount",
")",
":",
"if",
"heightAmount",
"==",
"0",
":",
"return",
"pitchList",
"=",
"[",
"f0V",
"for",
"_",
",",
"f0V",
"in",
"self",
".",
"pointList",
"]",
"minV",
"=",
"min",
"(",
"pitchList",
")",... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | PitchAccent.addPlateau | Add a plateau
A negative plateauAmount will move the peak backwards.
A positive plateauAmount will move the peak forwards.
All points on the side of the peak growth will also get moved.
i.e. the slope of the peak does not change. The accent gets
wider instead.
... | promo/morph_utils/modify_pitch_accent.py | def addPlateau(self, plateauAmount, pitchSampFreq=None):
'''
Add a plateau
A negative plateauAmount will move the peak backwards.
A positive plateauAmount will move the peak forwards.
All points on the side of the peak growth will also get moved.
i.e. th... | def addPlateau(self, plateauAmount, pitchSampFreq=None):
'''
Add a plateau
A negative plateauAmount will move the peak backwards.
A positive plateauAmount will move the peak forwards.
All points on the side of the peak growth will also get moved.
i.e. th... | [
"Add",
"a",
"plateau",
"A",
"negative",
"plateauAmount",
"will",
"move",
"the",
"peak",
"backwards",
".",
"A",
"positive",
"plateauAmount",
"will",
"move",
"the",
"peak",
"forwards",
".",
"All",
"points",
"on",
"the",
"side",
"of",
"the",
"peak",
"growth",
... | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L65-L114 | [
"def",
"addPlateau",
"(",
"self",
",",
"plateauAmount",
",",
"pitchSampFreq",
"=",
"None",
")",
":",
"if",
"plateauAmount",
"==",
"0",
":",
"return",
"maxPoint",
"=",
"self",
".",
"pointList",
"[",
"self",
".",
"peakI",
"]",
"# Define the plateau",
"if",
"... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | PitchAccent.shiftAccent | Move the whole accent earlier or later | promo/morph_utils/modify_pitch_accent.py | def shiftAccent(self, shiftAmount):
'''
Move the whole accent earlier or later
'''
if shiftAmount == 0:
return
self.pointList = [(time + shiftAmount, pitch)
for time, pitch in self.pointList]
# Update shift amounts
... | def shiftAccent(self, shiftAmount):
'''
Move the whole accent earlier or later
'''
if shiftAmount == 0:
return
self.pointList = [(time + shiftAmount, pitch)
for time, pitch in self.pointList]
# Update shift amounts
... | [
"Move",
"the",
"whole",
"accent",
"earlier",
"or",
"later"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L116-L130 | [
"def",
"shiftAccent",
"(",
"self",
",",
"shiftAmount",
")",
":",
"if",
"shiftAmount",
"==",
"0",
":",
"return",
"self",
".",
"pointList",
"=",
"[",
"(",
"time",
"+",
"shiftAmount",
",",
"pitch",
")",
"for",
"time",
",",
"pitch",
"in",
"self",
".",
"p... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | PitchAccent.deleteOverlapping | Erase points from another list that overlap with points in this list | promo/morph_utils/modify_pitch_accent.py | def deleteOverlapping(self, targetList):
'''
Erase points from another list that overlap with points in this list
'''
start = self.pointList[0][0]
stop = self.pointList[-1][0]
if self.netLeftShift < 0:
start += self.netLeftShift
i... | def deleteOverlapping(self, targetList):
'''
Erase points from another list that overlap with points in this list
'''
start = self.pointList[0][0]
stop = self.pointList[-1][0]
if self.netLeftShift < 0:
start += self.netLeftShift
i... | [
"Erase",
"points",
"from",
"another",
"list",
"that",
"overlap",
"with",
"points",
"in",
"this",
"list"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L132-L147 | [
"def",
"deleteOverlapping",
"(",
"self",
",",
"targetList",
")",
":",
"start",
"=",
"self",
".",
"pointList",
"[",
"0",
"]",
"[",
"0",
"]",
"stop",
"=",
"self",
".",
"pointList",
"[",
"-",
"1",
"]",
"[",
"0",
"]",
"if",
"self",
".",
"netLeftShift",... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | PitchAccent.reintegrate | Integrates the pitch values of the accent into a larger pitch contour | promo/morph_utils/modify_pitch_accent.py | def reintegrate(self, fullPointList):
'''
Integrates the pitch values of the accent into a larger pitch contour
'''
# Erase the original region of the accent
fullPointList = _deletePoints(fullPointList, self.minT, self.maxT)
# Erase the new region of the accent
... | def reintegrate(self, fullPointList):
'''
Integrates the pitch values of the accent into a larger pitch contour
'''
# Erase the original region of the accent
fullPointList = _deletePoints(fullPointList, self.minT, self.maxT)
# Erase the new region of the accent
... | [
"Integrates",
"the",
"pitch",
"values",
"of",
"the",
"accent",
"into",
"a",
"larger",
"pitch",
"contour"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/modify_pitch_accent.py#L149-L163 | [
"def",
"reintegrate",
"(",
"self",
",",
"fullPointList",
")",
":",
"# Erase the original region of the accent",
"fullPointList",
"=",
"_deletePoints",
"(",
"fullPointList",
",",
"self",
".",
"minT",
",",
"self",
".",
"maxT",
")",
"# Erase the new region of the accent",
... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | convert | Convert file with crappy encoding to a new proper encoding (or vice versa if you wish).
filename -- the name, partial path or full path of the file you want to encode to a new encoding
new_filename -- (optional) the name of the new file to be generated using the new encoding
overwrite -- if `new_filename` ... | mafan/encoding.py | def convert(filename, new_filename=None, overwrite=False, to_encoding='utf-8', force=True):
""" Convert file with crappy encoding to a new proper encoding (or vice versa if you wish).
filename -- the name, partial path or full path of the file you want to encode to a new encoding
new_filename -- (optional)... | def convert(filename, new_filename=None, overwrite=False, to_encoding='utf-8', force=True):
""" Convert file with crappy encoding to a new proper encoding (or vice versa if you wish).
filename -- the name, partial path or full path of the file you want to encode to a new encoding
new_filename -- (optional)... | [
"Convert",
"file",
"with",
"crappy",
"encoding",
"to",
"a",
"new",
"proper",
"encoding",
"(",
"or",
"vice",
"versa",
"if",
"you",
"wish",
")",
"."
] | hermanschaaf/mafan | python | https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/encoding.py#L17-L64 | [
"def",
"convert",
"(",
"filename",
",",
"new_filename",
"=",
"None",
",",
"overwrite",
"=",
"False",
",",
"to_encoding",
"=",
"'utf-8'",
",",
"force",
"=",
"True",
")",
":",
"logging",
".",
"info",
"(",
"'Opening file %s'",
"%",
"filename",
")",
"f",
"="... | 373ddf299aeb2bd8413bf921c71768af7a8170ea |
train | detect | Detect the encoding of a file.
Returns only the predicted current encoding as a string.
If `include_confidence` is True,
Returns tuple containing: (str encoding, float confidence) | mafan/encoding.py | def detect(filename, include_confidence=False):
"""
Detect the encoding of a file.
Returns only the predicted current encoding as a string.
If `include_confidence` is True,
Returns tuple containing: (str encoding, float confidence)
"""
f = open(filename)
detection = chardet.detect(f.r... | def detect(filename, include_confidence=False):
"""
Detect the encoding of a file.
Returns only the predicted current encoding as a string.
If `include_confidence` is True,
Returns tuple containing: (str encoding, float confidence)
"""
f = open(filename)
detection = chardet.detect(f.r... | [
"Detect",
"the",
"encoding",
"of",
"a",
"file",
"."
] | hermanschaaf/mafan | python | https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/encoding.py#L67-L83 | [
"def",
"detect",
"(",
"filename",
",",
"include_confidence",
"=",
"False",
")",
":",
"f",
"=",
"open",
"(",
"filename",
")",
"detection",
"=",
"chardet",
".",
"detect",
"(",
"f",
".",
"read",
"(",
")",
")",
"f",
".",
"close",
"(",
")",
"encoding",
... | 373ddf299aeb2bd8413bf921c71768af7a8170ea |
train | download | Utility function for downloading files from the web
and retaining the same filename. | mafan/download_data.py | def download(url, localFileName=None, localDirName=None):
"""
Utility function for downloading files from the web
and retaining the same filename.
"""
localName = url2name(url)
req = Request(url)
r = urlopen(req)
if r.info().has_key('Content-Disposition'):
# If the response has ... | def download(url, localFileName=None, localDirName=None):
"""
Utility function for downloading files from the web
and retaining the same filename.
"""
localName = url2name(url)
req = Request(url)
r = urlopen(req)
if r.info().has_key('Content-Disposition'):
# If the response has ... | [
"Utility",
"function",
"for",
"downloading",
"files",
"from",
"the",
"web",
"and",
"retaining",
"the",
"same",
"filename",
"."
] | hermanschaaf/mafan | python | https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/download_data.py#L22-L53 | [
"def",
"download",
"(",
"url",
",",
"localFileName",
"=",
"None",
",",
"localDirName",
"=",
"None",
")",
":",
"localName",
"=",
"url2name",
"(",
"url",
")",
"req",
"=",
"Request",
"(",
"url",
")",
"r",
"=",
"urlopen",
"(",
"req",
")",
"if",
"r",
".... | 373ddf299aeb2bd8413bf921c71768af7a8170ea |
train | _t | This is a unexposed function, is responsibility for translation internal. | mafan/third_party/jianfan/__init__.py | def _t(unistr, charset_from, charset_to):
"""
This is a unexposed function, is responsibility for translation internal.
"""
# if type(unistr) is str:
# try:
# unistr = unistr.decode('utf-8')
# # Python 3 returns AttributeError when .decode() is called on a str
# #... | def _t(unistr, charset_from, charset_to):
"""
This is a unexposed function, is responsibility for translation internal.
"""
# if type(unistr) is str:
# try:
# unistr = unistr.decode('utf-8')
# # Python 3 returns AttributeError when .decode() is called on a str
# #... | [
"This",
"is",
"a",
"unexposed",
"function",
"is",
"responsibility",
"for",
"translation",
"internal",
"."
] | hermanschaaf/mafan | python | https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/third_party/jianfan/__init__.py#L23-L45 | [
"def",
"_t",
"(",
"unistr",
",",
"charset_from",
",",
"charset_to",
")",
":",
"# if type(unistr) is str:",
"# try:",
"# unistr = unistr.decode('utf-8')",
"# # Python 3 returns AttributeError when .decode() is called on a str",
"# # This means it is already unicode.",
... | 373ddf299aeb2bd8413bf921c71768af7a8170ea |
train | identify | Identify whether a string is simplified or traditional Chinese.
Returns:
None: if there are no recognizd Chinese characters.
EITHER: if the test is inconclusive.
TRAD: if the text is traditional.
SIMP: if the text is simplified.
BOTH: the text has characters recognized as be... | mafan/hanzidentifier/hanzidentifier.py | def identify(text):
"""Identify whether a string is simplified or traditional Chinese.
Returns:
None: if there are no recognizd Chinese characters.
EITHER: if the test is inconclusive.
TRAD: if the text is traditional.
SIMP: if the text is simplified.
BOTH: the text has ... | def identify(text):
"""Identify whether a string is simplified or traditional Chinese.
Returns:
None: if there are no recognizd Chinese characters.
EITHER: if the test is inconclusive.
TRAD: if the text is traditional.
SIMP: if the text is simplified.
BOTH: the text has ... | [
"Identify",
"whether",
"a",
"string",
"is",
"simplified",
"or",
"traditional",
"Chinese",
"."
] | hermanschaaf/mafan | python | https://github.com/hermanschaaf/mafan/blob/373ddf299aeb2bd8413bf921c71768af7a8170ea/mafan/hanzidentifier/hanzidentifier.py#L38-L60 | [
"def",
"identify",
"(",
"text",
")",
":",
"filtered_text",
"=",
"set",
"(",
"list",
"(",
"text",
")",
")",
".",
"intersection",
"(",
"ALL_CHARS",
")",
"if",
"len",
"(",
"filtered_text",
")",
"is",
"0",
":",
"return",
"None",
"if",
"filtered_text",
".",... | 373ddf299aeb2bd8413bf921c71768af7a8170ea |
train | makeSequenceRelative | Puts every value in a list on a continuum between 0 and 1
Also returns the min and max values (to reverse the process) | promo/morph_utils/morph_sequence.py | def makeSequenceRelative(absVSequence):
'''
Puts every value in a list on a continuum between 0 and 1
Also returns the min and max values (to reverse the process)
'''
if len(absVSequence) < 2 or len(set(absVSequence)) == 1:
raise RelativizeSequenceException(absVSequence)
minV = min(ab... | def makeSequenceRelative(absVSequence):
'''
Puts every value in a list on a continuum between 0 and 1
Also returns the min and max values (to reverse the process)
'''
if len(absVSequence) < 2 or len(set(absVSequence)) == 1:
raise RelativizeSequenceException(absVSequence)
minV = min(ab... | [
"Puts",
"every",
"value",
"in",
"a",
"list",
"on",
"a",
"continuum",
"between",
"0",
"and",
"1"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L33-L47 | [
"def",
"makeSequenceRelative",
"(",
"absVSequence",
")",
":",
"if",
"len",
"(",
"absVSequence",
")",
"<",
"2",
"or",
"len",
"(",
"set",
"(",
"absVSequence",
")",
")",
"==",
"1",
":",
"raise",
"RelativizeSequenceException",
"(",
"absVSequence",
")",
"minV",
... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | makeSequenceAbsolute | Makes every value in a sequence absolute | promo/morph_utils/morph_sequence.py | def makeSequenceAbsolute(relVSequence, minV, maxV):
'''
Makes every value in a sequence absolute
'''
return [(value * (maxV - minV)) + minV for value in relVSequence] | def makeSequenceAbsolute(relVSequence, minV, maxV):
'''
Makes every value in a sequence absolute
'''
return [(value * (maxV - minV)) + minV for value in relVSequence] | [
"Makes",
"every",
"value",
"in",
"a",
"sequence",
"absolute"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L50-L55 | [
"def",
"makeSequenceAbsolute",
"(",
"relVSequence",
",",
"minV",
",",
"maxV",
")",
":",
"return",
"[",
"(",
"value",
"*",
"(",
"maxV",
"-",
"minV",
")",
")",
"+",
"minV",
"for",
"value",
"in",
"relVSequence",
"]"
] | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | _makeTimingRelative | Given normal pitch tier data, puts the times on a scale from 0 to 1
Input is a list of tuples of the form
([(time1, pitch1), (time2, pitch2),...]
Also returns the start and end time so that the process can be reversed | promo/morph_utils/morph_sequence.py | def _makeTimingRelative(absoluteDataList):
'''
Given normal pitch tier data, puts the times on a scale from 0 to 1
Input is a list of tuples of the form
([(time1, pitch1), (time2, pitch2),...]
Also returns the start and end time so that the process can be reversed
'''
timingSeq = [row[0] ... | def _makeTimingRelative(absoluteDataList):
'''
Given normal pitch tier data, puts the times on a scale from 0 to 1
Input is a list of tuples of the form
([(time1, pitch1), (time2, pitch2),...]
Also returns the start and end time so that the process can be reversed
'''
timingSeq = [row[0] ... | [
"Given",
"normal",
"pitch",
"tier",
"data",
"puts",
"the",
"times",
"on",
"a",
"scale",
"from",
"0",
"to",
"1"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L58-L76 | [
"def",
"_makeTimingRelative",
"(",
"absoluteDataList",
")",
":",
"timingSeq",
"=",
"[",
"row",
"[",
"0",
"]",
"for",
"row",
"in",
"absoluteDataList",
"]",
"valueSeq",
"=",
"[",
"list",
"(",
"row",
"[",
"1",
":",
"]",
")",
"for",
"row",
"in",
"absoluteD... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
train | _makeTimingAbsolute | Maps values from 0 to 1 to the provided start and end time
Input is a list of tuples of the form
([(time1, pitch1), (time2, pitch2),...] | promo/morph_utils/morph_sequence.py | def _makeTimingAbsolute(relativeDataList, startTime, endTime):
'''
Maps values from 0 to 1 to the provided start and end time
Input is a list of tuples of the form
([(time1, pitch1), (time2, pitch2),...]
'''
timingSeq = [row[0] for row in relativeDataList]
valueSeq = [list(row[1:]) for row... | def _makeTimingAbsolute(relativeDataList, startTime, endTime):
'''
Maps values from 0 to 1 to the provided start and end time
Input is a list of tuples of the form
([(time1, pitch1), (time2, pitch2),...]
'''
timingSeq = [row[0] for row in relativeDataList]
valueSeq = [list(row[1:]) for row... | [
"Maps",
"values",
"from",
"0",
"to",
"1",
"to",
"the",
"provided",
"start",
"and",
"end",
"time"
] | timmahrt/ProMo | python | https://github.com/timmahrt/ProMo/blob/99d9f5cc01ff328a62973c5a5da910cc905ae4d5/promo/morph_utils/morph_sequence.py#L79-L95 | [
"def",
"_makeTimingAbsolute",
"(",
"relativeDataList",
",",
"startTime",
",",
"endTime",
")",
":",
"timingSeq",
"=",
"[",
"row",
"[",
"0",
"]",
"for",
"row",
"in",
"relativeDataList",
"]",
"valueSeq",
"=",
"[",
"list",
"(",
"row",
"[",
"1",
":",
"]",
"... | 99d9f5cc01ff328a62973c5a5da910cc905ae4d5 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.