repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
JnyJny/Geometry
Geometry/triangle.py
Triangle.random
def random(cls, origin=None, radius=1): ''' :origin: - optional Point subclass :radius: - optional float :return: Triangle Creates a triangle with random coordinates in the circle described by (origin,radius). If origin is unspecified, (0,0) is assumed. If the r...
python
def random(cls, origin=None, radius=1): ''' :origin: - optional Point subclass :radius: - optional float :return: Triangle Creates a triangle with random coordinates in the circle described by (origin,radius). If origin is unspecified, (0,0) is assumed. If the r...
[ "def", "random", "(", "cls", ",", "origin", "=", "None", ",", "radius", "=", "1", ")", ":", "# XXX no collinearity checks, possible to generate a", "# line (not likely, just possible).", "#", "pts", "=", "set", "(", ")", "while", "len", "(", "pts", ")", "<",...
:origin: - optional Point subclass :radius: - optional float :return: Triangle Creates a triangle with random coordinates in the circle described by (origin,radius). If origin is unspecified, (0,0) is assumed. If the radius is unspecified, 1.0 is assumed.
[ ":", "origin", ":", "-", "optional", "Point", "subclass", ":", "radius", ":", "-", "optional", "float", ":", "return", ":", "Triangle" ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L47-L65
JnyJny/Geometry
Geometry/triangle.py
Triangle.equilateral
def equilateral(cls, origin=None, side=1): ''' :origin: optional Point :side: optional float describing triangle side length :return: Triangle initialized with points comprising a equilateral triangle. XXX equilateral triangle definition ''' o =...
python
def equilateral(cls, origin=None, side=1): ''' :origin: optional Point :side: optional float describing triangle side length :return: Triangle initialized with points comprising a equilateral triangle. XXX equilateral triangle definition ''' o =...
[ "def", "equilateral", "(", "cls", ",", "origin", "=", "None", ",", "side", "=", "1", ")", ":", "o", "=", "Point", "(", "origin", ")", "base", "=", "o", ".", "x", "+", "side", "h", "=", "0.5", "*", "Sqrt_3", "*", "side", "+", "o", ".", "y", ...
:origin: optional Point :side: optional float describing triangle side length :return: Triangle initialized with points comprising a equilateral triangle. XXX equilateral triangle definition
[ ":", "origin", ":", "optional", "Point", ":", "side", ":", "optional", "float", "describing", "triangle", "side", "length", ":", "return", ":", "Triangle", "initialized", "with", "points", "comprising", "a", "equilateral", "triangle", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L68-L83
JnyJny/Geometry
Geometry/triangle.py
Triangle.isosceles
def isosceles(cls, origin=None, base=1, alpha=90): ''' :origin: optional Point :base: optional float describing triangle base length :return: Triangle initialized with points comprising a isosceles triangle. XXX isoceles triangle definition ''' ...
python
def isosceles(cls, origin=None, base=1, alpha=90): ''' :origin: optional Point :base: optional float describing triangle base length :return: Triangle initialized with points comprising a isosceles triangle. XXX isoceles triangle definition ''' ...
[ "def", "isosceles", "(", "cls", ",", "origin", "=", "None", ",", "base", "=", "1", ",", "alpha", "=", "90", ")", ":", "o", "=", "Point", "(", "origin", ")", "base", "=", "o", ".", "x", "+", "base", "return", "cls", "(", "o", ",", "[", "base",...
:origin: optional Point :base: optional float describing triangle base length :return: Triangle initialized with points comprising a isosceles triangle. XXX isoceles triangle definition
[ ":", "origin", ":", "optional", "Point", ":", "base", ":", "optional", "float", "describing", "triangle", "base", "length", ":", "return", ":", "Triangle", "initialized", "with", "points", "comprising", "a", "isosceles", "triangle", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L87-L100
JnyJny/Geometry
Geometry/triangle.py
Triangle.C
def C(self): ''' Third vertex of triangle, Point subclass. ''' try: return self._C except AttributeError: pass self._C = Point(0, 1) return self._C
python
def C(self): ''' Third vertex of triangle, Point subclass. ''' try: return self._C except AttributeError: pass self._C = Point(0, 1) return self._C
[ "def", "C", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_C", "except", "AttributeError", ":", "pass", "self", ".", "_C", "=", "Point", "(", "0", ",", "1", ")", "return", "self", ".", "_C" ]
Third vertex of triangle, Point subclass.
[ "Third", "vertex", "of", "triangle", "Point", "subclass", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L216-L226
JnyJny/Geometry
Geometry/triangle.py
Triangle.ABC
def ABC(self): ''' A list of the triangle's vertices, list. ''' try: return self._ABC except AttributeError: pass self._ABC = [self.A, self.B, self.C] return self._ABC
python
def ABC(self): ''' A list of the triangle's vertices, list. ''' try: return self._ABC except AttributeError: pass self._ABC = [self.A, self.B, self.C] return self._ABC
[ "def", "ABC", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_ABC", "except", "AttributeError", ":", "pass", "self", ".", "_ABC", "=", "[", "self", ".", "A", ",", "self", ".", "B", ",", "self", ".", "C", "]", "return", "self", ".", ...
A list of the triangle's vertices, list.
[ "A", "list", "of", "the", "triangle", "s", "vertices", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L233-L243
JnyJny/Geometry
Geometry/triangle.py
Triangle.BA
def BA(self): ''' Vertices B and A, list. ''' try: return self._BA except AttributeError: pass self._BA = [self.B, self.A] return self._BA
python
def BA(self): ''' Vertices B and A, list. ''' try: return self._BA except AttributeError: pass self._BA = [self.B, self.A] return self._BA
[ "def", "BA", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_BA", "except", "AttributeError", ":", "pass", "self", ".", "_BA", "=", "[", "self", ".", "B", ",", "self", ".", "A", "]", "return", "self", ".", "_BA" ]
Vertices B and A, list.
[ "Vertices", "B", "and", "A", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L267-L277
JnyJny/Geometry
Geometry/triangle.py
Triangle.AC
def AC(self): ''' Vertices A and C, list. ''' try: return self._AC except AttributeError: pass self._AC = [self.A, self.C] return self._AC
python
def AC(self): ''' Vertices A and C, list. ''' try: return self._AC except AttributeError: pass self._AC = [self.A, self.C] return self._AC
[ "def", "AC", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_AC", "except", "AttributeError", ":", "pass", "self", ".", "_AC", "=", "[", "self", ".", "A", ",", "self", ".", "C", "]", "return", "self", ".", "_AC" ]
Vertices A and C, list.
[ "Vertices", "A", "and", "C", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L284-L294
JnyJny/Geometry
Geometry/triangle.py
Triangle.CA
def CA(self): ''' Vertices C and A, list. ''' try: return self._CA except AttributeError: pass self._CA = [self.C, self.A] return self._CA
python
def CA(self): ''' Vertices C and A, list. ''' try: return self._CA except AttributeError: pass self._CA = [self.C, self.A] return self._CA
[ "def", "CA", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_CA", "except", "AttributeError", ":", "pass", "self", ".", "_CA", "=", "[", "self", ".", "C", ",", "self", ".", "A", "]", "return", "self", ".", "_CA" ]
Vertices C and A, list.
[ "Vertices", "C", "and", "A", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L301-L311
JnyJny/Geometry
Geometry/triangle.py
Triangle.BC
def BC(self): ''' Vertices B and C, list. ''' try: return self._BC except AttributeError: pass self._BC = [self.B, self.C] return self._BC
python
def BC(self): ''' Vertices B and C, list. ''' try: return self._BC except AttributeError: pass self._BC = [self.B, self.C] return self._BC
[ "def", "BC", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_BC", "except", "AttributeError", ":", "pass", "self", ".", "_BC", "=", "[", "self", ".", "B", ",", "self", ".", "C", "]", "return", "self", ".", "_BC" ]
Vertices B and C, list.
[ "Vertices", "B", "and", "C", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L318-L328
JnyJny/Geometry
Geometry/triangle.py
Triangle.CB
def CB(self): ''' Vertices C and B, list. ''' try: return self._CB except AttributeError: pass self._CB = [self.C, self.B] return self._CB
python
def CB(self): ''' Vertices C and B, list. ''' try: return self._CB except AttributeError: pass self._CB = [self.C, self.B] return self._CB
[ "def", "CB", "(", "self", ")", ":", "try", ":", "return", "self", ".", "_CB", "except", "AttributeError", ":", "pass", "self", ".", "_CB", "=", "[", "self", ".", "C", ",", "self", ".", "B", "]", "return", "self", ".", "_CB" ]
Vertices C and B, list.
[ "Vertices", "C", "and", "B", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L335-L345
JnyJny/Geometry
Geometry/triangle.py
Triangle.segments
def segments(self): ''' A list of the Triangle's line segments [AB, BC, AC], list. ''' return [Segment(self.AB), Segment(self.BC), Segment(self.AC)]
python
def segments(self): ''' A list of the Triangle's line segments [AB, BC, AC], list. ''' return [Segment(self.AB), Segment(self.BC), Segment(self.AC)]
[ "def", "segments", "(", "self", ")", ":", "return", "[", "Segment", "(", "self", ".", "AB", ")", ",", "Segment", "(", "self", ".", "BC", ")", ",", "Segment", "(", "self", ".", "AC", ")", "]" ]
A list of the Triangle's line segments [AB, BC, AC], list.
[ "A", "list", "of", "the", "Triangle", "s", "line", "segments", "[", "AB", "BC", "AC", "]", "list", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L364-L371
JnyJny/Geometry
Geometry/triangle.py
Triangle.circumcenter
def circumcenter(self): ''' The intersection of the median perpendicular bisectors, Point. The center of the circumscribed circle, which is the circle that passes through all vertices of the triangle. https://en.wikipedia.org/wiki/Circumscribed_circle#Cartesian_coordinates_2 ...
python
def circumcenter(self): ''' The intersection of the median perpendicular bisectors, Point. The center of the circumscribed circle, which is the circle that passes through all vertices of the triangle. https://en.wikipedia.org/wiki/Circumscribed_circle#Cartesian_coordinates_2 ...
[ "def", "circumcenter", "(", "self", ")", ":", "if", "self", ".", "isRight", ":", "return", "self", ".", "hypotenuse", ".", "midpoint", "if", "self", ".", "A", ".", "isOrigin", ":", "t", "=", "self", "else", ":", "# translate triangle to origin", "t", "="...
The intersection of the median perpendicular bisectors, Point. The center of the circumscribed circle, which is the circle that passes through all vertices of the triangle. https://en.wikipedia.org/wiki/Circumscribed_circle#Cartesian_coordinates_2 BUG: only finds the circumcenter in t...
[ "The", "intersection", "of", "the", "median", "perpendicular", "bisectors", "Point", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L424-L460
JnyJny/Geometry
Geometry/triangle.py
Triangle.altitudes
def altitudes(self): ''' A list of the altitudes of each vertex [AltA, AltB, AltC], list of floats. An altitude is the shortest distance from a vertex to the side opposite of it. ''' a = self.area * 2 return [a / self.a, a / self.b, a / self.c]
python
def altitudes(self): ''' A list of the altitudes of each vertex [AltA, AltB, AltC], list of floats. An altitude is the shortest distance from a vertex to the side opposite of it. ''' a = self.area * 2 return [a / self.a, a / self.b, a / self.c]
[ "def", "altitudes", "(", "self", ")", ":", "a", "=", "self", ".", "area", "*", "2", "return", "[", "a", "/", "self", ".", "a", ",", "a", "/", "self", ".", "b", ",", "a", "/", "self", ".", "c", "]" ]
A list of the altitudes of each vertex [AltA, AltB, AltC], list of floats. An altitude is the shortest distance from a vertex to the side opposite of it.
[ "A", "list", "of", "the", "altitudes", "of", "each", "vertex", "[", "AltA", "AltB", "AltC", "]", "list", "of", "floats", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L560-L571
JnyJny/Geometry
Geometry/triangle.py
Triangle.isEquilateral
def isEquilateral(self): ''' True if all sides of the triangle are the same length. All equilateral triangles are also isosceles. All equilateral triangles are also acute. ''' if not nearly_eq(self.a, self.b): return False if not nearly_eq(self.b, s...
python
def isEquilateral(self): ''' True if all sides of the triangle are the same length. All equilateral triangles are also isosceles. All equilateral triangles are also acute. ''' if not nearly_eq(self.a, self.b): return False if not nearly_eq(self.b, s...
[ "def", "isEquilateral", "(", "self", ")", ":", "if", "not", "nearly_eq", "(", "self", ".", "a", ",", "self", ".", "b", ")", ":", "return", "False", "if", "not", "nearly_eq", "(", "self", ".", "b", ",", "self", ".", "c", ")", ":", "return", "False...
True if all sides of the triangle are the same length. All equilateral triangles are also isosceles. All equilateral triangles are also acute.
[ "True", "if", "all", "sides", "of", "the", "triangle", "are", "the", "same", "length", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L629-L643
JnyJny/Geometry
Geometry/triangle.py
Triangle.swap
def swap(self, side='AB', inplace=False): ''' :side: - optional string :inplace: - optional boolean :return: Triangle with flipped side. The optional side paramater should have one of three values: AB, BC, or AC. Changes the order of the triangle's points, swapp...
python
def swap(self, side='AB', inplace=False): ''' :side: - optional string :inplace: - optional boolean :return: Triangle with flipped side. The optional side paramater should have one of three values: AB, BC, or AC. Changes the order of the triangle's points, swapp...
[ "def", "swap", "(", "self", ",", "side", "=", "'AB'", ",", "inplace", "=", "False", ")", ":", "try", ":", "flipset", "=", "{", "'AB'", ":", "(", "self", ".", "B", ".", "xyz", ",", "self", ".", "A", ".", "xyz", ",", "self", ".", "C", ".", "x...
:side: - optional string :inplace: - optional boolean :return: Triangle with flipped side. The optional side paramater should have one of three values: AB, BC, or AC. Changes the order of the triangle's points, swapping the specified points. Doing so will change the res...
[ ":", "side", ":", "-", "optional", "string", ":", "inplace", ":", "-", "optional", "boolean", ":", "return", ":", "Triangle", "with", "flipped", "side", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L789-L814
JnyJny/Geometry
Geometry/triangle.py
Triangle.doesIntersect
def doesIntersect(self, other): ''' :param: other - Triangle or Line subclass :return: boolean Returns True iff: Any segment in self intersects any segment in other. ''' otherType = type(other) if issubclass(otherType, Triangle): for s in...
python
def doesIntersect(self, other): ''' :param: other - Triangle or Line subclass :return: boolean Returns True iff: Any segment in self intersects any segment in other. ''' otherType = type(other) if issubclass(otherType, Triangle): for s in...
[ "def", "doesIntersect", "(", "self", ",", "other", ")", ":", "otherType", "=", "type", "(", "other", ")", "if", "issubclass", "(", "otherType", ",", "Triangle", ")", ":", "for", "s", "in", "self", ".", "segments", ".", "values", "(", ")", ":", "for",...
:param: other - Triangle or Line subclass :return: boolean Returns True iff: Any segment in self intersects any segment in other.
[ ":", "param", ":", "other", "-", "Triangle", "or", "Line", "subclass", ":", "return", ":", "boolean" ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/triangle.py#L816-L842
JnyJny/Geometry
Geometry/polygon.py
Polygon.perimeter
def perimeter(self): ''' Sum of the length of all sides, float. ''' return sum([a.distance(b) for a, b in self.pairs()])
python
def perimeter(self): ''' Sum of the length of all sides, float. ''' return sum([a.distance(b) for a, b in self.pairs()])
[ "def", "perimeter", "(", "self", ")", ":", "return", "sum", "(", "[", "a", ".", "distance", "(", "b", ")", "for", "a", ",", "b", "in", "self", ".", "pairs", "(", ")", "]", ")" ]
Sum of the length of all sides, float.
[ "Sum", "of", "the", "length", "of", "all", "sides", "float", "." ]
train
https://github.com/JnyJny/Geometry/blob/3500f815fa56c535b36d1b6fd0afe69ce5d055be/Geometry/polygon.py#L42-L46
dougalsutherland/vlfeat-ctypes
vlfeat/dsift.py
vl_dsift
def vl_dsift(data, fast=False, norm=False, bounds=None, size=3, step=1, window_size=None, float_descriptors=False, verbose=False, matlab_style=True): ''' Dense sift descriptors from an image. Returns: frames: num_frames x (2 or 3) matrix of x, y, (norm) descrs: n...
python
def vl_dsift(data, fast=False, norm=False, bounds=None, size=3, step=1, window_size=None, float_descriptors=False, verbose=False, matlab_style=True): ''' Dense sift descriptors from an image. Returns: frames: num_frames x (2 or 3) matrix of x, y, (norm) descrs: n...
[ "def", "vl_dsift", "(", "data", ",", "fast", "=", "False", ",", "norm", "=", "False", ",", "bounds", "=", "None", ",", "size", "=", "3", ",", "step", "=", "1", ",", "window_size", "=", "None", ",", "float_descriptors", "=", "False", ",", "verbose", ...
Dense sift descriptors from an image. Returns: frames: num_frames x (2 or 3) matrix of x, y, (norm) descrs: num_frames x 128 matrix of descriptors
[ "Dense", "sift", "descriptors", "from", "an", "image", "." ]
train
https://github.com/dougalsutherland/vlfeat-ctypes/blob/87367a1e18863e4effc98d7b3da0b85978e665d3/vlfeat/dsift.py#L105-L225
dougalsutherland/vlfeat-ctypes
vlfeat/utils.py
rgb2gray
def rgb2gray(img): """Converts an RGB image to grayscale using matlab's algorithm.""" T = np.linalg.inv(np.array([ [1.0, 0.956, 0.621], [1.0, -0.272, -0.647], [1.0, -1.106, 1.703], ])) r_c, g_c, b_c = T[0] r, g, b = np.rollaxis(as_float_image(img), axis=-1) return r_c ...
python
def rgb2gray(img): """Converts an RGB image to grayscale using matlab's algorithm.""" T = np.linalg.inv(np.array([ [1.0, 0.956, 0.621], [1.0, -0.272, -0.647], [1.0, -1.106, 1.703], ])) r_c, g_c, b_c = T[0] r, g, b = np.rollaxis(as_float_image(img), axis=-1) return r_c ...
[ "def", "rgb2gray", "(", "img", ")", ":", "T", "=", "np", ".", "linalg", ".", "inv", "(", "np", ".", "array", "(", "[", "[", "1.0", ",", "0.956", ",", "0.621", "]", ",", "[", "1.0", ",", "-", "0.272", ",", "-", "0.647", "]", ",", "[", "1.0",...
Converts an RGB image to grayscale using matlab's algorithm.
[ "Converts", "an", "RGB", "image", "to", "grayscale", "using", "matlab", "s", "algorithm", "." ]
train
https://github.com/dougalsutherland/vlfeat-ctypes/blob/87367a1e18863e4effc98d7b3da0b85978e665d3/vlfeat/utils.py#L31-L40
dougalsutherland/vlfeat-ctypes
vlfeat/utils.py
rgb2hsv
def rgb2hsv(arr): """Converts an RGB image to HSV using scikit-image's algorithm.""" arr = np.asanyarray(arr) if arr.ndim != 3 or arr.shape[2] != 3: raise ValueError("the input array must have a shape == (.,.,3)") arr = as_float_image(arr) out = np.empty_like(arr) # -- V channel ou...
python
def rgb2hsv(arr): """Converts an RGB image to HSV using scikit-image's algorithm.""" arr = np.asanyarray(arr) if arr.ndim != 3 or arr.shape[2] != 3: raise ValueError("the input array must have a shape == (.,.,3)") arr = as_float_image(arr) out = np.empty_like(arr) # -- V channel ou...
[ "def", "rgb2hsv", "(", "arr", ")", ":", "arr", "=", "np", ".", "asanyarray", "(", "arr", ")", "if", "arr", ".", "ndim", "!=", "3", "or", "arr", ".", "shape", "[", "2", "]", "!=", "3", ":", "raise", "ValueError", "(", "\"the input array must have a sh...
Converts an RGB image to HSV using scikit-image's algorithm.
[ "Converts", "an", "RGB", "image", "to", "HSV", "using", "scikit", "-", "image", "s", "algorithm", "." ]
train
https://github.com/dougalsutherland/vlfeat-ctypes/blob/87367a1e18863e4effc98d7b3da0b85978e665d3/vlfeat/utils.py#L44-L87
digidotcom/python-devicecloud
devicecloud/file_system_service.py
_parse_command_response
def _parse_command_response(response): """Parse an SCI command response into ElementTree XML This is a helper method that takes a Requests Response object of an SCI command response and will parse it into an ElementTree Element representing the root of the XML response. :param response: The reques...
python
def _parse_command_response(response): """Parse an SCI command response into ElementTree XML This is a helper method that takes a Requests Response object of an SCI command response and will parse it into an ElementTree Element representing the root of the XML response. :param response: The reques...
[ "def", "_parse_command_response", "(", "response", ")", ":", "try", ":", "root", "=", "ET", ".", "fromstring", "(", "response", ".", "text", ")", "except", "ET", ".", "ParseError", ":", "raise", "ResponseParseError", "(", "\"Unexpected response format, could not p...
Parse an SCI command response into ElementTree XML This is a helper method that takes a Requests Response object of an SCI command response and will parse it into an ElementTree Element representing the root of the XML response. :param response: The requests response object :return: An ElementTree...
[ "Parse", "an", "SCI", "command", "response", "into", "ElementTree", "XML" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L25-L42
digidotcom/python-devicecloud
devicecloud/file_system_service.py
_parse_error_tree
def _parse_error_tree(error): """Parse an error ElementTree Node to create an ErrorInfo object :param error: The ElementTree error node :return: An ErrorInfo object containing the error ID and the message. """ errinf = ErrorInfo(error.get('id'), None) if error.text is not None: errinf.m...
python
def _parse_error_tree(error): """Parse an error ElementTree Node to create an ErrorInfo object :param error: The ElementTree error node :return: An ErrorInfo object containing the error ID and the message. """ errinf = ErrorInfo(error.get('id'), None) if error.text is not None: errinf.m...
[ "def", "_parse_error_tree", "(", "error", ")", ":", "errinf", "=", "ErrorInfo", "(", "error", ".", "get", "(", "'id'", ")", ",", "None", ")", "if", "error", ".", "text", "is", "not", "None", ":", "errinf", ".", "message", "=", "error", ".", "text", ...
Parse an error ElementTree Node to create an ErrorInfo object :param error: The ElementTree error node :return: An ErrorInfo object containing the error ID and the message.
[ "Parse", "an", "error", "ElementTree", "Node", "to", "create", "an", "ErrorInfo", "object" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L45-L58
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileInfo.get_data
def get_data(self): """Get the contents of this file :return: The contents of this file :rtype: six.binary_type """ target = DeviceTarget(self.device_id) return self._fssapi.get_file(target, self.path)[self.device_id]
python
def get_data(self): """Get the contents of this file :return: The contents of this file :rtype: six.binary_type """ target = DeviceTarget(self.device_id) return self._fssapi.get_file(target, self.path)[self.device_id]
[ "def", "get_data", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "get_file", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
Get the contents of this file :return: The contents of this file :rtype: six.binary_type
[ "Get", "the", "contents", "of", "this", "file" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L116-L124
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileInfo.delete
def delete(self): """Delete this file from the device .. note:: After deleting the file, this object will no longer contain valid information and further calls to delete or get_data will return :class:`~.ErrorInfo` objects """ target = DeviceTarget(self.device_id) ...
python
def delete(self): """Delete this file from the device .. note:: After deleting the file, this object will no longer contain valid information and further calls to delete or get_data will return :class:`~.ErrorInfo` objects """ target = DeviceTarget(self.device_id) ...
[ "def", "delete", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "delete_file", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
Delete this file from the device .. note:: After deleting the file, this object will no longer contain valid information and further calls to delete or get_data will return :class:`~.ErrorInfo` objects
[ "Delete", "this", "file", "from", "the", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L126-L134
digidotcom/python-devicecloud
devicecloud/file_system_service.py
DirectoryInfo.list_contents
def list_contents(self): """List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.lis...
python
def list_contents(self): """List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.lis...
[ "def", "list_contents", "(", "self", ")", ":", "target", "=", "DeviceTarget", "(", "self", ".", "device_id", ")", "return", "self", ".", "_fssapi", ".", "list_files", "(", "target", ",", "self", ".", "path", ")", "[", "self", ".", "device_id", "]" ]
List the contents of this directory :return: A LsInfo object that contains directories and files :rtype: :class:`~.LsInfo` or :class:`~.ErrorInfo` Here is an example usage:: # let dirinfo be a DirectoryInfo object ldata = dirinfo.list_contents() if isinstan...
[ "List", "the", "contents", "of", "this", "directory" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L174-L197
digidotcom/python-devicecloud
devicecloud/file_system_service.py
LsCommand.parse_response
def parse_response(cls, response, device_id=None, fssapi=None, **kwargs): """Parse the server response for this ls command This will parse xml of the following form:: <ls hash="hash_type"> <file path="file_path" last_modified=last_modified_time ... /> ... ...
python
def parse_response(cls, response, device_id=None, fssapi=None, **kwargs): """Parse the server response for this ls command This will parse xml of the following form:: <ls hash="hash_type"> <file path="file_path" last_modified=last_modified_time ... /> ... ...
[ "def", "parse_response", "(", "cls", ",", "response", ",", "device_id", "=", "None", ",", "fssapi", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "tag", "!=", "cls", ".", "command_name", ":", "raise", "ResponseParseError", "(", ...
Parse the server response for this ls command This will parse xml of the following form:: <ls hash="hash_type"> <file path="file_path" last_modified=last_modified_time ... /> ... <dir path="dir_path" last_modified=last_modified_time /> ... ...
[ "Parse", "the", "server", "response", "for", "this", "ls", "command" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L282-L343
digidotcom/python-devicecloud
devicecloud/file_system_service.py
GetCommand.parse_response
def parse_response(cls, response, **kwargs): """Parse the server response for this get file command This will parse xml of the following form:: <get_file> <data> asdfasdfasdfasdfasf </data> </get_file> or with an error...
python
def parse_response(cls, response, **kwargs): """Parse the server response for this get file command This will parse xml of the following form:: <get_file> <data> asdfasdfasdfasdfasf </data> </get_file> or with an error...
[ "def", "parse_response", "(", "cls", ",", "response", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "tag", "!=", "cls", ".", "command_name", ":", "raise", "ResponseParseError", "(", "\"Received response of type {}, GetCommand can only parse responses of ty...
Parse the server response for this get file command This will parse xml of the following form:: <get_file> <data> asdfasdfasdfasdfasf </data> </get_file> or with an error:: <get_file> <error ... />...
[ "Parse", "the", "server", "response", "for", "this", "get", "file", "command" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L375-L409
digidotcom/python-devicecloud
devicecloud/file_system_service.py
PutCommand.parse_response
def parse_response(cls, response, **kwargs): """Parse the server response for this put file command This will parse xml of the following form:: <put_file /> or with an error:: <put_file> <error ... /> </put_file> :param response: T...
python
def parse_response(cls, response, **kwargs): """Parse the server response for this put file command This will parse xml of the following form:: <put_file /> or with an error:: <put_file> <error ... /> </put_file> :param response: T...
[ "def", "parse_response", "(", "cls", ",", "response", ",", "*", "*", "kwargs", ")", ":", "if", "response", ".", "tag", "!=", "cls", ".", "command_name", ":", "raise", "ResponseParseError", "(", "\"Received response of type {}, PutCommand can only parse responses of ty...
Parse the server response for this put file command This will parse xml of the following form:: <put_file /> or with an error:: <put_file> <error ... /> </put_file> :param response: The XML root of the response for a put file command ...
[ "Parse", "the", "server", "response", "for", "this", "put", "file", "command" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L459-L484
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.send_command_block
def send_command_block(self, target, command_block): """Send an arbitrary file system command block The primary use for this method is to send multiple file system commands with a single web service request. This can help to avoid throttling. :param target: The device(s) to be targete...
python
def send_command_block(self, target, command_block): """Send an arbitrary file system command block The primary use for this method is to send multiple file system commands with a single web service request. This can help to avoid throttling. :param target: The device(s) to be targete...
[ "def", "send_command_block", "(", "self", ",", "target", ",", "command_block", ")", ":", "root", "=", "_parse_command_response", "(", "self", ".", "_sci_api", ".", "send_sci", "(", "\"file_system\"", ",", "target", ",", "command_block", ".", "get_command_string", ...
Send an arbitrary file system command block The primary use for this method is to send multiple file system commands with a single web service request. This can help to avoid throttling. :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sc...
[ "Send", "an", "arbitrary", "file", "system", "command", "block" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L542-L573
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.list_files
def list_files(self, target, path, hash='any'): """List all files and directories in the path on the target :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path:...
python
def list_files(self, target, path, hash='any'): """List all files and directories in the path on the target :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path:...
[ "def", "list_files", "(", "self", ",", "target", ",", "path", ",", "hash", "=", "'any'", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")", "command_block", ".", "add_command", "(", "LsCommand", "(", "path", ",", "hash", "=", "hash", ...
List all files and directories in the path on the target :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to list files and directories from ...
[ "List", "all", "files", "and", "directories", "in", "the", "path", "on", "the", "target" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L575-L660
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.get_file
def get_file(self, target, path, offset=None, length=None): """Get the contents of a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
python
def get_file(self, target, path, offset=None, length=None): """Get the contents of a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
[ "def", "get_file", "(", "self", ",", "target", ",", "path", ",", "offset", "=", "None", ",", "length", "=", "None", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")", "command_block", ".", "add_command", "(", "GetCommand", "(", "path"...
Get the contents of a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to retrieve :param offset: Star...
[ "Get", "the", "contents", "of", "a", "file", "on", "the", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L662-L687
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.put_file
def put_file(self, target, path, file_data=None, server_file=None, offset=None, truncate=False): """Put data into a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` ins...
python
def put_file(self, target, path, file_data=None, server_file=None, offset=None, truncate=False): """Put data into a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` ins...
[ "def", "put_file", "(", "self", ",", "target", ",", "path", ",", "file_data", "=", "None", ",", "server_file", "=", "None", ",", "offset", "=", "None", ",", "truncate", "=", "False", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")"...
Put data into a file on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to write to. If the file already exists it w...
[ "Put", "data", "into", "a", "file", "on", "the", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L689-L721
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.delete_file
def delete_file(self, target, path): """Delete a file from a device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to d...
python
def delete_file(self, target, path): """Delete a file from a device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to d...
[ "def", "delete_file", "(", "self", ",", "target", ",", "path", ")", ":", "command_block", "=", "FileSystemServiceCommandBlock", "(", ")", "command_block", ".", "add_command", "(", "DeleteCommand", "(", "path", ")", ")", "root", "=", "_parse_command_response", "(...
Delete a file from a device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the file to delete. :return: A dictionary with keys b...
[ "Delete", "a", "file", "from", "a", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L723-L745
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.get_modified_items
def get_modified_items(self, target, path, last_modified_cutoff): """Get all files and directories from a path on the device modified since a given time :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud....
python
def get_modified_items(self, target, path, last_modified_cutoff): """Get all files and directories from a path on the device modified since a given time :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud....
[ "def", "get_modified_items", "(", "self", ",", "target", ",", "path", ",", "last_modified_cutoff", ")", ":", "file_list", "=", "self", ".", "list_files", "(", "target", ",", "path", ")", "out_dict", "=", "{", "}", "for", "device_id", ",", "device_data", "i...
Get all files and directories from a path on the device modified since a given time :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to the d...
[ "Get", "all", "files", "and", "directories", "from", "a", "path", "on", "the", "device", "modified", "since", "a", "given", "time" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L747-L776
digidotcom/python-devicecloud
devicecloud/file_system_service.py
FileSystemServiceAPI.exists
def exists(self, target, path, path_sep="/"): """Check if path refers to an existing path on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
python
def exists(self, target, path, path_sep="/"): """Check if path refers to an existing path on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The...
[ "def", "exists", "(", "self", ",", "target", ",", "path", ",", "path_sep", "=", "\"/\"", ")", ":", "if", "path", ".", "endswith", "(", "path_sep", ")", ":", "path", "=", "path", "[", ":", "-", "len", "(", "path_sep", ")", "]", "par_dir", ",", "fi...
Check if path refers to an existing path on the device :param target: The device(s) to be targeted with this request :type target: :class:`devicecloud.sci.TargetABC` or list of :class:`devicecloud.sci.TargetABC` instances :param path: The path on the target to check for existence. :para...
[ "Check", "if", "path", "refers", "to", "an", "existing", "path", "on", "the", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/file_system_service.py#L778-L805
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.get_devices
def get_devices(self, condition=None, page_size=1000): """Iterates over each :class:`Device` for this device cloud account Examples:: # get a list of all devices all_devices = list(dc.devicecore.get_devices()) # build a mapping of devices by their vendor id using a...
python
def get_devices(self, condition=None, page_size=1000): """Iterates over each :class:`Device` for this device cloud account Examples:: # get a list of all devices all_devices = list(dc.devicecore.get_devices()) # build a mapping of devices by their vendor id using a...
[ "def", "get_devices", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "condition", "=", "validate_type", "(", "condition", ",", "type", "(", "None", ")", ",", "Expression", ",", "*", "six", ".", "string_types", ")", ...
Iterates over each :class:`Device` for this device cloud account Examples:: # get a list of all devices all_devices = list(dc.devicecore.get_devices()) # build a mapping of devices by their vendor id using a # dict comprehension devices = dc.devicec...
[ "Iterates", "over", "each", ":", "class", ":", "Device", "for", "this", "device", "cloud", "account" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L48-L83
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.get_group_tree_root
def get_group_tree_root(self, page_size=1000): r"""Return the root group for this accounts' group tree This will return the root group for this tree but with all links between nodes (i.e. children starting from root) populated. Examples:: # print the group hierarchy to std...
python
def get_group_tree_root(self, page_size=1000): r"""Return the root group for this accounts' group tree This will return the root group for this tree but with all links between nodes (i.e. children starting from root) populated. Examples:: # print the group hierarchy to std...
[ "def", "get_group_tree_root", "(", "self", ",", "page_size", "=", "1000", ")", ":", "# first pass, build mapping", "group_map", "=", "{", "}", "# map id -> group", "page_size", "=", "validate_type", "(", "page_size", ",", "*", "six", ".", "integer_types", ")", "...
r"""Return the root group for this accounts' group tree This will return the root group for this tree but with all links between nodes (i.e. children starting from root) populated. Examples:: # print the group hierarchy to stdout dc.devicecore.get_group_tree_root().pri...
[ "r", "Return", "the", "root", "group", "for", "this", "accounts", "group", "tree" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L85-L134
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.get_groups
def get_groups(self, condition=None, page_size=1000): """Return an iterator over all groups in this device cloud account Optionally, a condition can be specified to limit the number of groups returned. Examples:: # Get all groups and print information about them ...
python
def get_groups(self, condition=None, page_size=1000): """Return an iterator over all groups in this device cloud account Optionally, a condition can be specified to limit the number of groups returned. Examples:: # Get all groups and print information about them ...
[ "def", "get_groups", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "query_kwargs", "=", "{", "}", "if", "condition", "is", "not", "None", ":", "query_kwargs", "[", "\"condition\"", "]", "=", "condition", ".", "compi...
Return an iterator over all groups in this device cloud account Optionally, a condition can be specified to limit the number of groups returned. Examples:: # Get all groups and print information about them for group in dc.devicecore.get_groups(): print ...
[ "Return", "an", "iterator", "over", "all", "groups", "in", "this", "device", "cloud", "account" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L136-L167
digidotcom/python-devicecloud
devicecloud/devicecore.py
DeviceCoreAPI.provision_devices
def provision_devices(self, devices): """Provision multiple devices with a single API call This method takes an iterable of dictionaries where the values in the dictionary are expected to match the arguments of a call to :meth:`provision_device`. The contents of each dictionary will be...
python
def provision_devices(self, devices): """Provision multiple devices with a single API call This method takes an iterable of dictionaries where the values in the dictionary are expected to match the arguments of a call to :meth:`provision_device`. The contents of each dictionary will be...
[ "def", "provision_devices", "(", "self", ",", "devices", ")", ":", "# Validate all the input for each device provided", "sio", "=", "six", ".", "StringIO", "(", ")", "def", "write_tag", "(", "tag", ",", "val", ")", ":", "sio", ".", "write", "(", "\"<{tag}>{val...
Provision multiple devices with a single API call This method takes an iterable of dictionaries where the values in the dictionary are expected to match the arguments of a call to :meth:`provision_device`. The contents of each dictionary will be validated. :param list devices: An iter...
[ "Provision", "multiple", "devices", "with", "a", "single", "API", "call" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L237-L312
digidotcom/python-devicecloud
devicecloud/devicecore.py
Group.from_json
def from_json(cls, json_data): """Build and return a new Group object from json data (used internally)""" # Example Data: # { "grpId": "11817", "grpName": "7603_Digi", "grpDescription": "7603_Digi root group", # "grpPath": "\/7603_Digi\/", "grpParentId": "1"} return cls( ...
python
def from_json(cls, json_data): """Build and return a new Group object from json data (used internally)""" # Example Data: # { "grpId": "11817", "grpName": "7603_Digi", "grpDescription": "7603_Digi root group", # "grpPath": "\/7603_Digi\/", "grpParentId": "1"} return cls( ...
[ "def", "from_json", "(", "cls", ",", "json_data", ")", ":", "# Example Data:", "# { \"grpId\": \"11817\", \"grpName\": \"7603_Digi\", \"grpDescription\": \"7603_Digi root group\",", "# \"grpPath\": \"\\/7603_Digi\\/\", \"grpParentId\": \"1\"}", "return", "cls", "(", "group_id", "=", ...
Build and return a new Group object from json data (used internally)
[ "Build", "and", "return", "a", "new", "Group", "object", "from", "json", "data", "(", "used", "internally", ")" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L335-L346
digidotcom/python-devicecloud
devicecloud/devicecore.py
Group.print_subtree
def print_subtree(self, fobj=sys.stdout, level=0): """Print this group node and the subtree rooted at it""" fobj.write("{}{!r}\n".format(" " * (level * 2), self)) for child in self.get_children(): child.print_subtree(fobj, level + 1)
python
def print_subtree(self, fobj=sys.stdout, level=0): """Print this group node and the subtree rooted at it""" fobj.write("{}{!r}\n".format(" " * (level * 2), self)) for child in self.get_children(): child.print_subtree(fobj, level + 1)
[ "def", "print_subtree", "(", "self", ",", "fobj", "=", "sys", ".", "stdout", ",", "level", "=", "0", ")", ":", "fobj", ".", "write", "(", "\"{}{!r}\\n\"", ".", "format", "(", "\" \"", "*", "(", "level", "*", "2", ")", ",", "self", ")", ")", "for"...
Print this group node and the subtree rooted at it
[ "Print", "this", "group", "node", "and", "the", "subtree", "rooted", "at", "it" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L353-L357
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_device_json
def get_device_json(self, use_cached=True): """Get the JSON metadata for this device as a python data structure If ``use_cached`` is not True, then a web services request will be made synchronously in order to get the latest device metatdata. This will update the cached data for this d...
python
def get_device_json(self, use_cached=True): """Get the JSON metadata for this device as a python data structure If ``use_cached`` is not True, then a web services request will be made synchronously in order to get the latest device metatdata. This will update the cached data for this d...
[ "def", "get_device_json", "(", "self", ",", "use_cached", "=", "True", ")", ":", "if", "not", "use_cached", ":", "devicecore_data", "=", "self", ".", "_conn", ".", "get_json", "(", "\"/ws/DeviceCore/{}\"", ".", "format", "(", "self", ".", "get_device_id", "(...
Get the JSON metadata for this device as a python data structure If ``use_cached`` is not True, then a web services request will be made synchronously in order to get the latest device metatdata. This will update the cached data for this device.
[ "Get", "the", "JSON", "metadata", "for", "this", "device", "as", "a", "python", "data", "structure" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L405-L417
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_tags
def get_tags(self, use_cached=True): """Get the list of tags for this device""" device_json = self.get_device_json(use_cached) potential_tags = device_json.get("dpTags") if potential_tags: return list(filter(None, potential_tags.split(","))) else: return [...
python
def get_tags(self, use_cached=True): """Get the list of tags for this device""" device_json = self.get_device_json(use_cached) potential_tags = device_json.get("dpTags") if potential_tags: return list(filter(None, potential_tags.split(","))) else: return [...
[ "def", "get_tags", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "potential_tags", "=", "device_json", ".", "get", "(", "\"dpTags\"", ")", "if", "potential_tags", ":", "retu...
Get the list of tags for this device
[ "Get", "the", "list", "of", "tags", "for", "this", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L419-L426
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.is_connected
def is_connected(self, use_cached=True): """Return True if the device is currrently connect and False if not""" device_json = self.get_device_json(use_cached) return int(device_json.get("dpConnectionStatus")) > 0
python
def is_connected(self, use_cached=True): """Return True if the device is currrently connect and False if not""" device_json = self.get_device_json(use_cached) return int(device_json.get("dpConnectionStatus")) > 0
[ "def", "is_connected", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "int", "(", "device_json", ".", "get", "(", "\"dpConnectionStatus\"", ")", ")", ">", "0" ]
Return True if the device is currrently connect and False if not
[ "Return", "True", "if", "the", "device", "is", "currrently", "connect", "and", "False", "if", "not" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L428-L431
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_connectware_id
def get_connectware_id(self, use_cached=True): """Get the connectware id of this device (primary key)""" device_json = self.get_device_json(use_cached) return device_json.get("devConnectwareId")
python
def get_connectware_id(self, use_cached=True): """Get the connectware id of this device (primary key)""" device_json = self.get_device_json(use_cached) return device_json.get("devConnectwareId")
[ "def", "get_connectware_id", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", ".", "get", "(", "\"devConnectwareId\"", ")" ]
Get the connectware id of this device (primary key)
[ "Get", "the", "connectware", "id", "of", "this", "device", "(", "primary", "key", ")" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L433-L436
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_device_id
def get_device_id(self, use_cached=True): """Get this device's device id""" device_json = self.get_device_json(use_cached) return device_json["id"].get("devId")
python
def get_device_id(self, use_cached=True): """Get this device's device id""" device_json = self.get_device_json(use_cached) return device_json["id"].get("devId")
[ "def", "get_device_id", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", "[", "\"id\"", "]", ".", "get", "(", "\"devId\"", ")" ]
Get this device's device id
[ "Get", "this", "device", "s", "device", "id" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L438-L441
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_ip
def get_ip(self, use_cached=True): """Get the last known IP of this device""" device_json = self.get_device_json(use_cached) return device_json.get("dpLastKnownIp")
python
def get_ip(self, use_cached=True): """Get the last known IP of this device""" device_json = self.get_device_json(use_cached) return device_json.get("dpLastKnownIp")
[ "def", "get_ip", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", ".", "get", "(", "\"dpLastKnownIp\"", ")" ]
Get the last known IP of this device
[ "Get", "the", "last", "known", "IP", "of", "this", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L443-L446
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_mac
def get_mac(self, use_cached=True): """Get the MAC address of this device""" device_json = self.get_device_json(use_cached) return device_json.get("devMac")
python
def get_mac(self, use_cached=True): """Get the MAC address of this device""" device_json = self.get_device_json(use_cached) return device_json.get("devMac")
[ "def", "get_mac", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "return", "device_json", ".", "get", "(", "\"devMac\"", ")" ]
Get the MAC address of this device
[ "Get", "the", "MAC", "address", "of", "this", "device" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L448-L451
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_mac_last4
def get_mac_last4(self, use_cached=True): """Get the last 4 characters in the device mac address hex (e.g. 00:40:9D:58:17:5B -> 175B) This is useful for use as a short reference to the device. It is not guaranteed to be unique (obviously) but will often be if you don't have too many devices. ...
python
def get_mac_last4(self, use_cached=True): """Get the last 4 characters in the device mac address hex (e.g. 00:40:9D:58:17:5B -> 175B) This is useful for use as a short reference to the device. It is not guaranteed to be unique (obviously) but will often be if you don't have too many devices. ...
[ "def", "get_mac_last4", "(", "self", ",", "use_cached", "=", "True", ")", ":", "chunks", "=", "self", ".", "get_mac", "(", "use_cached", ")", ".", "split", "(", "\":\"", ")", "mac4", "=", "\"%s%s\"", "%", "(", "chunks", "[", "-", "2", "]", ",", "ch...
Get the last 4 characters in the device mac address hex (e.g. 00:40:9D:58:17:5B -> 175B) This is useful for use as a short reference to the device. It is not guaranteed to be unique (obviously) but will often be if you don't have too many devices.
[ "Get", "the", "last", "4", "characters", "in", "the", "device", "mac", "address", "hex", "(", "e", ".", "g", ".", "00", ":", "40", ":", "9D", ":", "58", ":", "17", ":", "5B", "-", ">", "175B", ")" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L453-L462
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_registration_dt
def get_registration_dt(self, use_cached=True): """Get the datetime of when this device was added to Device Cloud""" device_json = self.get_device_json(use_cached) start_date_iso8601 = device_json.get("devRecordStartDate") if start_date_iso8601: return iso8601_to_dt(start_dat...
python
def get_registration_dt(self, use_cached=True): """Get the datetime of when this device was added to Device Cloud""" device_json = self.get_device_json(use_cached) start_date_iso8601 = device_json.get("devRecordStartDate") if start_date_iso8601: return iso8601_to_dt(start_dat...
[ "def", "get_registration_dt", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "start_date_iso8601", "=", "device_json", ".", "get", "(", "\"devRecordStartDate\"", ")", "if", "star...
Get the datetime of when this device was added to Device Cloud
[ "Get", "the", "datetime", "of", "when", "this", "device", "was", "added", "to", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L464-L471
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.get_latlon
def get_latlon(self, use_cached=True): """Get a tuple with device latitude and longitude... these may be None""" device_json = self.get_device_json(use_cached) lat = device_json.get("dpMapLat") lon = device_json.get("dpMapLong") return (float(lat) if lat else None, ...
python
def get_latlon(self, use_cached=True): """Get a tuple with device latitude and longitude... these may be None""" device_json = self.get_device_json(use_cached) lat = device_json.get("dpMapLat") lon = device_json.get("dpMapLong") return (float(lat) if lat else None, ...
[ "def", "get_latlon", "(", "self", ",", "use_cached", "=", "True", ")", ":", "device_json", "=", "self", ".", "get_device_json", "(", "use_cached", ")", "lat", "=", "device_json", ".", "get", "(", "\"dpMapLat\"", ")", "lon", "=", "device_json", ".", "get", ...
Get a tuple with device latitude and longitude... these may be None
[ "Get", "a", "tuple", "with", "device", "latitude", "and", "longitude", "...", "these", "may", "be", "None" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L542-L548
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.add_to_group
def add_to_group(self, group_path): """Add a device to a group, if the group doesn't exist it is created :param group_path: Path or "name" of the group """ if self.get_group_path() != group_path: post_data = ADD_GROUP_TEMPLATE.format(connectware_id=self.get_connectware_id()...
python
def add_to_group(self, group_path): """Add a device to a group, if the group doesn't exist it is created :param group_path: Path or "name" of the group """ if self.get_group_path() != group_path: post_data = ADD_GROUP_TEMPLATE.format(connectware_id=self.get_connectware_id()...
[ "def", "add_to_group", "(", "self", ",", "group_path", ")", ":", "if", "self", ".", "get_group_path", "(", ")", "!=", "group_path", ":", "post_data", "=", "ADD_GROUP_TEMPLATE", ".", "format", "(", "connectware_id", "=", "self", ".", "get_connectware_id", "(", ...
Add a device to a group, if the group doesn't exist it is created :param group_path: Path or "name" of the group
[ "Add", "a", "device", "to", "a", "group", "if", "the", "group", "doesn", "t", "exist", "it", "is", "created" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L576-L588
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.add_tag
def add_tag(self, new_tags): """Add a tag to existing device tags. This method will not add a duplicate, if already in the list. :param new_tags: the tag(s) to be added. new_tags can be a comma-separated string or list """ tags = self.get_tags() orig_tag_cnt = len(tags) ...
python
def add_tag(self, new_tags): """Add a tag to existing device tags. This method will not add a duplicate, if already in the list. :param new_tags: the tag(s) to be added. new_tags can be a comma-separated string or list """ tags = self.get_tags() orig_tag_cnt = len(tags) ...
[ "def", "add_tag", "(", "self", ",", "new_tags", ")", ":", "tags", "=", "self", ".", "get_tags", "(", ")", "orig_tag_cnt", "=", "len", "(", "tags", ")", "# print(\"self.get_tags() {}\".format(tags))", "if", "isinstance", "(", "new_tags", ",", "six", ".", "str...
Add a tag to existing device tags. This method will not add a duplicate, if already in the list. :param new_tags: the tag(s) to be added. new_tags can be a comma-separated string or list
[ "Add", "a", "tag", "to", "existing", "device", "tags", ".", "This", "method", "will", "not", "add", "a", "duplicate", "if", "already", "in", "the", "list", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L601-L626
digidotcom/python-devicecloud
devicecloud/devicecore.py
Device.remove_tag
def remove_tag(self, tag): """Remove tag from existing device tags :param tag: the tag to be removed from the list :raises ValueError: If tag does not exist in list """ tags = self.get_tags() tags.remove(tag) post_data = TAGS_TEMPLATE.format(connectware_id=sel...
python
def remove_tag(self, tag): """Remove tag from existing device tags :param tag: the tag to be removed from the list :raises ValueError: If tag does not exist in list """ tags = self.get_tags() tags.remove(tag) post_data = TAGS_TEMPLATE.format(connectware_id=sel...
[ "def", "remove_tag", "(", "self", ",", "tag", ")", ":", "tags", "=", "self", ".", "get_tags", "(", ")", "tags", ".", "remove", "(", "tag", ")", "post_data", "=", "TAGS_TEMPLATE", ".", "format", "(", "connectware_id", "=", "self", ".", "get_connectware_id...
Remove tag from existing device tags :param tag: the tag to be removed from the list :raises ValueError: If tag does not exist in list
[ "Remove", "tag", "from", "existing", "device", "tags" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/devicecore.py#L630-L646
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.hostname
def hostname(self): """Get the hostname that this connection is associated with""" from six.moves.urllib.parse import urlparse return urlparse(self._base_url).netloc.split(':', 1)[0]
python
def hostname(self): """Get the hostname that this connection is associated with""" from six.moves.urllib.parse import urlparse return urlparse(self._base_url).netloc.split(':', 1)[0]
[ "def", "hostname", "(", "self", ")", ":", "from", "six", ".", "moves", ".", "urllib", ".", "parse", "import", "urlparse", "return", "urlparse", "(", "self", ".", "_base_url", ")", ".", "netloc", ".", "split", "(", "':'", ",", "1", ")", "[", "0", "]...
Get the hostname that this connection is associated with
[ "Get", "the", "hostname", "that", "this", "connection", "is", "associated", "with" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L131-L134
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.iter_json_pages
def iter_json_pages(self, path, page_size=1000, **params): """Return an iterator over JSON items from a paginated resource Legacy resources (prior to V1) implemented a common paging interfaces for several different resources. This method handles the details of iterating over the paged ...
python
def iter_json_pages(self, path, page_size=1000, **params): """Return an iterator over JSON items from a paginated resource Legacy resources (prior to V1) implemented a common paging interfaces for several different resources. This method handles the details of iterating over the paged ...
[ "def", "iter_json_pages", "(", "self", ",", "path", ",", "page_size", "=", "1000", ",", "*", "*", "params", ")", ":", "path", "=", "validate_type", "(", "path", ",", "*", "six", ".", "string_types", ")", "page_size", "=", "validate_type", "(", "page_size...
Return an iterator over JSON items from a paginated resource Legacy resources (prior to V1) implemented a common paging interfaces for several different resources. This method handles the details of iterating over the paged result set, yielding only the JSON data for each item within t...
[ "Return", "an", "iterator", "over", "JSON", "items", "from", "a", "paginated", "resource" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L181-L209
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.get
def get(self, path, **kwargs): """Perform an HTTP GET request of the specified path in Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `...
python
def get(self, path, **kwargs): """Perform an HTTP GET request of the specified path in Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `...
[ "def", "get", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"GET\"", ",", "url", ",", "*", "*", "kwargs", ")" ]
Perform an HTTP GET request of the specified path in Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-request...
[ "Perform", "an", "HTTP", "GET", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L220-L238
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.get_json
def get_json(self, path, **kwargs): """Perform an HTTP GET request with JSON headers of the specified path against Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/...
python
def get_json(self, path, **kwargs): """Perform an HTTP GET request with JSON headers of the specified path against Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/...
[ "def", "get_json", "(", "self", ",", "path", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "headers", "=", "kwargs", ".", "setdefault", "(", "'headers'", ",", "{", "}", ")", "headers", ".", "update", "("...
Perform an HTTP GET request with JSON headers of the specified path against Device Cloud Make an HTTP GET request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <htt...
[ "Perform", "an", "HTTP", "GET", "request", "with", "JSON", "headers", "of", "the", "specified", "path", "against", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L240-L266
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.post
def post(self, path, data, **kwargs): """Perform an HTTP POST request of the specified path in Device Cloud Make an HTTP POST request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
python
def post(self, path, data, **kwargs): """Perform an HTTP POST request of the specified path in Device Cloud Make an HTTP POST request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
[ "def", "post", "(", "self", ",", "path", ",", "data", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"POST\"", ",", "url", ",", "data", "=", "data", ",", "...
Perform an HTTP POST request of the specified path in Device Cloud Make an HTTP POST request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-reque...
[ "Perform", "an", "HTTP", "POST", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L268-L288
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.put
def put(self, path, data, **kwargs): """Perform an HTTP PUT request of the specified path in Device Cloud Make an HTTP PUT request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
python
def put(self, path, data, **kwargs): """Perform an HTTP PUT request of the specified path in Device Cloud Make an HTTP PUT request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library ...
[ "def", "put", "(", "self", ",", "path", ",", "data", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"PUT\"", ",", "url", ",", "data", "=", "data", ",", "*"...
Perform an HTTP PUT request of the specified path in Device Cloud Make an HTTP PUT request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-request...
[ "Perform", "an", "HTTP", "PUT", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L290-L311
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloudConnection.delete
def delete(self, path, retries=DEFAULT_THROTTLE_RETRIES, **kwargs): """Perform an HTTP DELETE request of the specified path in Device Cloud Make an HTTP DELETE request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-r...
python
def delete(self, path, retries=DEFAULT_THROTTLE_RETRIES, **kwargs): """Perform an HTTP DELETE request of the specified path in Device Cloud Make an HTTP DELETE request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-r...
[ "def", "delete", "(", "self", ",", "path", ",", "retries", "=", "DEFAULT_THROTTLE_RETRIES", ",", "*", "*", "kwargs", ")", ":", "url", "=", "self", ".", "_make_url", "(", "path", ")", "return", "self", ".", "_make_request", "(", "\"DELETE\"", ",", "url", ...
Perform an HTTP DELETE request of the specified path in Device Cloud Make an HTTP DELETE request against Device Cloud with this accounts credentials and base url. This method uses the `requests <http://docs.python-requests.org/en/latest/>`_ library `request method <http://docs.python-r...
[ "Perform", "an", "HTTP", "DELETE", "request", "of", "the", "specified", "path", "in", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L313-L331
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.streams
def streams(self): """Property providing access to the :class:`.StreamsAPI`""" if self._streams_api is None: self._streams_api = self.get_streams_api() return self._streams_api
python
def streams(self): """Property providing access to the :class:`.StreamsAPI`""" if self._streams_api is None: self._streams_api = self.get_streams_api() return self._streams_api
[ "def", "streams", "(", "self", ")", ":", "if", "self", ".", "_streams_api", "is", "None", ":", "self", ".", "_streams_api", "=", "self", ".", "get_streams_api", "(", ")", "return", "self", ".", "_streams_api" ]
Property providing access to the :class:`.StreamsAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "StreamsAPI" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L394-L398
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.filedata
def filedata(self): """Property providing access to the :class:`.FileDataAPI`""" if self._filedata_api is None: self._filedata_api = self.get_filedata_api() return self._filedata_api
python
def filedata(self): """Property providing access to the :class:`.FileDataAPI`""" if self._filedata_api is None: self._filedata_api = self.get_filedata_api() return self._filedata_api
[ "def", "filedata", "(", "self", ")", ":", "if", "self", ".", "_filedata_api", "is", "None", ":", "self", ".", "_filedata_api", "=", "self", ".", "get_filedata_api", "(", ")", "return", "self", ".", "_filedata_api" ]
Property providing access to the :class:`.FileDataAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "FileDataAPI" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L401-L405
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.devicecore
def devicecore(self): """Property providing access to the :class:`.DeviceCoreAPI`""" if self._devicecore_api is None: self._devicecore_api = self.get_devicecore_api() return self._devicecore_api
python
def devicecore(self): """Property providing access to the :class:`.DeviceCoreAPI`""" if self._devicecore_api is None: self._devicecore_api = self.get_devicecore_api() return self._devicecore_api
[ "def", "devicecore", "(", "self", ")", ":", "if", "self", ".", "_devicecore_api", "is", "None", ":", "self", ".", "_devicecore_api", "=", "self", ".", "get_devicecore_api", "(", ")", "return", "self", ".", "_devicecore_api" ]
Property providing access to the :class:`.DeviceCoreAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "DeviceCoreAPI" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L408-L412
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.sci
def sci(self): """Property providing access to the :class:`.ServerCommandInterfaceAPI`""" if self._sci_api is None: self._sci_api = self.get_sci_api() return self._sci_api
python
def sci(self): """Property providing access to the :class:`.ServerCommandInterfaceAPI`""" if self._sci_api is None: self._sci_api = self.get_sci_api() return self._sci_api
[ "def", "sci", "(", "self", ")", ":", "if", "self", ".", "_sci_api", "is", "None", ":", "self", ".", "_sci_api", "=", "self", ".", "get_sci_api", "(", ")", "return", "self", ".", "_sci_api" ]
Property providing access to the :class:`.ServerCommandInterfaceAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "ServerCommandInterfaceAPI" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L415-L419
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.file_system_service
def file_system_service(self): """Property providing access to the :class:`.FileSystemServiceAPI`""" if self._fss_api is None: self._fss_api = self.get_fss_api() return self._fss_api
python
def file_system_service(self): """Property providing access to the :class:`.FileSystemServiceAPI`""" if self._fss_api is None: self._fss_api = self.get_fss_api() return self._fss_api
[ "def", "file_system_service", "(", "self", ")", ":", "if", "self", ".", "_fss_api", "is", "None", ":", "self", ".", "_fss_api", "=", "self", ".", "get_fss_api", "(", ")", "return", "self", ".", "_fss_api" ]
Property providing access to the :class:`.FileSystemServiceAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "FileSystemServiceAPI" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L422-L426
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.monitor
def monitor(self): """Property providing access to the :class:`.MonitorAPI`""" if self._monitor_api is None: self._monitor_api = self.get_monitor_api() return self._monitor_api
python
def monitor(self): """Property providing access to the :class:`.MonitorAPI`""" if self._monitor_api is None: self._monitor_api = self.get_monitor_api() return self._monitor_api
[ "def", "monitor", "(", "self", ")", ":", "if", "self", ".", "_monitor_api", "is", "None", ":", "self", ".", "_monitor_api", "=", "self", ".", "get_monitor_api", "(", ")", "return", "self", ".", "_monitor_api" ]
Property providing access to the :class:`.MonitorAPI`
[ "Property", "providing", "access", "to", "the", ":", "class", ":", ".", "MonitorAPI" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L429-L433
digidotcom/python-devicecloud
devicecloud/__init__.py
DeviceCloud.get_devicecore_api
def get_devicecore_api(self): """Returns a :class:`.DeviceCoreAPI` bound to this device cloud instance This provides access to the same API as :attr:`.DeviceCloud.devicecore` but will create a new object (with a new cache) each time called. :return: devicecore API object bound to this ...
python
def get_devicecore_api(self): """Returns a :class:`.DeviceCoreAPI` bound to this device cloud instance This provides access to the same API as :attr:`.DeviceCloud.devicecore` but will create a new object (with a new cache) each time called. :return: devicecore API object bound to this ...
[ "def", "get_devicecore_api", "(", "self", ")", ":", "from", "devicecloud", ".", "devicecore", "import", "DeviceCoreAPI", "return", "DeviceCoreAPI", "(", "self", ".", "_conn", ",", "self", ".", "get_sci_api", "(", ")", ")" ]
Returns a :class:`.DeviceCoreAPI` bound to this device cloud instance This provides access to the same API as :attr:`.DeviceCloud.devicecore` but will create a new object (with a new cache) each time called. :return: devicecore API object bound to this device cloud account :rtype: :cla...
[ "Returns", "a", ":", "class", ":", ".", "DeviceCoreAPI", "bound", "to", "this", "device", "cloud", "instance" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/__init__.py#L477-L489
digidotcom/python-devicecloud
devicecloud/sci.py
ServerCommandInterfaceAPI.get_async_job
def get_async_job(self, job_id): """Query an asynchronous SCI job by ID This is useful if the job was not created with send_sci_async(). :param int job_id: The job ID to query :returns: The SCI response from GETting the job information """ uri = "/ws/sci/{0}".format(job...
python
def get_async_job(self, job_id): """Query an asynchronous SCI job by ID This is useful if the job was not created with send_sci_async(). :param int job_id: The job ID to query :returns: The SCI response from GETting the job information """ uri = "/ws/sci/{0}".format(job...
[ "def", "get_async_job", "(", "self", ",", "job_id", ")", ":", "uri", "=", "\"/ws/sci/{0}\"", ".", "format", "(", "job_id", ")", "# TODO: do parsing here?", "return", "self", ".", "_conn", ".", "get", "(", "uri", ")" ]
Query an asynchronous SCI job by ID This is useful if the job was not created with send_sci_async(). :param int job_id: The job ID to query :returns: The SCI response from GETting the job information
[ "Query", "an", "asynchronous", "SCI", "job", "by", "ID" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L100-L110
digidotcom/python-devicecloud
devicecloud/sci.py
ServerCommandInterfaceAPI.send_sci_async
def send_sci_async(self, operation, target, payload, **sci_options): """Send an asynchronous SCI request, and wraps the job in an object to manage it :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_s...
python
def send_sci_async(self, operation, target, payload, **sci_options): """Send an asynchronous SCI request, and wraps the job in an object to manage it :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_s...
[ "def", "send_sci_async", "(", "self", ",", "operation", ",", "target", ",", "payload", ",", "*", "*", "sci_options", ")", ":", "sci_options", "[", "'synchronous'", "]", "=", "False", "resp", "=", "self", ".", "send_sci", "(", "operation", ",", "target", ...
Send an asynchronous SCI request, and wraps the job in an object to manage it :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_service, and reboot} :param target: The device(s) to be targeted with thi...
[ "Send", "an", "asynchronous", "SCI", "request", "and", "wraps", "the", "job", "in", "an", "object", "to", "manage", "it" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L112-L131
digidotcom/python-devicecloud
devicecloud/sci.py
ServerCommandInterfaceAPI.send_sci
def send_sci(self, operation, target, payload, reply=None, synchronous=None, sync_timeout=None, cache=None, allow_offline=None, wait_for_reconnect=None): """Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, q...
python
def send_sci(self, operation, target, payload, reply=None, synchronous=None, sync_timeout=None, cache=None, allow_offline=None, wait_for_reconnect=None): """Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, q...
[ "def", "send_sci", "(", "self", ",", "operation", ",", "target", ",", "payload", ",", "reply", "=", "None", ",", "synchronous", "=", "None", ",", "sync_timeout", "=", "None", ",", "cache", "=", "None", ",", "allow_offline", "=", "None", ",", "wait_for_re...
Send SCI request to 1 or more targets :param str operation: The operation is one of {send_message, update_firmware, disconnect, query_firmware_targets, file_system, data_service, and reboot} :param target: The device(s) to be targeted with this request :type target: :class:`~.Target...
[ "Send", "SCI", "request", "to", "1", "or", "more", "targets" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/sci.py#L133-L220
digidotcom/python-devicecloud
devicecloud/util.py
conditional_write
def conditional_write(strm, fmt, value, *args, **kwargs): """Write to stream using fmt and value if value is not None""" if value is not None: strm.write(fmt.format(value, *args, **kwargs))
python
def conditional_write(strm, fmt, value, *args, **kwargs): """Write to stream using fmt and value if value is not None""" if value is not None: strm.write(fmt.format(value, *args, **kwargs))
[ "def", "conditional_write", "(", "strm", ",", "fmt", ",", "value", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "value", "is", "not", "None", ":", "strm", ".", "write", "(", "fmt", ".", "format", "(", "value", ",", "*", "args", ",",...
Write to stream using fmt and value if value is not None
[ "Write", "to", "stream", "using", "fmt", "and", "value", "if", "value", "is", "not", "None" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L13-L16
digidotcom/python-devicecloud
devicecloud/util.py
iso8601_to_dt
def iso8601_to_dt(iso8601): """Given an ISO8601 string as returned by Device Cloud, convert to a datetime object""" # We could just use arrow.get() but that is more permissive than we actually want. # Internal (but still public) to arrow is the actual parser where we can be # a bit more specific par...
python
def iso8601_to_dt(iso8601): """Given an ISO8601 string as returned by Device Cloud, convert to a datetime object""" # We could just use arrow.get() but that is more permissive than we actually want. # Internal (but still public) to arrow is the actual parser where we can be # a bit more specific par...
[ "def", "iso8601_to_dt", "(", "iso8601", ")", ":", "# We could just use arrow.get() but that is more permissive than we actually want.", "# Internal (but still public) to arrow is the actual parser where we can be", "# a bit more specific", "parser", "=", "DateTimeParser", "(", ")", "try"...
Given an ISO8601 string as returned by Device Cloud, convert to a datetime object
[ "Given", "an", "ISO8601", "string", "as", "returned", "by", "Device", "Cloud", "convert", "to", "a", "datetime", "object" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L19-L29
digidotcom/python-devicecloud
devicecloud/util.py
to_none_or_dt
def to_none_or_dt(input): """Convert ``input`` to either None or a datetime object If the input is None, None will be returned. If the input is a datetime object, it will be converted to a datetime object with UTC timezone info. If the datetime object is naive, then this method will assume the obj...
python
def to_none_or_dt(input): """Convert ``input`` to either None or a datetime object If the input is None, None will be returned. If the input is a datetime object, it will be converted to a datetime object with UTC timezone info. If the datetime object is naive, then this method will assume the obj...
[ "def", "to_none_or_dt", "(", "input", ")", ":", "if", "input", "is", "None", ":", "return", "input", "elif", "isinstance", "(", "input", ",", "datetime", ".", "datetime", ")", ":", "arrow_dt", "=", "arrow", ".", "Arrow", ".", "fromdatetime", "(", "input"...
Convert ``input`` to either None or a datetime object If the input is None, None will be returned. If the input is a datetime object, it will be converted to a datetime object with UTC timezone info. If the datetime object is naive, then this method will assume the object is specified according to UTC...
[ "Convert", "input", "to", "either", "None", "or", "a", "datetime", "object" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L32-L57
digidotcom/python-devicecloud
devicecloud/util.py
isoformat
def isoformat(dt): """Return an ISO-8601 formatted string from the provided datetime object""" if not isinstance(dt, datetime.datetime): raise TypeError("Must provide datetime.datetime object to isoformat") if dt.tzinfo is None: raise ValueError("naive datetime objects are not allowed beyon...
python
def isoformat(dt): """Return an ISO-8601 formatted string from the provided datetime object""" if not isinstance(dt, datetime.datetime): raise TypeError("Must provide datetime.datetime object to isoformat") if dt.tzinfo is None: raise ValueError("naive datetime objects are not allowed beyon...
[ "def", "isoformat", "(", "dt", ")", ":", "if", "not", "isinstance", "(", "dt", ",", "datetime", ".", "datetime", ")", ":", "raise", "TypeError", "(", "\"Must provide datetime.datetime object to isoformat\"", ")", "if", "dt", ".", "tzinfo", "is", "None", ":", ...
Return an ISO-8601 formatted string from the provided datetime object
[ "Return", "an", "ISO", "-", "8601", "formatted", "string", "from", "the", "provided", "datetime", "object" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/util.py#L72-L80
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.get_filedata
def get_filedata(self, condition=None, page_size=1000): """Return a generator over all results matching the provided condition :param condition: An :class:`.Expression` which defines the condition which must be matched on the filedata that will be retrieved from file data store....
python
def get_filedata(self, condition=None, page_size=1000): """Return a generator over all results matching the provided condition :param condition: An :class:`.Expression` which defines the condition which must be matched on the filedata that will be retrieved from file data store....
[ "def", "get_filedata", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "condition", "=", "validate_type", "(", "condition", ",", "type", "(", "None", ")", ",", "Expression", ",", "*", "six", ".", "string_types", ")", ...
Return a generator over all results matching the provided condition :param condition: An :class:`.Expression` which defines the condition which must be matched on the filedata that will be retrieved from file data store. If a condition is unspecified, the following condition ...
[ "Return", "a", "generator", "over", "all", "results", "matching", "the", "provided", "condition" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L30-L54
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.write_file
def write_file(self, path, name, data, content_type=None, archive=False, raw=False): """Write a file to the file data store at the given path :param str path: The path (directory) into which the file should be written. :param str name: The name of the file to be written. ...
python
def write_file(self, path, name, data, content_type=None, archive=False, raw=False): """Write a file to the file data store at the given path :param str path: The path (directory) into which the file should be written. :param str name: The name of the file to be written. ...
[ "def", "write_file", "(", "self", ",", "path", ",", "name", ",", "data", ",", "content_type", "=", "None", ",", "archive", "=", "False", ",", "raw", "=", "False", ")", ":", "path", "=", "validate_type", "(", "path", ",", "*", "six", ".", "string_type...
Write a file to the file data store at the given path :param str path: The path (directory) into which the file should be written. :param str name: The name of the file to be written. :param data: The binary data that should be written into the file. :type data: str (Python2) or bytes (...
[ "Write", "a", "file", "to", "the", "file", "data", "store", "at", "the", "given", "path" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L56-L108
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.delete_file
def delete_file(self, path): """Delete a file or directory from the filedata store This method removes a file or directory (recursively) from the filedata store. :param path: The path of the file or directory to remove from the file data store. """ path = v...
python
def delete_file(self, path): """Delete a file or directory from the filedata store This method removes a file or directory (recursively) from the filedata store. :param path: The path of the file or directory to remove from the file data store. """ path = v...
[ "def", "delete_file", "(", "self", ",", "path", ")", ":", "path", "=", "validate_type", "(", "path", ",", "*", "six", ".", "string_types", ")", "if", "not", "path", ".", "startswith", "(", "\"/\"", ")", ":", "path", "=", "\"/\"", "+", "path", "self",...
Delete a file or directory from the filedata store This method removes a file or directory (recursively) from the filedata store. :param path: The path of the file or directory to remove from the file data store.
[ "Delete", "a", "file", "or", "directory", "from", "the", "filedata", "store" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L110-L124
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataAPI.walk
def walk(self, root="~/"): """Emulation of os.walk behavior against Device Cloud filedata store This method will yield tuples in the form ``(dirpath, FileDataDirectory's, FileData's)`` recursively in pre-order (depth first from top down). :param str root: The root path from which the s...
python
def walk(self, root="~/"): """Emulation of os.walk behavior against Device Cloud filedata store This method will yield tuples in the form ``(dirpath, FileDataDirectory's, FileData's)`` recursively in pre-order (depth first from top down). :param str root: The root path from which the s...
[ "def", "walk", "(", "self", ",", "root", "=", "\"~/\"", ")", ":", "root", "=", "validate_type", "(", "root", ",", "*", "six", ".", "string_types", ")", "directories", "=", "[", "]", "files", "=", "[", "]", "# fd_path is real picky", "query_fd_path", "=",...
Emulation of os.walk behavior against Device Cloud filedata store This method will yield tuples in the form ``(dirpath, FileDataDirectory's, FileData's)`` recursively in pre-order (depth first from top down). :param str root: The root path from which the search should commence. By default, th...
[ "Emulation", "of", "os", ".", "walk", "behavior", "against", "Device", "Cloud", "filedata", "store" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L126-L160
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataObject.get_data
def get_data(self): """Get the data associated with this filedata object :returns: Data associated with this object or None if none exists :rtype: str (Python2)/bytes (Python3) or None """ # NOTE: we assume that the "embed" option is used base64_data = self._json_data.g...
python
def get_data(self): """Get the data associated with this filedata object :returns: Data associated with this object or None if none exists :rtype: str (Python2)/bytes (Python3) or None """ # NOTE: we assume that the "embed" option is used base64_data = self._json_data.g...
[ "def", "get_data", "(", "self", ")", ":", "# NOTE: we assume that the \"embed\" option is used", "base64_data", "=", "self", ".", "_json_data", ".", "get", "(", "\"fdData\"", ")", "if", "base64_data", "is", "None", ":", "return", "None", "else", ":", "# need to co...
Get the data associated with this filedata object :returns: Data associated with this object or None if none exists :rtype: str (Python2)/bytes (Python3) or None
[ "Get", "the", "data", "associated", "with", "this", "filedata", "object" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L182-L195
digidotcom/python-devicecloud
devicecloud/filedata.py
FileDataDirectory.write_file
def write_file(self, *args, **kwargs): """Write a file into this directory This method takes the same arguments as :meth:`.FileDataAPI.write_file` with the exception of the ``path`` argument which is not needed here. """ return self._fdapi.write_file(self.get_path(), *args, **k...
python
def write_file(self, *args, **kwargs): """Write a file into this directory This method takes the same arguments as :meth:`.FileDataAPI.write_file` with the exception of the ``path`` argument which is not needed here. """ return self._fdapi.write_file(self.get_path(), *args, **k...
[ "def", "write_file", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "_fdapi", ".", "write_file", "(", "self", ".", "get_path", "(", ")", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Write a file into this directory This method takes the same arguments as :meth:`.FileDataAPI.write_file` with the exception of the ``path`` argument which is not needed here.
[ "Write", "a", "file", "into", "this", "directory" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/filedata.py#L259-L266
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.create_tcp_monitor
def create_tcp_monitor(self, topics, batch_size=1, batch_duration=0, compression='gzip', format_type='json'): """Creates a TCP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDat...
python
def create_tcp_monitor(self, topics, batch_size=1, batch_duration=0, compression='gzip', format_type='json'): """Creates a TCP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDat...
[ "def", "create_tcp_monitor", "(", "self", ",", "topics", ",", "batch_size", "=", "1", ",", "batch_duration", "=", "0", ",", "compression", "=", "'gzip'", ",", "format_type", "=", "'json'", ")", ":", "monitor_xml", "=", "\"\"\"\\\n <Monitor>\n <mo...
Creates a TCP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDataCore']). :param batch_size: How many Msgs received before sending data. :param batch_duration: How long to wait before sending batc...
[ "Creates", "a", "TCP", "Monitor", "instance", "in", "Device", "Cloud", "for", "a", "given", "list", "of", "topics" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L176-L211
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.create_http_monitor
def create_http_monitor(self, topics, transport_url, transport_token=None, transport_method='PUT', connect_timeout=0, response_timeout=0, batch_size=1, batch_duration=0, compression='none', format_type='json'): """Creates a HTTP Monitor instance in Device Cloud for a given list of to...
python
def create_http_monitor(self, topics, transport_url, transport_token=None, transport_method='PUT', connect_timeout=0, response_timeout=0, batch_size=1, batch_duration=0, compression='none', format_type='json'): """Creates a HTTP Monitor instance in Device Cloud for a given list of to...
[ "def", "create_http_monitor", "(", "self", ",", "topics", ",", "transport_url", ",", "transport_token", "=", "None", ",", "transport_method", "=", "'PUT'", ",", "connect_timeout", "=", "0", ",", "response_timeout", "=", "0", ",", "batch_size", "=", "1", ",", ...
Creates a HTTP Monitor instance in Device Cloud for a given list of topics :param topics: a string list of topics (e.g. ['DeviceCore[U]', 'FileDataCore']). :param transport_url: URL of the customer web server. :param transport_token: Credentials for basic authentication in the...
[ "Creates", "a", "HTTP", "Monitor", "instance", "in", "Device", "Cloud", "for", "a", "given", "list", "of", "topics" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L213-L263
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.get_monitors
def get_monitors(self, condition=None, page_size=1000): """Return an iterator over all monitors matching the provided condition Get all inactive monitors and print id:: for mon in dc.monitor.get_monitors(MON_STATUS_ATTR == "DISABLED"): print(mon.get_id()) Get all t...
python
def get_monitors(self, condition=None, page_size=1000): """Return an iterator over all monitors matching the provided condition Get all inactive monitors and print id:: for mon in dc.monitor.get_monitors(MON_STATUS_ATTR == "DISABLED"): print(mon.get_id()) Get all t...
[ "def", "get_monitors", "(", "self", ",", "condition", "=", "None", ",", "page_size", "=", "1000", ")", ":", "req_kwargs", "=", "{", "}", "if", "condition", ":", "req_kwargs", "[", "'condition'", "]", "=", "condition", ".", "compile", "(", ")", "for", "...
Return an iterator over all monitors matching the provided condition Get all inactive monitors and print id:: for mon in dc.monitor.get_monitors(MON_STATUS_ATTR == "DISABLED"): print(mon.get_id()) Get all the HTTP monitors and print id:: for mon in dc.monitor....
[ "Return", "an", "iterator", "over", "all", "monitors", "matching", "the", "provided", "condition" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L265-L294
digidotcom/python-devicecloud
devicecloud/monitor.py
MonitorAPI.get_monitor
def get_monitor(self, topics): """Attempts to find a Monitor in device cloud that matches the provided topics :param topics: a string list of topics (e.g. ``['DeviceCore[U]', 'FileDataCore'])``) Returns a :class:`DeviceCloudMonitor` if found, otherwise None. """ for monitor in ...
python
def get_monitor(self, topics): """Attempts to find a Monitor in device cloud that matches the provided topics :param topics: a string list of topics (e.g. ``['DeviceCore[U]', 'FileDataCore'])``) Returns a :class:`DeviceCloudMonitor` if found, otherwise None. """ for monitor in ...
[ "def", "get_monitor", "(", "self", ",", "topics", ")", ":", "for", "monitor", "in", "self", ".", "get_monitors", "(", "MON_TOPIC_ATTR", "==", "\",\"", ".", "join", "(", "topics", ")", ")", ":", "return", "monitor", "# return the first one, even if there are mult...
Attempts to find a Monitor in device cloud that matches the provided topics :param topics: a string list of topics (e.g. ``['DeviceCore[U]', 'FileDataCore'])``) Returns a :class:`DeviceCloudMonitor` if found, otherwise None.
[ "Attempts", "to", "find", "a", "Monitor", "in", "device", "cloud", "that", "matches", "the", "provided", "topics" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/monitor.py#L296-L305
digidotcom/python-devicecloud
devicecloud/streams.py
_get_encoder_method
def _get_encoder_method(stream_type): """A function to get the python type to device cloud type converter function. :param stream_type: The streams data type :return: A function that when called with the python object will return the serializable type for sending to the cloud. If there is no function f...
python
def _get_encoder_method(stream_type): """A function to get the python type to device cloud type converter function. :param stream_type: The streams data type :return: A function that when called with the python object will return the serializable type for sending to the cloud. If there is no function f...
[ "def", "_get_encoder_method", "(", "stream_type", ")", ":", "if", "stream_type", "is", "not", "None", ":", "return", "DSTREAM_TYPE_MAP", ".", "get", "(", "stream_type", ".", "upper", "(", ")", ",", "(", "lambda", "x", ":", "x", ",", "lambda", "x", ":", ...
A function to get the python type to device cloud type converter function. :param stream_type: The streams data type :return: A function that when called with the python object will return the serializable type for sending to the cloud. If there is no function for the given type, or the `stream_type` i...
[ "A", "function", "to", "get", "the", "python", "type", "to", "device", "cloud", "type", "converter", "function", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L66-L77
digidotcom/python-devicecloud
devicecloud/streams.py
_get_decoder_method
def _get_decoder_method(stream_type): """ A function to get Device Cloud type to python type converter function. :param stream_type: The streams data type :return: A function that when called with Device Cloud object will return the python native type. If there is no function for the given type, or the...
python
def _get_decoder_method(stream_type): """ A function to get Device Cloud type to python type converter function. :param stream_type: The streams data type :return: A function that when called with Device Cloud object will return the python native type. If there is no function for the given type, or the...
[ "def", "_get_decoder_method", "(", "stream_type", ")", ":", "if", "stream_type", "is", "not", "None", ":", "return", "DSTREAM_TYPE_MAP", ".", "get", "(", "stream_type", ".", "upper", "(", ")", ",", "(", "lambda", "x", ":", "x", ",", "lambda", "x", ":", ...
A function to get Device Cloud type to python type converter function. :param stream_type: The streams data type :return: A function that when called with Device Cloud object will return the python native type. If there is no function for the given type, or the `stream_type` is `None` the returned func...
[ "A", "function", "to", "get", "Device", "Cloud", "type", "to", "python", "type", "converter", "function", "." ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L80-L91
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI._get_streams
def _get_streams(self, uri_suffix=None): """Clear and update internal cache of stream objects""" # TODO: handle paging, perhaps change this to be a generator if uri_suffix is not None and not uri_suffix.startswith('/'): uri_suffix = '/' + uri_suffix elif uri_suffix is None: ...
python
def _get_streams(self, uri_suffix=None): """Clear and update internal cache of stream objects""" # TODO: handle paging, perhaps change this to be a generator if uri_suffix is not None and not uri_suffix.startswith('/'): uri_suffix = '/' + uri_suffix elif uri_suffix is None: ...
[ "def", "_get_streams", "(", "self", ",", "uri_suffix", "=", "None", ")", ":", "# TODO: handle paging, perhaps change this to be a generator", "if", "uri_suffix", "is", "not", "None", "and", "not", "uri_suffix", ".", "startswith", "(", "'/'", ")", ":", "uri_suffix", ...
Clear and update internal cache of stream objects
[ "Clear", "and", "update", "internal", "cache", "of", "stream", "objects" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L116-L129
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI.create_stream
def create_stream(self, stream_id, data_type, description=None, data_ttl=None, rollup_ttl=None, units=None): """Create a new data stream on Device Cloud This method will attempt to create a new data stream on Device Cloud. This method will only succeed if the stream does n...
python
def create_stream(self, stream_id, data_type, description=None, data_ttl=None, rollup_ttl=None, units=None): """Create a new data stream on Device Cloud This method will attempt to create a new data stream on Device Cloud. This method will only succeed if the stream does n...
[ "def", "create_stream", "(", "self", ",", "stream_id", ",", "data_type", ",", "description", "=", "None", ",", "data_ttl", "=", "None", ",", "rollup_ttl", "=", "None", ",", "units", "=", "None", ")", ":", "stream_id", "=", "validate_type", "(", "stream_id"...
Create a new data stream on Device Cloud This method will attempt to create a new data stream on Device Cloud. This method will only succeed if the stream does not already exist. :param str stream_id: The path/id of the stream being created on Device Cloud. :param str data_type: The ty...
[ "Create", "a", "new", "data", "stream", "on", "Device", "Cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L131-L173
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI.get_stream_if_exists
def get_stream_if_exists(self, stream_id): """Return a reference to a stream with the given ``stream_id`` if it exists This works similar to :py:meth:`get_stream` but will return None if the stream is not already created. :param stream_id: The path of the stream on Device Cloud ...
python
def get_stream_if_exists(self, stream_id): """Return a reference to a stream with the given ``stream_id`` if it exists This works similar to :py:meth:`get_stream` but will return None if the stream is not already created. :param stream_id: The path of the stream on Device Cloud ...
[ "def", "get_stream_if_exists", "(", "self", ",", "stream_id", ")", ":", "stream", "=", "self", ".", "get_stream", "(", "stream_id", ")", "try", ":", "stream", ".", "get_data_type", "(", "use_cached", "=", "True", ")", "except", "NoSuchStreamException", ":", ...
Return a reference to a stream with the given ``stream_id`` if it exists This works similar to :py:meth:`get_stream` but will return None if the stream is not already created. :param stream_id: The path of the stream on Device Cloud :raises TypeError: if the stream_id provided is the w...
[ "Return", "a", "reference", "to", "a", "stream", "with", "the", "given", "stream_id", "if", "it", "exists" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L203-L222
digidotcom/python-devicecloud
devicecloud/streams.py
StreamsAPI.bulk_write_datapoints
def bulk_write_datapoints(self, datapoints): """Perform a bulk write (or set of writes) of a collection of data points This method takes a list (or other iterable) of datapoints and writes them to Device Cloud in an efficient manner, minimizing the number of HTTP requests that need to b...
python
def bulk_write_datapoints(self, datapoints): """Perform a bulk write (or set of writes) of a collection of data points This method takes a list (or other iterable) of datapoints and writes them to Device Cloud in an efficient manner, minimizing the number of HTTP requests that need to b...
[ "def", "bulk_write_datapoints", "(", "self", ",", "datapoints", ")", ":", "datapoints", "=", "list", "(", "datapoints", ")", "# effectively performs validation that we have the right type", "for", "dp", "in", "datapoints", ":", "if", "not", "isinstance", "(", "dp", ...
Perform a bulk write (or set of writes) of a collection of data points This method takes a list (or other iterable) of datapoints and writes them to Device Cloud in an efficient manner, minimizing the number of HTTP requests that need to be made. As this call is performed from outside ...
[ "Perform", "a", "bulk", "write", "(", "or", "set", "of", "writes", ")", "of", "a", "collection", "of", "data", "points" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L224-L283
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.from_json
def from_json(cls, stream, json_data): """Create a new DataPoint object from device cloud JSON data :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: i...
python
def from_json(cls, stream, json_data): """Create a new DataPoint object from device cloud JSON data :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: i...
[ "def", "from_json", "(", "cls", ",", "stream", ",", "json_data", ")", ":", "type_converter", "=", "_get_decoder_method", "(", "stream", ".", "get_data_type", "(", ")", ")", "data", "=", "type_converter", "(", "json_data", ".", "get", "(", "\"data\"", ")", ...
Create a new DataPoint object from device cloud JSON data :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: if the data is malformed :return: (:class:`...
[ "Create", "a", "new", "DataPoint", "object", "from", "device", "cloud", "JSON", "data" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L296-L321
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.from_rollup_json
def from_rollup_json(cls, stream, json_data): """Rollup json data from the server looks slightly different :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueE...
python
def from_rollup_json(cls, stream, json_data): """Rollup json data from the server looks slightly different :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueE...
[ "def", "from_rollup_json", "(", "cls", ",", "stream", ",", "json_data", ")", ":", "dp", "=", "cls", ".", "from_json", "(", "stream", ",", "json_data", ")", "# Special handling for timestamp", "timestamp", "=", "isoformat", "(", "dc_utc_timestamp_to_dt", "(", "in...
Rollup json data from the server looks slightly different :param DataStream stream: The :class:`~DataStream` out of which this data is coming :param dict json_data: Deserialized JSON data from Device Cloud about this device :raises ValueError: if the data is malformed :return: (:class:`...
[ "Rollup", "json", "data", "from", "the", "server", "looks", "slightly", "different" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L324-L344
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_stream_id
def set_stream_id(self, stream_id): """Set the stream id associated with this data point""" stream_id = validate_type(stream_id, type(None), *six.string_types) if stream_id is not None: stream_id = stream_id.lstrip('/') self._stream_id = stream_id
python
def set_stream_id(self, stream_id): """Set the stream id associated with this data point""" stream_id = validate_type(stream_id, type(None), *six.string_types) if stream_id is not None: stream_id = stream_id.lstrip('/') self._stream_id = stream_id
[ "def", "set_stream_id", "(", "self", ",", "stream_id", ")", ":", "stream_id", "=", "validate_type", "(", "stream_id", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")", "if", "stream_id", "is", "not", "None", ":", "stream_id", "=",...
Set the stream id associated with this data point
[ "Set", "the", "stream", "id", "associated", "with", "this", "data", "point" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L429-L434
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_description
def set_description(self, description): """Set the description for this data point""" self._description = validate_type(description, type(None), *six.string_types)
python
def set_description(self, description): """Set the description for this data point""" self._description = validate_type(description, type(None), *six.string_types)
[ "def", "set_description", "(", "self", ",", "description", ")", ":", "self", ".", "_description", "=", "validate_type", "(", "description", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")" ]
Set the description for this data point
[ "Set", "the", "description", "for", "this", "data", "point" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L440-L442
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_quality
def set_quality(self, quality): """Set the quality for this sample Quality is stored on Device Cloud as a 32-bit integer, so the input to this function should be either None, an integer, or a string that can be converted to an integer. """ if isinstance(quality, *six.st...
python
def set_quality(self, quality): """Set the quality for this sample Quality is stored on Device Cloud as a 32-bit integer, so the input to this function should be either None, an integer, or a string that can be converted to an integer. """ if isinstance(quality, *six.st...
[ "def", "set_quality", "(", "self", ",", "quality", ")", ":", "if", "isinstance", "(", "quality", ",", "*", "six", ".", "string_types", ")", ":", "quality", "=", "int", "(", "quality", ")", "elif", "isinstance", "(", "quality", ",", "float", ")", ":", ...
Set the quality for this sample Quality is stored on Device Cloud as a 32-bit integer, so the input to this function should be either None, an integer, or a string that can be converted to an integer.
[ "Set", "the", "quality", "for", "this", "sample" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L475-L488
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_location
def set_location(self, location): """Set the location for this data point The location must be either None (if no location data is known) or a 3-tuple of floating point values in the form (latitude-degrees, longitude-degrees, altitude-meters). """ if location is None: ...
python
def set_location(self, location): """Set the location for this data point The location must be either None (if no location data is known) or a 3-tuple of floating point values in the form (latitude-degrees, longitude-degrees, altitude-meters). """ if location is None: ...
[ "def", "set_location", "(", "self", ",", "location", ")", ":", "if", "location", "is", "None", ":", "self", ".", "_location", "=", "location", "elif", "isinstance", "(", "location", ",", "*", "six", ".", "string_types", ")", ":", "# from device cloud, conver...
Set the location for this data point The location must be either None (if no location data is known) or a 3-tuple of floating point values in the form (latitude-degrees, longitude-degrees, altitude-meters).
[ "Set", "the", "location", "for", "this", "data", "point" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L499-L526
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_data_type
def set_data_type(self, data_type): """Set the data type for ths data point The data type is actually associated with the stream itself and should not (generally) vary on a point-per-point basis. That being said, if creating a new stream by writing a datapoint, it may be beneficial to ...
python
def set_data_type(self, data_type): """Set the data type for ths data point The data type is actually associated with the stream itself and should not (generally) vary on a point-per-point basis. That being said, if creating a new stream by writing a datapoint, it may be beneficial to ...
[ "def", "set_data_type", "(", "self", ",", "data_type", ")", ":", "validate_type", "(", "data_type", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")", "if", "isinstance", "(", "data_type", ",", "*", "six", ".", "string_types", ")",...
Set the data type for ths data point The data type is actually associated with the stream itself and should not (generally) vary on a point-per-point basis. That being said, if creating a new stream by writing a datapoint, it may be beneficial to include this information. The ...
[ "Set", "the", "data", "type", "for", "ths", "data", "point" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L539-L556
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.set_units
def set_units(self, unit): """Set the unit for this data point Unit, as with data_type, are actually associated with the stream and not the individual data point. As such, changing this within a stream is not encouraged. Setting the unit on the data point is useful when the st...
python
def set_units(self, unit): """Set the unit for this data point Unit, as with data_type, are actually associated with the stream and not the individual data point. As such, changing this within a stream is not encouraged. Setting the unit on the data point is useful when the st...
[ "def", "set_units", "(", "self", ",", "unit", ")", ":", "self", ".", "_units", "=", "validate_type", "(", "unit", ",", "type", "(", "None", ")", ",", "*", "six", ".", "string_types", ")" ]
Set the unit for this data point Unit, as with data_type, are actually associated with the stream and not the individual data point. As such, changing this within a stream is not encouraged. Setting the unit on the data point is useful when the stream might be created with the write o...
[ "Set", "the", "unit", "for", "this", "data", "point" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L562-L571
digidotcom/python-devicecloud
devicecloud/streams.py
DataPoint.to_xml
def to_xml(self): """Convert this datapoint into a form suitable for pushing to device cloud An XML string will be returned that will contain all pieces of information set on this datapoint. Values not set (e.g. quality) will be ommitted. """ type_converter = _get_encoder_meth...
python
def to_xml(self): """Convert this datapoint into a form suitable for pushing to device cloud An XML string will be returned that will contain all pieces of information set on this datapoint. Values not set (e.g. quality) will be ommitted. """ type_converter = _get_encoder_meth...
[ "def", "to_xml", "(", "self", ")", ":", "type_converter", "=", "_get_encoder_method", "(", "self", ".", "_data_type", ")", "# Convert from python native to device cloud", "encoded_data", "=", "type_converter", "(", "self", ".", "_data", ")", "out", "=", "StringIO", ...
Convert this datapoint into a form suitable for pushing to device cloud An XML string will be returned that will contain all pieces of information set on this datapoint. Values not set (e.g. quality) will be ommitted.
[ "Convert", "this", "datapoint", "into", "a", "form", "suitable", "for", "pushing", "to", "device", "cloud" ]
train
https://github.com/digidotcom/python-devicecloud/blob/32529684a348a7830a269c32601604c78036bcb8/devicecloud/streams.py#L573-L597