INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Starts up the imolecule server complete with argparse handling.
def start_server(): """Starts up the imolecule server, complete with argparse handling.""" parser = argparse.ArgumentParser(description="Opens a browser-based " "client that interfaces with the " "chemical format converter.") parser.a...
Evaluates the function pointed to by json - rpc.
def on_message(self, message): """Evaluates the function pointed to by json-rpc.""" json_rpc = json.loads(message) logging.log(logging.DEBUG, json_rpc) if self.pool is None: self.pool = multiprocessing.Pool(processes=args.workers) # Spawn a process to protect the se...
implementation based on:
def nearly_eq(valA, valB, maxf=None, minf=None, epsilon=None): ''' implementation based on: http://floating-point-gui.de/errors/comparison/ ''' if valA == valB: return True if maxf is None: maxf = float_info.max if minf is None: minf = float_info.min if epsil...
: other: Point or point equivalent: ignorescalars: optional boolean: return: Point
def _convert(cls, other, ignoreScalars=False): ''' :other: Point or point equivalent :ignorescalars: optional boolean :return: Point Class private method for converting 'other' into a Point subclasss. If 'other' already is a Point subclass, nothing is done. If ig...
: scale: optional integer scaling factor: return: list of three Point subclass
def units(cls, scale=1): ''' :scale: optional integer scaling factor :return: list of three Point subclass Returns three points whose coordinates are the head of a unit vector from the origin ( conventionally i, j and k). ''' return [cls(x=scale), cls(y=scale), ...
: mu: mean: sigma: standard deviation: return: Point subclass
def gaussian(cls, mu=0, sigma=1): ''' :mu: mean :sigma: standard deviation :return: Point subclass Returns a point whose coordinates are picked from a Gaussian distribution with mean 'mu' and standard deviation 'sigma'. See random.gauss for further explanati...
: origin: optional Point or point equivalent: radius: optional float radius around origin: return: Point subclass
def random(cls, origin=None, radius=1): ''' :origin: optional Point or point equivalent :radius: optional float, radius around origin :return: Point subclass Returns a point with random x, y and z coordinates bounded by the sphere defined by (origin,radius). If ...
: other: Point or point equivalent: func: binary function to apply: inplace: optional boolean: return: Point
def _binary_(self, other, func, inplace=False): ''' :other: Point or point equivalent :func: binary function to apply :inplace: optional boolean :return: Point Implementation private method. All of the binary operations funnel thru this method to r...
: func: unary function to apply to each coordinate: inplace: optional boolean: return: Point
def _unary_(self, func, inplace=False): ''' :func: unary function to apply to each coordinate :inplace: optional boolean :return: Point Implementation private method. All of the unary operations funnel thru this method to reduce cut-and-paste code and enforce co...
: other: Point or point equivalent: return: float
def cross(self, other): ''' :other: Point or point equivalent :return: float Vector cross product of points U (self) and V (other), computed: U x V = (u1*i + u2*j + u3*k) x (v1*i + v2*j + v3*k) s1 = u2v3 - u3v2 s2 = u3v1 - u1v3 s3 = u1v2 - u2v1 ...
: a: Point or point equivalent: b: Point or point equivalent: axis: optional string: return: float
def isBetween(self, a, b, axes='xyz'): ''' :a: Point or point equivalent :b: Point or point equivalent :axis: optional string :return: float Checks the coordinates specified in 'axes' of 'self' to determine if they are bounded by 'a' and 'b'. The range is...
: b: Point or point equivalent: c: Point or point equivalent: axis: optional string or integer in set ( x 0 y 1 z 2 ): return: float
def ccw(self, b, c, axis='z'): ''' :b: Point or point equivalent :c: Point or point equivalent :axis: optional string or integer in set('x',0,'y',1,'z',2) :return: float CCW - Counter Clockwise Returns an integer signifying the direction of rotation around 'axis...
: b: Point or point equivalent: c: Point or point equivalent: axis: optional string or integer in set ( x 0 y 1 z 2 ): return: boolean
def isCCW(self, b, c, axis='z'): ''' :b: Point or point equivalent :c: Point or point equivalent :axis: optional string or integer in set('x',0,'y',1,'z',2) :return: boolean True if the angle determined by a,self,b around 'axis' describes a counter-clockwise rota...
: b: Point or point equivalent: c: Point or point equivalent: return: boolean
def isCollinear(self, b, c): ''' :b: Point or point equivalent :c: Point or point equivalent :return: boolean True if 'self' is collinear with 'b' and 'c', otherwise False. ''' return all(self.ccw(b, c, axis) == 0 for axis in self._keys)
: theta: float radians to rotate self around origin: origin: optional Point defaults to 0 0 0
def rotate2d(self, theta, origin=None, axis='z', radians=False): ''' :theta: float radians to rotate self around origin :origin: optional Point, defaults to 0,0,0 Returns a Point rotated by :theta: around :origin:. ''' origin = Point._convert(origin) delta = se...
: origin: optional Point: alpha: optional float describing length of the side opposite A: beta: optional float describing length of the side opposite B: gamma: optional float describing length of the side opposite C: return: Triangle initialized with points comprising the triangle with the specified angles.
def withAngles(cls, origin=None, base=1, alpha=None, beta=None, gamma=None, inDegrees=False): ''' :origin: optional Point :alpha: optional float describing length of the side opposite A :beta: optional float describing length of the side opposite B :gamma: opti...
Heron s forumla for computing the area of a triangle float.
def heronsArea(self): ''' Heron's forumla for computing the area of a triangle, float. Performance note: contains a square root. ''' s = self.semiperimeter return math.sqrt(s * ((s - self.a) * (s - self.b) * (s - self.c)))
Distance from the circumcenter to all the verticies in the Triangle float.
def circumradius(self): ''' Distance from the circumcenter to all the verticies in the Triangle, float. ''' return (self.a * self.b * self.c) / (self.area * 4)
A list of the altitudes of each vertex [ AltA AltB AltC ] list of floats.
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]
True iff two side lengths are equal boolean.
def isIsosceles(self): ''' True iff two side lengths are equal, boolean. ''' return (self.a == self.b) or (self.a == self.c) or (self.b == self.c)
A congruent B
def congruent(self, other): ''' A congruent B True iff all angles of 'A' equal angles in 'B' and all side lengths of 'A' equal all side lengths of 'B', boolean. ''' a = set(self.angles) b = set(other.angles) if len(a) != len(b) or len(a.difference(b)) ...
Center point of the ellipse equidistant from foci Point class. \ n Defaults to the origin.
def center(self): ''' Center point of the ellipse, equidistant from foci, Point class.\n Defaults to the origin. ''' try: return self._center except AttributeError: pass self._center = Point() return self._center
Radius of the ellipse Point class.
def radius(self): ''' Radius of the ellipse, Point class. ''' try: return self._radius except AttributeError: pass self._radius = Point(1, 1, 0) return self._radius
Returns True if the major axis is parallel to the X axis boolean.
def xAxisIsMajor(self): ''' Returns True if the major axis is parallel to the X axis, boolean. ''' return max(self.radius.x, self.radius.y) == self.radius.x
Returns True if the minor axis is parallel to the X axis boolean.
def xAxisIsMinor(self): ''' Returns True if the minor axis is parallel to the X axis, boolean. ''' return min(self.radius.x, self.radius.y) == self.radius.x
Returns True if the major axis is parallel to the Y axis boolean.
def yAxisIsMajor(self): ''' Returns True if the major axis is parallel to the Y axis, boolean. ''' return max(self.radius.x, self.radius.y) == self.radius.y
Returns True if the minor axis is parallel to the Y axis boolean.
def yAxisIsMinor(self): ''' Returns True if the minor axis is parallel to the Y axis, boolean. ''' return min(self.radius.x, self.radius.y) == self.radius.y
Positive antipodal point on the major axis Point class.
def a(self): ''' Positive antipodal point on the major axis, Point class. ''' a = Point(self.center) if self.xAxisIsMajor: a.x += self.majorRadius else: a.y += self.majorRadius return a
Negative antipodal point on the major axis Point class.
def a_neg(self): ''' Negative antipodal point on the major axis, Point class. ''' na = Point(self.center) if self.xAxisIsMajor: na.x -= self.majorRadius else: na.y -= self.majorRadius return na
Positive antipodal point on the minor axis Point class.
def b(self): ''' Positive antipodal point on the minor axis, Point class. ''' b = Point(self.center) if self.xAxisIsMinor: b.x += self.minorRadius else: b.y += self.minorRadius return b
Negative antipodal point on the minor axis Point class.
def b_neg(self): ''' Negative antipodal point on the minor axis, Point class. ''' nb = Point(self.center) if self.xAxisIsMinor: nb.x -= self.minorRadius else: nb.y -= self.minorRadius return nb
A dictionary of four points where the axes intersect the ellipse dict.
def vertices(self): ''' A dictionary of four points where the axes intersect the ellipse, dict. ''' return {'a': self.a, 'a_neg': self.a_neg, 'b': self.b, 'b_neg': self.b_neg}
First focus of the ellipse Point class.
def focus0(self): ''' First focus of the ellipse, Point class. ''' f = Point(self.center) if self.xAxisIsMajor: f.x -= self.linearEccentricity else: f.y -= self.linearEccentricity return f
: param: triangle - Triangle class: return: Circle class
def circumcircleForTriangle(cls, triangle): ''' :param: triangle - Triangle class :return: Circle class Returns the circle where every vertex in the input triangle is on the radius of that circle. ''' if triangle.isRight: # circumcircle origin is th...
: param: other - Circle class
def doesIntersect(self, other): ''' :param: other - Circle class Returns True iff: self.center.distance(other.center) <= self.radius+other.radius ''' otherType = type(other) if issubclass(otherType, Ellipse): distance = self.center.distance(other....
A list containing Points A and B.
def AB(self): ''' A list containing Points A and B. ''' try: return self._AB except AttributeError: pass self._AB = [self.A, self.B] return self._AB
: return: Line
def normal(self): ''' :return: Line Returns a Line normal (perpendicular) to this Line. ''' d = self.B - self.A return Line([-d.y, d.x], [d.y, -d.x])
: point: Point subclass: return: float
def t(self, point): ''' :point: Point subclass :return: float If :point: is collinear, determine the 't' coefficient of the parametric equation: xyz = A<xyz> + t ( B<xyz> - A<xyz> ) if t < 0, point is less than A and B on the line if t >= 0 and <= 1, po...
: returns: None
def flip(self): ''' :returns: None Swaps the positions of A and B. ''' tmp = self.A.xyz self.A = self.B self.B = tmp
: param: other - Line subclass: return: boolean
def doesIntersect(self, other): ''' :param: other - Line subclass :return: boolean Returns True iff: ccw(self.A,self.B,other.A) * ccw(self.A,self.B,other.B) <= 0 and ccw(other.A,other.B,self.A) * ccw(other.A,other.B,self.B) <= 0 ''' if s...
: param: other - Line subclass: return: Point subclass
def intersection(self, other): ''' :param: other - Line subclass :return: Point subclass Returns a Point object with the coordinates of the intersection between the current line and the other line. Will raise Parallel() if the two lines are parallel. Will raise ...
: param: point - Point subclass: return: float
def distanceFromPoint(self, point): ''' :param: point - Point subclass :return: float Distance from the line to the given point. ''' # XXX planar distance, doesn't take into account z ? d = self.m n = (d.y * point.x) - (d.x * point.y) + self.A.cross(self....
: param: other - Line subclass: return: float
def radiansBetween(self, other): ''' :param: other - Line subclass :return: float Returns the angle measured between two lines in radians with a range of [0, 2 * math.pi]. ''' # a dot b = |a||b| * cos(theta) # a dot b / |a||b| = cos(theta) # cos-...
: name: string - property name: default: float - property default value: readonly: boolean - if True setter method is NOT generated
def FloatProperty(name, default=0.0, readonly=False, docs=None): ''' :name: string - property name :default: float - property default value :readonly: boolean - if True, setter method is NOT generated Returns a property object that can be used to initialize a class instance variable as a proper...
: param: radius - float: param: widthLimits - iterable of floats with length > = 2: param: heightLimits - iterable of floats with length > = 2: param: origin - optional Point subclass: return: Rectangle
def randomSizeAndLocation(cls, radius, widthLimits, heightLimits, origin=None): ''' :param: radius - float :param: widthLimits - iterable of floats with length >= 2 :param: heightLimits - iterable of floats with length >= 2 :param: origin ...
: param: widthLimits - iterable of integers with length > = 2: param: heightLimits - iterable of integers with length > = 2: param: origin - optional Point subclass: return: Rectangle
def randomSize(cls, widthLimits, heightLimits, origin=None): ''' :param: widthLimits - iterable of integers with length >= 2 :param: heightLimits - iterable of integers with length >= 2 :param: origin - optional Point subclass :return: Rectangle ''' r = cl...
: param: radius - float: param: width - float: param: height - float: param: origin - optional Point subclass: return: Rectangle
def randomLocation(cls, radius, width, height, origin=None): ''' :param: radius - float :param: width - float :param: height - float :param: origin - optional Point subclass :return: Rectangle ''' return cls(width, height, ...
Point describing the origin of the rectangle. Defaults to ( 0 0 0 ).
def origin(self): ''' Point describing the origin of the rectangle. Defaults to (0,0,0). ''' try: return self._origin except AttributeError: pass self._origin = Point() return self._origin
Point whose coordinates are ( maxX minY origin. z ) Point.
def B(self): ''' Point whose coordinates are (maxX,minY,origin.z), Point. ''' return Point(self.maxX, self.minY, self.origin.z)
Point whose coordinates are ( maxX maxY origin. z ) Point.
def C(self): ''' Point whose coordinates are (maxX,maxY,origin.z), Point. ''' return Point(self.maxX, self.maxY, self.origin.z)
Point whose coordinates are ( minX maxY origin. Z ) Point.
def D(self): ''' Point whose coordinates are (minX,maxY,origin.Z), Point. ''' return Point(self.minX, self.maxY, self.origin.z)
Point whose coordinates are ( midX midY origin. z ) Point.
def center(self): ''' Point whose coordinates are (midX,midY,origin.z), Point. ''' return Point(self.midX, self.midY, self.origin.z)
: param: dx - optional float: param: dy - optional float
def scale(self, dx=1.0, dy=1.0): ''' :param: dx - optional float :param: dy - optional float Scales the rectangle's width and height by dx and dy. ''' self.width *= dx self.height *= dy
: param: point - Point subclass: param: Zorder - optional Boolean
def containsPoint(self, point, Zorder=False): ''' :param: point - Point subclass :param: Zorder - optional Boolean Is true if the point is contain in the rectangle or along the rectangle's edges. If Zorder is True, the method will check point.z for equality wit...
: origin: - optional Point subclass: radius: - optional float: return: Triangle
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...
: origin: optional Point: side: optional float describing triangle side length: return: Triangle initialized with points comprising a equilateral triangle.
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 =...
: origin: optional Point: base: optional float describing triangle base length: return: Triangle initialized with points comprising a isosceles triangle.
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 ''' ...
Third vertex of triangle Point subclass.
def C(self): ''' Third vertex of triangle, Point subclass. ''' try: return self._C except AttributeError: pass self._C = Point(0, 1) return self._C
A list of the triangle s vertices list.
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
Vertices B and A list.
def BA(self): ''' Vertices B and A, list. ''' try: return self._BA except AttributeError: pass self._BA = [self.B, self.A] return self._BA
Vertices A and C list.
def AC(self): ''' Vertices A and C, list. ''' try: return self._AC except AttributeError: pass self._AC = [self.A, self.C] return self._AC
Vertices C and A list.
def CA(self): ''' Vertices C and A, list. ''' try: return self._CA except AttributeError: pass self._CA = [self.C, self.A] return self._CA
Vertices B and C list.
def BC(self): ''' Vertices B and C, list. ''' try: return self._BC except AttributeError: pass self._BC = [self.B, self.C] return self._BC
Vertices C and B list.
def CB(self): ''' Vertices C and B, list. ''' try: return self._CB except AttributeError: pass self._CB = [self.C, self.B] return self._CB
A list of the Triangle s line segments [ AB BC AC ] list.
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)]
The intersection of the median perpendicular bisectors Point.
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 ...
A list of the altitudes of each vertex [ AltA AltB AltC ] list of floats.
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]
True if all sides of the triangle are the same length.
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...
: side: - optional string: inplace: - optional boolean: return: Triangle with flipped side.
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...
: param: other - Triangle or Line subclass: return: boolean
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...
Sum of the length of all sides float.
def perimeter(self): ''' Sum of the length of all sides, float. ''' return sum([a.distance(b) for a, b in self.pairs()])
Dense sift descriptors from an image.
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...
Converts an RGB image to grayscale using matlab s algorithm.
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 ...
Converts an RGB image to HSV using scikit - image s algorithm.
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...
Parse an SCI command response into ElementTree XML
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...
Parse an error ElementTree Node to create an ErrorInfo object
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...
Get the contents of this file
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]
Delete this file from the device
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) ...
List the contents of this directory
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...
Parse the server response for this ls command
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 ... /> ... ...
Parse the server response for this get file command
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...
Parse the server response for this put file command
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...
Send an arbitrary file system 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...
List all files and directories in the path on the target
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:...
Get the contents of a file on the device
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...
Put data into a file on the device
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...
Delete a file from a device
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...
Get all files and directories from a path on the device modified since a given time
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....
Check if path refers to an existing path on the device
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...
Iterates over each: class: Device for this device cloud account
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...
r Return the root group for this accounts group tree
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...
Return an iterator over all groups in this device cloud account
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 ...
Provision multiple devices with a single API call
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...
Build and return a new Group object from json data ( used internally )
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( ...
Print this group node and the subtree rooted at it
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)
Get the JSON metadata for this device as a python data structure
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...
Get the list of tags for this device
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 [...
Return True if the device is currrently connect and False if not
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
Get the connectware id of this device ( primary key )
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")
Get this device s 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")