id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
600
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_bounding_box
def get_bounding_box(self): """ Compute bounding box for each surface element, and then return the bounding box of all surface elements' bounding boxes. :return: A tuple of four items. These items represent western, eastern, northern and southern borders of the b...
python
def get_bounding_box(self): """ Compute bounding box for each surface element, and then return the bounding box of all surface elements' bounding boxes. :return: A tuple of four items. These items represent western, eastern, northern and southern borders of the b...
[ "def", "get_bounding_box", "(", "self", ")", ":", "lons", "=", "[", "]", "lats", "=", "[", "]", "for", "surf", "in", "self", ".", "surfaces", ":", "west", ",", "east", ",", "north", ",", "south", "=", "surf", ".", "get_bounding_box", "(", ")", "lon...
Compute bounding box for each surface element, and then return the bounding box of all surface elements' bounding boxes. :return: A tuple of four items. These items represent western, eastern, northern and southern borders of the bounding box respectively. Values are...
[ "Compute", "bounding", "box", "for", "each", "surface", "element", "and", "then", "return", "the", "bounding", "box", "of", "all", "surface", "elements", "bounding", "boxes", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L291-L307
601
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_areas
def _get_areas(self): """ Return surface elements area values in a numpy array. """ if self.areas is None: self.areas = [] for surf in self.surfaces: self.areas.append(surf.get_area()) self.areas = numpy.array(self.areas) retur...
python
def _get_areas(self): """ Return surface elements area values in a numpy array. """ if self.areas is None: self.areas = [] for surf in self.surfaces: self.areas.append(surf.get_area()) self.areas = numpy.array(self.areas) retur...
[ "def", "_get_areas", "(", "self", ")", ":", "if", "self", ".", "areas", "is", "None", ":", "self", ".", "areas", "=", "[", "]", "for", "surf", "in", "self", ".", "surfaces", ":", "self", ".", "areas", ".", "append", "(", "surf", ".", "get_area", ...
Return surface elements area values in a numpy array.
[ "Return", "surface", "elements", "area", "values", "in", "a", "numpy", "array", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L350-L360
602
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_cartesian_edge_set
def _get_cartesian_edge_set(self): """ For the GC2 calculations a set of cartesian representations of the fault edges are needed. In this present case we use a common cartesian framework for all edges, as opposed to defining a separate orthographic projection per edge """...
python
def _get_cartesian_edge_set(self): """ For the GC2 calculations a set of cartesian representations of the fault edges are needed. In this present case we use a common cartesian framework for all edges, as opposed to defining a separate orthographic projection per edge """...
[ "def", "_get_cartesian_edge_set", "(", "self", ")", ":", "# Get projection space for cartesian projection", "edge_sets", "=", "numpy", ".", "vstack", "(", "self", ".", "edge_set", ")", "west", ",", "east", ",", "north", ",", "south", "=", "utils", ".", "get_sphe...
For the GC2 calculations a set of cartesian representations of the fault edges are needed. In this present case we use a common cartesian framework for all edges, as opposed to defining a separate orthographic projection per edge
[ "For", "the", "GC2", "calculations", "a", "set", "of", "cartesian", "representations", "of", "the", "fault", "edges", "are", "needed", ".", "In", "this", "present", "case", "we", "use", "a", "common", "cartesian", "framework", "for", "all", "edges", "as", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L362-L392
603
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_gc2_coordinates_for_rupture
def _get_gc2_coordinates_for_rupture(self, edge_sets): """ Calculates the GC2 coordinates for the nodes of the upper edge of the fault """ # Establish GC2 length - for use with Ry0 rup_gc2t, rup_gc2u = self.get_generalised_coordinates( edge_sets[:, 0], edge_s...
python
def _get_gc2_coordinates_for_rupture(self, edge_sets): """ Calculates the GC2 coordinates for the nodes of the upper edge of the fault """ # Establish GC2 length - for use with Ry0 rup_gc2t, rup_gc2u = self.get_generalised_coordinates( edge_sets[:, 0], edge_s...
[ "def", "_get_gc2_coordinates_for_rupture", "(", "self", ",", "edge_sets", ")", ":", "# Establish GC2 length - for use with Ry0", "rup_gc2t", ",", "rup_gc2u", "=", "self", ".", "get_generalised_coordinates", "(", "edge_sets", "[", ":", ",", "0", "]", ",", "edge_sets", ...
Calculates the GC2 coordinates for the nodes of the upper edge of the fault
[ "Calculates", "the", "GC2", "coordinates", "for", "the", "nodes", "of", "the", "upper", "edge", "of", "the", "fault" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L454-L464
604
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface._get_ut_i
def _get_ut_i(self, seg, sx, sy): """ Returns the U and T coordinate for a specific trace segment :param seg: End points of the segment edge :param sx: Sites longitudes rendered into coordinate system :param sy: Sites latitudes rendered into...
python
def _get_ut_i(self, seg, sx, sy): """ Returns the U and T coordinate for a specific trace segment :param seg: End points of the segment edge :param sx: Sites longitudes rendered into coordinate system :param sy: Sites latitudes rendered into...
[ "def", "_get_ut_i", "(", "self", ",", "seg", ",", "sx", ",", "sy", ")", ":", "p0x", ",", "p0y", ",", "p1x", ",", "p1y", "=", "seg", "[", "0", ",", "0", "]", ",", "seg", "[", "0", ",", "1", "]", ",", "seg", "[", "1", ",", "0", "]", ",", ...
Returns the U and T coordinate for a specific trace segment :param seg: End points of the segment edge :param sx: Sites longitudes rendered into coordinate system :param sy: Sites latitudes rendered into coordinate system
[ "Returns", "the", "U", "and", "T", "coordinate", "for", "a", "specific", "trace", "segment" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L466-L489
605
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_rx_distance
def get_rx_distance(self, mesh): """ For each point determine the corresponding rx distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_rx_distance>` for spec of input and result values. """ # If the GC2 calculations h...
python
def get_rx_distance(self, mesh): """ For each point determine the corresponding rx distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_rx_distance>` for spec of input and result values. """ # If the GC2 calculations h...
[ "def", "get_rx_distance", "(", "self", ",", "mesh", ")", ":", "# If the GC2 calculations have already been computed (by invoking Ry0", "# first) and the mesh is identical then class has GC2 attributes", "# already pre-calculated", "if", "not", "self", ".", "tmp_mesh", "or", "(", ...
For each point determine the corresponding rx distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_rx_distance>` for spec of input and result values.
[ "For", "each", "point", "determine", "the", "corresponding", "rx", "distance", "using", "the", "GC2", "configuration", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L570-L588
606
gem/oq-engine
openquake/hazardlib/geo/surface/multi.py
MultiSurface.get_ry0_distance
def get_ry0_distance(self, mesh): """ For each point determine the corresponding Ry0 distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_ry0_distance>` for spec of input and result values. """ # If the GC2 calculation...
python
def get_ry0_distance(self, mesh): """ For each point determine the corresponding Ry0 distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_ry0_distance>` for spec of input and result values. """ # If the GC2 calculation...
[ "def", "get_ry0_distance", "(", "self", ",", "mesh", ")", ":", "# If the GC2 calculations have already been computed (by invoking Ry0", "# first) and the mesh is identical then class has GC2 attributes", "# already pre-calculated", "if", "not", "self", ".", "tmp_mesh", "or", "(", ...
For each point determine the corresponding Ry0 distance using the GC2 configuration. See :meth:`superclass method <.base.BaseSurface.get_ry0_distance>` for spec of input and result values.
[ "For", "each", "point", "determine", "the", "corresponding", "Ry0", "distance", "using", "the", "GC2", "configuration", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/geo/surface/multi.py#L590-L622
607
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid.from_model_files
def from_model_files(cls, limits, input_model, investigation_time=1.0, simple_mesh_spacing=1.0, complex_mesh_spacing=5.0, mfd_width=0.1, area_discretisation=10.0): """ Reads the hazard model from a file :param list limits: Grid conf...
python
def from_model_files(cls, limits, input_model, investigation_time=1.0, simple_mesh_spacing=1.0, complex_mesh_spacing=5.0, mfd_width=0.1, area_discretisation=10.0): """ Reads the hazard model from a file :param list limits: Grid conf...
[ "def", "from_model_files", "(", "cls", ",", "limits", ",", "input_model", ",", "investigation_time", "=", "1.0", ",", "simple_mesh_spacing", "=", "1.0", ",", "complex_mesh_spacing", "=", "5.0", ",", "mfd_width", "=", "0.1", ",", "area_discretisation", "=", "10.0...
Reads the hazard model from a file :param list limits: Grid configuration [west, east, xspc, south, north, yspc, upper, lower, zspc] :param str input_model: Path to input source model :param float investigation_time: Investig...
[ "Reads", "the", "hazard", "model", "from", "a", "file" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L114-L144
608
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid.get_rates
def get_rates(self, mmin, mmax=np.inf): """ Returns the cumulative rates greater than Mmin :param float mmin: Minimum magnitude """ nsrcs = self.number_sources() for iloc, source in enumerate(self.source_model): print("Source Number %s of %s, Name...
python
def get_rates(self, mmin, mmax=np.inf): """ Returns the cumulative rates greater than Mmin :param float mmin: Minimum magnitude """ nsrcs = self.number_sources() for iloc, source in enumerate(self.source_model): print("Source Number %s of %s, Name...
[ "def", "get_rates", "(", "self", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "nsrcs", "=", "self", ".", "number_sources", "(", ")", "for", "iloc", ",", "source", "in", "enumerate", "(", "self", ".", "source_model", ")", ":", "print", ...
Returns the cumulative rates greater than Mmin :param float mmin: Minimum magnitude
[ "Returns", "the", "cumulative", "rates", "greater", "than", "Mmin" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L152-L178
609
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid._get_point_location
def _get_point_location(self, location): """ Returns the location in the output grid corresponding to the cell in which the epicentre lays :param location: Source hypocentre as instance of :class: openquake.hazardlib.geo.point.Point :returns: ...
python
def _get_point_location(self, location): """ Returns the location in the output grid corresponding to the cell in which the epicentre lays :param location: Source hypocentre as instance of :class: openquake.hazardlib.geo.point.Point :returns: ...
[ "def", "_get_point_location", "(", "self", ",", "location", ")", ":", "if", "(", "location", ".", "longitude", "<", "self", ".", "xlim", "[", "0", "]", ")", "or", "(", "location", ".", "longitude", ">", "self", ".", "xlim", "[", "-", "1", "]", ")",...
Returns the location in the output grid corresponding to the cell in which the epicentre lays :param location: Source hypocentre as instance of :class: openquake.hazardlib.geo.point.Point :returns: xloc - Location of longitude cell yloc - Location...
[ "Returns", "the", "location", "in", "the", "output", "grid", "corresponding", "to", "the", "cell", "in", "which", "the", "epicentre", "lays" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L180-L200
610
gem/oq-engine
openquake/hmtk/comparison/rate_grids.py
RateGrid._get_area_rates
def _get_area_rates(self, source, mmin, mmax=np.inf): """ Adds the rates from the area source by discretising the source to a set of point sources :param source: Area source as instance of :class: openquake.hazardlib.source.area.AreaSource """ poi...
python
def _get_area_rates(self, source, mmin, mmax=np.inf): """ Adds the rates from the area source by discretising the source to a set of point sources :param source: Area source as instance of :class: openquake.hazardlib.source.area.AreaSource """ poi...
[ "def", "_get_area_rates", "(", "self", ",", "source", ",", "mmin", ",", "mmax", "=", "np", ".", "inf", ")", ":", "points", "=", "list", "(", "source", ")", "for", "point", "in", "points", ":", "self", ".", "_get_point_rates", "(", "point", ",", "mmin...
Adds the rates from the area source by discretising the source to a set of point sources :param source: Area source as instance of :class: openquake.hazardlib.source.area.AreaSource
[ "Adds", "the", "rates", "from", "the", "area", "source", "by", "discretising", "the", "source", "to", "a", "set", "of", "point", "sources" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hmtk/comparison/rate_grids.py#L231-L242
611
gem/oq-engine
openquake/hazardlib/gsim/megawati_pan_2010.py
MegawatiPan2010._get_distance_scaling
def _get_distance_scaling(self, C, mag, rhypo): """ Returns the distance scalig term """ return (C["a3"] * np.log(rhypo)) + (C["a4"] + C["a5"] * mag) * rhypo
python
def _get_distance_scaling(self, C, mag, rhypo): """ Returns the distance scalig term """ return (C["a3"] * np.log(rhypo)) + (C["a4"] + C["a5"] * mag) * rhypo
[ "def", "_get_distance_scaling", "(", "self", ",", "C", ",", "mag", ",", "rhypo", ")", ":", "return", "(", "C", "[", "\"a3\"", "]", "*", "np", ".", "log", "(", "rhypo", ")", ")", "+", "(", "C", "[", "\"a4\"", "]", "+", "C", "[", "\"a5\"", "]", ...
Returns the distance scalig term
[ "Returns", "the", "distance", "scalig", "term" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/megawati_pan_2010.py#L98-L102
612
gem/oq-engine
openquake/hazardlib/gsim/rietbrock_2013.py
RietbrockEtAl2013SelfSimilar._get_distance_scaling_term
def _get_distance_scaling_term(self, C, rjb, mag): """ Returns the distance scaling component of the model Equation 10, Page 63 """ # Depth adjusted distance, equation 11 (Page 63) rval = np.sqrt(rjb ** 2.0 + C["c11"] ** 2.0) f_0, f_1, f_2 = self._get_distance_seg...
python
def _get_distance_scaling_term(self, C, rjb, mag): """ Returns the distance scaling component of the model Equation 10, Page 63 """ # Depth adjusted distance, equation 11 (Page 63) rval = np.sqrt(rjb ** 2.0 + C["c11"] ** 2.0) f_0, f_1, f_2 = self._get_distance_seg...
[ "def", "_get_distance_scaling_term", "(", "self", ",", "C", ",", "rjb", ",", "mag", ")", ":", "# Depth adjusted distance, equation 11 (Page 63)", "rval", "=", "np", ".", "sqrt", "(", "rjb", "**", "2.0", "+", "C", "[", "\"c11\"", "]", "**", "2.0", ")", "f_0...
Returns the distance scaling component of the model Equation 10, Page 63
[ "Returns", "the", "distance", "scaling", "component", "of", "the", "model", "Equation", "10", "Page", "63" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L109-L120
613
gem/oq-engine
openquake/hazardlib/gsim/rietbrock_2013.py
RietbrockEtAl2013SelfSimilar._get_distance_segment_coefficients
def _get_distance_segment_coefficients(self, rval): """ Returns the coefficients describing the distance attenuation shape for three different distance bins, equations 12a - 12c """ # Get distance segment ends nsites = len(rval) # Equation 12a f_0 = np.log...
python
def _get_distance_segment_coefficients(self, rval): """ Returns the coefficients describing the distance attenuation shape for three different distance bins, equations 12a - 12c """ # Get distance segment ends nsites = len(rval) # Equation 12a f_0 = np.log...
[ "def", "_get_distance_segment_coefficients", "(", "self", ",", "rval", ")", ":", "# Get distance segment ends", "nsites", "=", "len", "(", "rval", ")", "# Equation 12a", "f_0", "=", "np", ".", "log10", "(", "self", ".", "CONSTS", "[", "\"r0\"", "]", "/", "rv...
Returns the coefficients describing the distance attenuation shape for three different distance bins, equations 12a - 12c
[ "Returns", "the", "coefficients", "describing", "the", "distance", "attenuation", "shape", "for", "three", "different", "distance", "bins", "equations", "12a", "-", "12c" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/hazardlib/gsim/rietbrock_2013.py#L122-L139
614
gem/oq-engine
openquake/commonlib/readinput.py
collect_files
def collect_files(dirpath, cond=lambda fullname: True): """ Recursively collect the files contained inside dirpath. :param dirpath: path to a readable directory :param cond: condition on the path to collect the file """ files = [] for fname in os.listdir(dirpath): fullname = os.path...
python
def collect_files(dirpath, cond=lambda fullname: True): """ Recursively collect the files contained inside dirpath. :param dirpath: path to a readable directory :param cond: condition on the path to collect the file """ files = [] for fname in os.listdir(dirpath): fullname = os.path...
[ "def", "collect_files", "(", "dirpath", ",", "cond", "=", "lambda", "fullname", ":", "True", ")", ":", "files", "=", "[", "]", "for", "fname", "in", "os", ".", "listdir", "(", "dirpath", ")", ":", "fullname", "=", "os", ".", "path", ".", "join", "(...
Recursively collect the files contained inside dirpath. :param dirpath: path to a readable directory :param cond: condition on the path to collect the file
[ "Recursively", "collect", "the", "files", "contained", "inside", "dirpath", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L69-L84
615
gem/oq-engine
openquake/commonlib/readinput.py
extract_from_zip
def extract_from_zip(path, candidates): """ Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive. :param path: pathname of...
python
def extract_from_zip(path, candidates): """ Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive. :param path: pathname of...
[ "def", "extract_from_zip", "(", "path", ",", "candidates", ")", ":", "temp_dir", "=", "tempfile", ".", "mkdtemp", "(", ")", "with", "zipfile", ".", "ZipFile", "(", "path", ")", "as", "archive", ":", "archive", ".", "extractall", "(", "temp_dir", ")", "re...
Given a zip archive and a function to detect the presence of a given filename, unzip the archive into a temporary directory and return the full path of the file. Raise an IOError if the file cannot be found within the archive. :param path: pathname of the archive :param candidates: list of names to...
[ "Given", "a", "zip", "archive", "and", "a", "function", "to", "detect", "the", "presence", "of", "a", "given", "filename", "unzip", "the", "archive", "into", "a", "temporary", "directory", "and", "return", "the", "full", "path", "of", "the", "file", ".", ...
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L87-L101
616
gem/oq-engine
openquake/commonlib/readinput.py
get_params
def get_params(job_inis, **kw): """ Parse one or more INI-style config files. :param job_inis: List of configuration files (or list containing a single zip archive) :param kw: Optionally override some parameters :returns: A dictionary of parameters """ input_zip = No...
python
def get_params(job_inis, **kw): """ Parse one or more INI-style config files. :param job_inis: List of configuration files (or list containing a single zip archive) :param kw: Optionally override some parameters :returns: A dictionary of parameters """ input_zip = No...
[ "def", "get_params", "(", "job_inis", ",", "*", "*", "kw", ")", ":", "input_zip", "=", "None", "if", "len", "(", "job_inis", ")", "==", "1", "and", "job_inis", "[", "0", "]", ".", "endswith", "(", "'.zip'", ")", ":", "input_zip", "=", "job_inis", "...
Parse one or more INI-style config files. :param job_inis: List of configuration files (or list containing a single zip archive) :param kw: Optionally override some parameters :returns: A dictionary of parameters
[ "Parse", "one", "or", "more", "INI", "-", "style", "config", "files", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L152-L191
617
gem/oq-engine
openquake/commonlib/readinput.py
get_oqparam
def get_oqparam(job_ini, pkg=None, calculators=None, hc_id=None, validate=1, **kw): """ Parse a dictionary of parameters from an INI-style config file. :param job_ini: Path to configuration file/archive or dictionary of parameters :param pkg: Python package where to find...
python
def get_oqparam(job_ini, pkg=None, calculators=None, hc_id=None, validate=1, **kw): """ Parse a dictionary of parameters from an INI-style config file. :param job_ini: Path to configuration file/archive or dictionary of parameters :param pkg: Python package where to find...
[ "def", "get_oqparam", "(", "job_ini", ",", "pkg", "=", "None", ",", "calculators", "=", "None", ",", "hc_id", "=", "None", ",", "validate", "=", "1", ",", "*", "*", "kw", ")", ":", "# UGLY: this is here to avoid circular imports", "from", "openquake", ".", ...
Parse a dictionary of parameters from an INI-style config file. :param job_ini: Path to configuration file/archive or dictionary of parameters :param pkg: Python package where to find the configuration file (optional) :param calculators: Sequence of calculator names (optional) used ...
[ "Parse", "a", "dictionary", "of", "parameters", "from", "an", "INI", "-", "style", "config", "file", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L194-L233
618
gem/oq-engine
openquake/commonlib/readinput.py
get_site_model
def get_site_model(oqparam): """ Convert the NRML file into an array of site parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an array with fields lon, lat, vs30, ... """ req_site_params = get_gsim_lt(oqparam).req_site_params ...
python
def get_site_model(oqparam): """ Convert the NRML file into an array of site parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an array with fields lon, lat, vs30, ... """ req_site_params = get_gsim_lt(oqparam).req_site_params ...
[ "def", "get_site_model", "(", "oqparam", ")", ":", "req_site_params", "=", "get_gsim_lt", "(", "oqparam", ")", ".", "req_site_params", "arrays", "=", "[", "]", "for", "fname", "in", "oqparam", ".", "inputs", "[", "'site_model'", "]", ":", "if", "isinstance",...
Convert the NRML file into an array of site parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an array with fields lon, lat, vs30, ...
[ "Convert", "the", "NRML", "file", "into", "an", "array", "of", "site", "parameters", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L342-L386
619
gem/oq-engine
openquake/commonlib/readinput.py
get_site_collection
def get_site_collection(oqparam): """ Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ mesh = get_mesh(oqparam) req_site_params = g...
python
def get_site_collection(oqparam): """ Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance """ mesh = get_mesh(oqparam) req_site_params = g...
[ "def", "get_site_collection", "(", "oqparam", ")", ":", "mesh", "=", "get_mesh", "(", "oqparam", ")", "req_site_params", "=", "get_gsim_lt", "(", "oqparam", ")", ".", "req_site_params", "if", "oqparam", ".", "inputs", ".", "get", "(", "'site_model'", ")", ":...
Returns a SiteCollection instance by looking at the points and the site model defined by the configuration parameters. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance
[ "Returns", "a", "SiteCollection", "instance", "by", "looking", "at", "the", "points", "and", "the", "site", "model", "defined", "by", "the", "configuration", "parameters", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L389-L439
620
gem/oq-engine
openquake/commonlib/readinput.py
get_rupture
def get_rupture(oqparam): """ Read the `rupture_model` file and by filter the site collection :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an hazardlib rupture """ rup_model = oqparam.inputs['rupture_model'] [rup_node] = nrml.read(r...
python
def get_rupture(oqparam): """ Read the `rupture_model` file and by filter the site collection :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an hazardlib rupture """ rup_model = oqparam.inputs['rupture_model'] [rup_node] = nrml.read(r...
[ "def", "get_rupture", "(", "oqparam", ")", ":", "rup_model", "=", "oqparam", ".", "inputs", "[", "'rupture_model'", "]", "[", "rup_node", "]", "=", "nrml", ".", "read", "(", "rup_model", ")", "conv", "=", "sourceconverter", ".", "RuptureConverter", "(", "o...
Read the `rupture_model` file and by filter the site collection :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: an hazardlib rupture
[ "Read", "the", "rupture_model", "file", "and", "by", "filter", "the", "site", "collection" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L498-L514
621
gem/oq-engine
openquake/commonlib/readinput.py
get_composite_source_model
def get_composite_source_model(oqparam, monitor=None, in_memory=True, srcfilter=SourceFilter(None, {})): """ Parse the XML and build a complete composite source model in memory. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param m...
python
def get_composite_source_model(oqparam, monitor=None, in_memory=True, srcfilter=SourceFilter(None, {})): """ Parse the XML and build a complete composite source model in memory. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param m...
[ "def", "get_composite_source_model", "(", "oqparam", ",", "monitor", "=", "None", ",", "in_memory", "=", "True", ",", "srcfilter", "=", "SourceFilter", "(", "None", ",", "{", "}", ")", ")", ":", "ucerf", "=", "oqparam", ".", "calculation_mode", ".", "start...
Parse the XML and build a complete composite source model in memory. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :param monitor: a `openquake.baselib.performance.Monitor` instance :param in_memory: if False, just parse the XML without instantiating...
[ "Parse", "the", "XML", "and", "build", "a", "complete", "composite", "source", "model", "in", "memory", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L816-L892
622
gem/oq-engine
openquake/commonlib/readinput.py
get_mesh_hcurves
def get_mesh_hcurves(oqparam): """ Read CSV data in the format `lon lat, v1-vN, w1-wN, ...`. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: the mesh of points and the data as a dictionary imt -> array of curves for each site """ i...
python
def get_mesh_hcurves(oqparam): """ Read CSV data in the format `lon lat, v1-vN, w1-wN, ...`. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: the mesh of points and the data as a dictionary imt -> array of curves for each site """ i...
[ "def", "get_mesh_hcurves", "(", "oqparam", ")", ":", "imtls", "=", "oqparam", ".", "imtls", "lon_lats", "=", "set", "(", ")", "data", "=", "AccumDict", "(", ")", "# imt -> list of arrays", "ncols", "=", "len", "(", "imtls", ")", "+", "1", "# lon_lat + curv...
Read CSV data in the format `lon lat, v1-vN, w1-wN, ...`. :param oqparam: an :class:`openquake.commonlib.oqvalidation.OqParam` instance :returns: the mesh of points and the data as a dictionary imt -> array of curves for each site
[ "Read", "CSV", "data", "in", "the", "format", "lon", "lat", "v1", "-", "vN", "w1", "-", "wN", "...", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1212-L1247
623
gem/oq-engine
openquake/commonlib/readinput.py
reduce_source_model
def reduce_source_model(smlt_file, source_ids, remove=True): """ Extract sources from the composite source model """ found = 0 to_remove = [] for paths in logictree.collect_info(smlt_file).smpaths.values(): for path in paths: logging.info('Reading %s', path) root ...
python
def reduce_source_model(smlt_file, source_ids, remove=True): """ Extract sources from the composite source model """ found = 0 to_remove = [] for paths in logictree.collect_info(smlt_file).smpaths.values(): for path in paths: logging.info('Reading %s', path) root ...
[ "def", "reduce_source_model", "(", "smlt_file", ",", "source_ids", ",", "remove", "=", "True", ")", ":", "found", "=", "0", "to_remove", "=", "[", "]", "for", "paths", "in", "logictree", ".", "collect_info", "(", "smlt_file", ")", ".", "smpaths", ".", "v...
Extract sources from the composite source model
[ "Extract", "sources", "from", "the", "composite", "source", "model" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1251-L1292
624
gem/oq-engine
openquake/commonlib/readinput.py
get_checksum32
def get_checksum32(oqparam, hazard=False): """ Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume """ # NB: using adler32 & 0xffffffff is the documented way...
python
def get_checksum32(oqparam, hazard=False): """ Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume """ # NB: using adler32 & 0xffffffff is the documented way...
[ "def", "get_checksum32", "(", "oqparam", ",", "hazard", "=", "False", ")", ":", "# NB: using adler32 & 0xffffffff is the documented way to get a checksum", "# which is the same between Python 2 and Python 3", "checksum", "=", "0", "for", "fname", "in", "get_input_files", "(", ...
Build an unsigned 32 bit integer from the input files of a calculation. :param oqparam: an OqParam instance :param hazard: if True, consider only the hazard files :returns: the checkume
[ "Build", "an", "unsigned", "32", "bit", "integer", "from", "the", "input", "files", "of", "a", "calculation", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commonlib/readinput.py#L1388-L1415
625
gem/oq-engine
openquake/commands/dump.py
smart_save
def smart_save(dbpath, archive, calc_id): """ Make a copy of the db, remove the incomplete jobs and add the copy to the archive """ tmpdir = tempfile.mkdtemp() newdb = os.path.join(tmpdir, os.path.basename(dbpath)) shutil.copy(dbpath, newdb) try: with sqlite3.connect(newdb) as co...
python
def smart_save(dbpath, archive, calc_id): """ Make a copy of the db, remove the incomplete jobs and add the copy to the archive """ tmpdir = tempfile.mkdtemp() newdb = os.path.join(tmpdir, os.path.basename(dbpath)) shutil.copy(dbpath, newdb) try: with sqlite3.connect(newdb) as co...
[ "def", "smart_save", "(", "dbpath", ",", "archive", ",", "calc_id", ")", ":", "tmpdir", "=", "tempfile", ".", "mkdtemp", "(", ")", "newdb", "=", "os", ".", "path", ".", "join", "(", "tmpdir", ",", "os", ".", "path", ".", "basename", "(", "dbpath", ...
Make a copy of the db, remove the incomplete jobs and add the copy to the archive
[ "Make", "a", "copy", "of", "the", "db", "remove", "the", "incomplete", "jobs", "and", "add", "the", "copy", "to", "the", "archive" ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/dump.py#L28-L45
626
gem/oq-engine
openquake/commands/dump.py
dump
def dump(archive, calc_id=0, user=None): """ Dump the openquake database and all the complete calculations into a zip file. In a multiuser installation must be run as administrator. """ t0 = time.time() assert archive.endswith('.zip'), archive getfnames = 'select ds_calc_dir || ".hdf5" from ...
python
def dump(archive, calc_id=0, user=None): """ Dump the openquake database and all the complete calculations into a zip file. In a multiuser installation must be run as administrator. """ t0 = time.time() assert archive.endswith('.zip'), archive getfnames = 'select ds_calc_dir || ".hdf5" from ...
[ "def", "dump", "(", "archive", ",", "calc_id", "=", "0", ",", "user", "=", "None", ")", ":", "t0", "=", "time", ".", "time", "(", ")", "assert", "archive", ".", "endswith", "(", "'.zip'", ")", ",", "archive", "getfnames", "=", "'select ds_calc_dir || \...
Dump the openquake database and all the complete calculations into a zip file. In a multiuser installation must be run as administrator.
[ "Dump", "the", "openquake", "database", "and", "all", "the", "complete", "calculations", "into", "a", "zip", "file", ".", "In", "a", "multiuser", "installation", "must", "be", "run", "as", "administrator", "." ]
8294553a0b8aba33fd96437a35065d03547d0040
https://github.com/gem/oq-engine/blob/8294553a0b8aba33fd96437a35065d03547d0040/openquake/commands/dump.py#L49-L77
627
conan-io/conan-package-tools
setup.py
load_version
def load_version(): """Loads a file content""" filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cpt", "__init__.py")) with open(filename, "rt") as version_file: conan_init = version_file.read() version = re.searc...
python
def load_version(): """Loads a file content""" filename = os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "cpt", "__init__.py")) with open(filename, "rt") as version_file: conan_init = version_file.read() version = re.searc...
[ "def", "load_version", "(", ")", ":", "filename", "=", "os", ".", "path", ".", "abspath", "(", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "os", ".", "path", ".", "abspath", "(", "__file__", ")", ")", ",", "\"cpt\...
Loads a file content
[ "Loads", "a", "file", "content" ]
3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/setup.py#L25-L32
628
conan-io/conan-package-tools
cpt/packager.py
ConanMultiPackager.builds
def builds(self, confs): """For retro compatibility directly assigning builds""" self._named_builds = {} self._builds = [] for values in confs: if len(values) == 2: self._builds.append(BuildConf(values[0], values[1], {}, {}, self.reference)) elif l...
python
def builds(self, confs): """For retro compatibility directly assigning builds""" self._named_builds = {} self._builds = [] for values in confs: if len(values) == 2: self._builds.append(BuildConf(values[0], values[1], {}, {}, self.reference)) elif l...
[ "def", "builds", "(", "self", ",", "confs", ")", ":", "self", ".", "_named_builds", "=", "{", "}", "self", ".", "_builds", "=", "[", "]", "for", "values", "in", "confs", ":", "if", "len", "(", "values", ")", "==", "2", ":", "self", ".", "_builds"...
For retro compatibility directly assigning builds
[ "For", "retro", "compatibility", "directly", "assigning", "builds" ]
3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/cpt/packager.py#L357-L371
629
conan-io/conan-package-tools
cpt/profiles.py
patch_default_base_profile
def patch_default_base_profile(conan_api, profile_abs_path): """If we have a profile including default, but the users default in config is that the default is other, we have to change the include""" text = tools.load(profile_abs_path) if "include(default)" in text: # User didn't specified a custom prof...
python
def patch_default_base_profile(conan_api, profile_abs_path): """If we have a profile including default, but the users default in config is that the default is other, we have to change the include""" text = tools.load(profile_abs_path) if "include(default)" in text: # User didn't specified a custom prof...
[ "def", "patch_default_base_profile", "(", "conan_api", ",", "profile_abs_path", ")", ":", "text", "=", "tools", ".", "load", "(", "profile_abs_path", ")", "if", "\"include(default)\"", "in", "text", ":", "# User didn't specified a custom profile", "if", "Version", "("...
If we have a profile including default, but the users default in config is that the default is other, we have to change the include
[ "If", "we", "have", "a", "profile", "including", "default", "but", "the", "users", "default", "in", "config", "is", "that", "the", "default", "is", "other", "we", "have", "to", "change", "the", "include" ]
3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324
https://github.com/conan-io/conan-package-tools/blob/3d0f5f4dc5d9dc899a57626e8d8a125fc28b8324/cpt/profiles.py#L51-L68
630
edx/auth-backends
auth_backends/pipeline.py
get_user_if_exists
def get_user_if_exists(strategy, details, user=None, *args, **kwargs): """Return a User with the given username iff the User exists.""" if user: return {'is_new': False} try: username = details.get('username') # Return the user if it exists return { 'is_new': Fal...
python
def get_user_if_exists(strategy, details, user=None, *args, **kwargs): """Return a User with the given username iff the User exists.""" if user: return {'is_new': False} try: username = details.get('username') # Return the user if it exists return { 'is_new': Fal...
[ "def", "get_user_if_exists", "(", "strategy", ",", "details", ",", "user", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "user", ":", "return", "{", "'is_new'", ":", "False", "}", "try", ":", "username", "=", "details", ".",...
Return a User with the given username iff the User exists.
[ "Return", "a", "User", "with", "the", "given", "username", "iff", "the", "User", "exists", "." ]
493f93e9d87d0237f0fea6d75c7b70646ad6d31e
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/pipeline.py#L14-L31
631
edx/auth-backends
auth_backends/pipeline.py
update_email
def update_email(strategy, details, user=None, *args, **kwargs): """Update the user's email address using data from provider.""" if user: email = details.get('email') if email and user.email != email: user.email = email strategy.storage.user.changed(user)
python
def update_email(strategy, details, user=None, *args, **kwargs): """Update the user's email address using data from provider.""" if user: email = details.get('email') if email and user.email != email: user.email = email strategy.storage.user.changed(user)
[ "def", "update_email", "(", "strategy", ",", "details", ",", "user", "=", "None", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "if", "user", ":", "email", "=", "details", ".", "get", "(", "'email'", ")", "if", "email", "and", "user", ".", ...
Update the user's email address using data from provider.
[ "Update", "the", "user", "s", "email", "address", "using", "data", "from", "provider", "." ]
493f93e9d87d0237f0fea6d75c7b70646ad6d31e
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/pipeline.py#L34-L41
632
edx/auth-backends
auth_backends/backends.py
EdXOpenIdConnect.get_user_claims
def get_user_claims(self, access_token, claims=None, token_type='Bearer'): """Returns a dictionary with the values for each claim requested.""" data = self.get_json( self.USER_INFO_URL, headers={'Authorization': '{token_type} {token}'.format(token_type=token_type, token=access_to...
python
def get_user_claims(self, access_token, claims=None, token_type='Bearer'): """Returns a dictionary with the values for each claim requested.""" data = self.get_json( self.USER_INFO_URL, headers={'Authorization': '{token_type} {token}'.format(token_type=token_type, token=access_to...
[ "def", "get_user_claims", "(", "self", ",", "access_token", ",", "claims", "=", "None", ",", "token_type", "=", "'Bearer'", ")", ":", "data", "=", "self", ".", "get_json", "(", "self", ".", "USER_INFO_URL", ",", "headers", "=", "{", "'Authorization'", ":",...
Returns a dictionary with the values for each claim requested.
[ "Returns", "a", "dictionary", "with", "the", "values", "for", "each", "claim", "requested", "." ]
493f93e9d87d0237f0fea6d75c7b70646ad6d31e
https://github.com/edx/auth-backends/blob/493f93e9d87d0237f0fea6d75c7b70646ad6d31e/auth_backends/backends.py#L170-L181
633
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._setup_ipc
def _setup_ipc(self): ''' Setup the IPC pub and sub. Subscript to the listener IPC and publish to the device specific IPC. ''' log.debug('Setting up the server IPC puller to receive from the listener') self.ctx = zmq.Context() # subscribe to listener ...
python
def _setup_ipc(self): ''' Setup the IPC pub and sub. Subscript to the listener IPC and publish to the device specific IPC. ''' log.debug('Setting up the server IPC puller to receive from the listener') self.ctx = zmq.Context() # subscribe to listener ...
[ "def", "_setup_ipc", "(", "self", ")", ":", "log", ".", "debug", "(", "'Setting up the server IPC puller to receive from the listener'", ")", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "# subscribe to listener", "self", ".", "sub", "=", "self", "....
Setup the IPC pub and sub. Subscript to the listener IPC and publish to the device specific IPC.
[ "Setup", "the", "IPC", "pub", "and", "sub", ".", "Subscript", "to", "the", "listener", "IPC", "and", "publish", "to", "the", "device", "specific", "IPC", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L55-L90
634
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._cleanup_buffer
def _cleanup_buffer(self): ''' Periodically cleanup the buffer. ''' if not self._buffer: return while True: time.sleep(60) log.debug('Cleaning up buffer') items = self._buffer.items() # The ``items`` function should also...
python
def _cleanup_buffer(self): ''' Periodically cleanup the buffer. ''' if not self._buffer: return while True: time.sleep(60) log.debug('Cleaning up buffer') items = self._buffer.items() # The ``items`` function should also...
[ "def", "_cleanup_buffer", "(", "self", ")", ":", "if", "not", "self", ".", "_buffer", ":", "return", "while", "True", ":", "time", ".", "sleep", "(", "60", ")", "log", ".", "debug", "(", "'Cleaning up buffer'", ")", "items", "=", "self", ".", "_buffer"...
Periodically cleanup the buffer.
[ "Periodically", "cleanup", "the", "buffer", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L92-L104
635
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._compile_prefixes
def _compile_prefixes(self): ''' Create a dict of all OS prefixes and their compiled regexs ''' self.compiled_prefixes = {} for dev_os, os_config in self.config.items(): if not os_config: continue self.compiled_prefixes[dev_os] = [] ...
python
def _compile_prefixes(self): ''' Create a dict of all OS prefixes and their compiled regexs ''' self.compiled_prefixes = {} for dev_os, os_config in self.config.items(): if not os_config: continue self.compiled_prefixes[dev_os] = [] ...
[ "def", "_compile_prefixes", "(", "self", ")", ":", "self", ".", "compiled_prefixes", "=", "{", "}", "for", "dev_os", ",", "os_config", "in", "self", ".", "config", ".", "items", "(", ")", ":", "if", "not", "os_config", ":", "continue", "self", ".", "co...
Create a dict of all OS prefixes and their compiled regexs
[ "Create", "a", "dict", "of", "all", "OS", "prefixes", "and", "their", "compiled", "regexs" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L106-L146
636
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._identify_prefix
def _identify_prefix(self, msg, data): ''' Check the message again each OS prefix and if matched return the message dict ''' prefix_id = -1 for prefix in data: msg_dict = {} prefix_id += 1 match = None if '__python_fun__' in...
python
def _identify_prefix(self, msg, data): ''' Check the message again each OS prefix and if matched return the message dict ''' prefix_id = -1 for prefix in data: msg_dict = {} prefix_id += 1 match = None if '__python_fun__' in...
[ "def", "_identify_prefix", "(", "self", ",", "msg", ",", "data", ")", ":", "prefix_id", "=", "-", "1", "for", "prefix", "in", "data", ":", "msg_dict", "=", "{", "}", "prefix_id", "+=", "1", "match", "=", "None", "if", "'__python_fun__'", "in", "prefix"...
Check the message again each OS prefix and if matched return the message dict
[ "Check", "the", "message", "again", "each", "OS", "prefix", "and", "if", "matched", "return", "the", "message", "dict" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L150-L191
637
napalm-automation/napalm-logs
napalm_logs/server.py
NapalmLogsServerProc._identify_os
def _identify_os(self, msg): ''' Using the prefix of the syslog message, we are able to identify the operating system and then continue parsing. ''' ret = [] for dev_os, data in self.compiled_prefixes.items(): # TODO Should we prevent attepmting to determine t...
python
def _identify_os(self, msg): ''' Using the prefix of the syslog message, we are able to identify the operating system and then continue parsing. ''' ret = [] for dev_os, data in self.compiled_prefixes.items(): # TODO Should we prevent attepmting to determine t...
[ "def", "_identify_os", "(", "self", ",", "msg", ")", ":", "ret", "=", "[", "]", "for", "dev_os", ",", "data", "in", "self", ".", "compiled_prefixes", ".", "items", "(", ")", ":", "# TODO Should we prevent attepmting to determine the OS for the blacklisted?", "# [m...
Using the prefix of the syslog message, we are able to identify the operating system and then continue parsing.
[ "Using", "the", "prefix", "of", "the", "syslog", "message", "we", "are", "able", "to", "identify", "the", "operating", "system", "and", "then", "continue", "parsing", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/server.py#L193-L215
638
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._setup_ipc
def _setup_ipc(self): ''' Subscribe to the right topic in the device IPC and publish to the publisher proxy. ''' self.ctx = zmq.Context() # subscribe to device IPC log.debug('Creating the dealer IPC for %s', self._name) self.sub = self.ctx.socket(z...
python
def _setup_ipc(self): ''' Subscribe to the right topic in the device IPC and publish to the publisher proxy. ''' self.ctx = zmq.Context() # subscribe to device IPC log.debug('Creating the dealer IPC for %s', self._name) self.sub = self.ctx.socket(z...
[ "def", "_setup_ipc", "(", "self", ")", ":", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "# subscribe to device IPC", "log", ".", "debug", "(", "'Creating the dealer IPC for %s'", ",", "self", ".", "_name", ")", "self", ".", "sub", "=", "self"...
Subscribe to the right topic in the device IPC and publish to the publisher proxy.
[ "Subscribe", "to", "the", "right", "topic", "in", "the", "device", "IPC", "and", "publish", "to", "the", "publisher", "proxy", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L52-L82
639
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._compile_messages
def _compile_messages(self): ''' Create a list of all OS messages and their compiled regexs ''' self.compiled_messages = [] if not self._config: return for message_dict in self._config.get('messages', {}): error = message_dict['error'] ...
python
def _compile_messages(self): ''' Create a list of all OS messages and their compiled regexs ''' self.compiled_messages = [] if not self._config: return for message_dict in self._config.get('messages', {}): error = message_dict['error'] ...
[ "def", "_compile_messages", "(", "self", ")", ":", "self", ".", "compiled_messages", "=", "[", "]", "if", "not", "self", ".", "_config", ":", "return", "for", "message_dict", "in", "self", ".", "_config", ".", "get", "(", "'messages'", ",", "{", "}", "...
Create a list of all OS messages and their compiled regexs
[ "Create", "a", "list", "of", "all", "OS", "messages", "and", "their", "compiled", "regexs" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L84-L138
640
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._parse
def _parse(self, msg_dict): ''' Parse a syslog message and check what OpenConfig object should be generated. ''' error_present = False # log.debug('Matching the message:') # log.debug(msg_dict) for message in self.compiled_messages: # log.debug...
python
def _parse(self, msg_dict): ''' Parse a syslog message and check what OpenConfig object should be generated. ''' error_present = False # log.debug('Matching the message:') # log.debug(msg_dict) for message in self.compiled_messages: # log.debug...
[ "def", "_parse", "(", "self", ",", "msg_dict", ")", ":", "error_present", "=", "False", "# log.debug('Matching the message:')", "# log.debug(msg_dict)", "for", "message", "in", "self", ".", "compiled_messages", ":", "# log.debug('Matching using:')", "# log.debug(message)", ...
Parse a syslog message and check what OpenConfig object should be generated.
[ "Parse", "a", "syslog", "message", "and", "check", "what", "OpenConfig", "object", "should", "be", "generated", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L140-L186
641
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._emit
def _emit(self, **kwargs): ''' Emit an OpenConfig object given a certain combination of fields mappeed in the config to the corresponding hierarchy. ''' oc_dict = {} for mapping, result_key in kwargs['mapping']['variables'].items(): result = kwargs[result_key]...
python
def _emit(self, **kwargs): ''' Emit an OpenConfig object given a certain combination of fields mappeed in the config to the corresponding hierarchy. ''' oc_dict = {} for mapping, result_key in kwargs['mapping']['variables'].items(): result = kwargs[result_key]...
[ "def", "_emit", "(", "self", ",", "*", "*", "kwargs", ")", ":", "oc_dict", "=", "{", "}", "for", "mapping", ",", "result_key", "in", "kwargs", "[", "'mapping'", "]", "[", "'variables'", "]", ".", "items", "(", ")", ":", "result", "=", "kwargs", "["...
Emit an OpenConfig object given a certain combination of fields mappeed in the config to the corresponding hierarchy.
[ "Emit", "an", "OpenConfig", "object", "given", "a", "certain", "combination", "of", "fields", "mappeed", "in", "the", "config", "to", "the", "corresponding", "hierarchy", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L188-L200
642
napalm-automation/napalm-logs
napalm_logs/device.py
NapalmLogsDeviceProc._publish
def _publish(self, obj): ''' Publish the OC object. ''' bin_obj = umsgpack.packb(obj) self.pub.send(bin_obj)
python
def _publish(self, obj): ''' Publish the OC object. ''' bin_obj = umsgpack.packb(obj) self.pub.send(bin_obj)
[ "def", "_publish", "(", "self", ",", "obj", ")", ":", "bin_obj", "=", "umsgpack", ".", "packb", "(", "obj", ")", "self", ".", "pub", ".", "send", "(", "bin_obj", ")" ]
Publish the OC object.
[ "Publish", "the", "OC", "object", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/device.py#L202-L207
643
napalm-automation/napalm-logs
napalm_logs/auth.py
NapalmLogsAuthProc._handshake
def _handshake(self, conn, addr): ''' Ensures that the client receives the AES key. ''' # waiting for the magic request message msg = conn.recv(len(MAGIC_REQ)) log.debug('Received message %s from %s', msg, addr) if msg != MAGIC_REQ: log.warning('%s is ...
python
def _handshake(self, conn, addr): ''' Ensures that the client receives the AES key. ''' # waiting for the magic request message msg = conn.recv(len(MAGIC_REQ)) log.debug('Received message %s from %s', msg, addr) if msg != MAGIC_REQ: log.warning('%s is ...
[ "def", "_handshake", "(", "self", ",", "conn", ",", "addr", ")", ":", "# waiting for the magic request message", "msg", "=", "conn", ".", "recv", "(", "len", "(", "MAGIC_REQ", ")", ")", "log", ".", "debug", "(", "'Received message %s from %s'", ",", "msg", "...
Ensures that the client receives the AES key.
[ "Ensures", "that", "the", "client", "receives", "the", "AES", "key", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L79-L104
644
napalm-automation/napalm-logs
napalm_logs/auth.py
NapalmLogsAuthProc.keep_alive
def keep_alive(self, conn): ''' Maintains auth sessions ''' while self.__up: msg = conn.recv(len(AUTH_KEEP_ALIVE)) if msg != AUTH_KEEP_ALIVE: log.error('Received something other than %s', AUTH_KEEP_ALIVE) conn.close() ...
python
def keep_alive(self, conn): ''' Maintains auth sessions ''' while self.__up: msg = conn.recv(len(AUTH_KEEP_ALIVE)) if msg != AUTH_KEEP_ALIVE: log.error('Received something other than %s', AUTH_KEEP_ALIVE) conn.close() ...
[ "def", "keep_alive", "(", "self", ",", "conn", ")", ":", "while", "self", ".", "__up", ":", "msg", "=", "conn", ".", "recv", "(", "len", "(", "AUTH_KEEP_ALIVE", ")", ")", "if", "msg", "!=", "AUTH_KEEP_ALIVE", ":", "log", ".", "error", "(", "'Received...
Maintains auth sessions
[ "Maintains", "auth", "sessions" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L106-L121
645
napalm-automation/napalm-logs
napalm_logs/auth.py
NapalmLogsAuthProc.verify_cert
def verify_cert(self): ''' Checks that the provided cert and key are valid and usable ''' log.debug('Verifying the %s certificate, keyfile: %s', self.certificate, self.keyfile) try: ssl.create_default_context().load_cert_chain(self.certificate, keyfi...
python
def verify_cert(self): ''' Checks that the provided cert and key are valid and usable ''' log.debug('Verifying the %s certificate, keyfile: %s', self.certificate, self.keyfile) try: ssl.create_default_context().load_cert_chain(self.certificate, keyfi...
[ "def", "verify_cert", "(", "self", ")", ":", "log", ".", "debug", "(", "'Verifying the %s certificate, keyfile: %s'", ",", "self", ".", "certificate", ",", "self", ".", "keyfile", ")", "try", ":", "ssl", ".", "create_default_context", "(", ")", ".", "load_cert...
Checks that the provided cert and key are valid and usable
[ "Checks", "that", "the", "provided", "cert", "and", "key", "are", "valid", "and", "usable" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L123-L138
646
napalm-automation/napalm-logs
napalm_logs/auth.py
NapalmLogsAuthProc._create_skt
def _create_skt(self): ''' Create the authentication socket. ''' log.debug('Creating the auth socket') if ':' in self.auth_address: self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) else: self.socket = socket.socket(socket.AF_INET, s...
python
def _create_skt(self): ''' Create the authentication socket. ''' log.debug('Creating the auth socket') if ':' in self.auth_address: self.socket = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) else: self.socket = socket.socket(socket.AF_INET, s...
[ "def", "_create_skt", "(", "self", ")", ":", "log", ".", "debug", "(", "'Creating the auth socket'", ")", "if", "':'", "in", "self", ".", "auth_address", ":", "self", ".", "socket", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET6", ",", "sock...
Create the authentication socket.
[ "Create", "the", "authentication", "socket", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L140-L154
647
napalm-automation/napalm-logs
napalm_logs/auth.py
NapalmLogsAuthProc.start
def start(self): ''' Listen to auth requests and send the AES key. Each client connection starts a new thread. ''' # Start suicide polling thread log.debug('Starting the auth process') self.verify_cert() self._create_skt() log.debug('The auth proce...
python
def start(self): ''' Listen to auth requests and send the AES key. Each client connection starts a new thread. ''' # Start suicide polling thread log.debug('Starting the auth process') self.verify_cert() self._create_skt() log.debug('The auth proce...
[ "def", "start", "(", "self", ")", ":", "# Start suicide polling thread", "log", ".", "debug", "(", "'Starting the auth process'", ")", "self", ".", "verify_cert", "(", ")", "self", ".", "_create_skt", "(", ")", "log", ".", "debug", "(", "'The auth process can re...
Listen to auth requests and send the AES key. Each client connection starts a new thread.
[ "Listen", "to", "auth", "requests", "and", "send", "the", "AES", "key", ".", "Each", "client", "connection", "starts", "a", "new", "thread", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L156-L192
648
napalm-automation/napalm-logs
napalm_logs/auth.py
NapalmLogsAuthProc.stop
def stop(self): ''' Stop the auth proc. ''' log.info('Stopping auth process') self.__up = False self.socket.close()
python
def stop(self): ''' Stop the auth proc. ''' log.info('Stopping auth process') self.__up = False self.socket.close()
[ "def", "stop", "(", "self", ")", ":", "log", ".", "info", "(", "'Stopping auth process'", ")", "self", ".", "__up", "=", "False", "self", ".", "socket", ".", "close", "(", ")" ]
Stop the auth proc.
[ "Stop", "the", "auth", "proc", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/auth.py#L194-L200
649
napalm-automation/napalm-logs
napalm_logs/listener/kafka.py
KafkaListener.start
def start(self): ''' Startup the kafka consumer. ''' log.debug('Creating the consumer using the bootstrap servers: %s and the group ID: %s', self.bootstrap_servers, self.group_id) try: self.consumer = kafka.KafkaConsumer(bootstrap_s...
python
def start(self): ''' Startup the kafka consumer. ''' log.debug('Creating the consumer using the bootstrap servers: %s and the group ID: %s', self.bootstrap_servers, self.group_id) try: self.consumer = kafka.KafkaConsumer(bootstrap_s...
[ "def", "start", "(", "self", ")", ":", "log", ".", "debug", "(", "'Creating the consumer using the bootstrap servers: %s and the group ID: %s'", ",", "self", ".", "bootstrap_servers", ",", "self", ".", "group_id", ")", "try", ":", "self", ".", "consumer", "=", "ka...
Startup the kafka consumer.
[ "Startup", "the", "kafka", "consumer", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/kafka.py#L41-L55
650
napalm-automation/napalm-logs
napalm_logs/listener/kafka.py
KafkaListener.stop
def stop(self): ''' Shutdown kafka consumer. ''' log.info('Stopping te kafka listener class') self.consumer.unsubscribe() self.consumer.close()
python
def stop(self): ''' Shutdown kafka consumer. ''' log.info('Stopping te kafka listener class') self.consumer.unsubscribe() self.consumer.close()
[ "def", "stop", "(", "self", ")", ":", "log", ".", "info", "(", "'Stopping te kafka listener class'", ")", "self", ".", "consumer", ".", "unsubscribe", "(", ")", "self", ".", "consumer", ".", "close", "(", ")" ]
Shutdown kafka consumer.
[ "Shutdown", "kafka", "consumer", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/kafka.py#L76-L82
651
napalm-automation/napalm-logs
napalm_logs/transport/__init__.py
get_transport
def get_transport(name): ''' Return the transport class. ''' try: log.debug('Using %s as transport', name) return TRANSPORT_LOOKUP[name] except KeyError: msg = 'Transport {} is not available. Are the dependencies installed?'.format(name) log.error(msg, exc_info=True) ...
python
def get_transport(name): ''' Return the transport class. ''' try: log.debug('Using %s as transport', name) return TRANSPORT_LOOKUP[name] except KeyError: msg = 'Transport {} is not available. Are the dependencies installed?'.format(name) log.error(msg, exc_info=True) ...
[ "def", "get_transport", "(", "name", ")", ":", "try", ":", "log", ".", "debug", "(", "'Using %s as transport'", ",", "name", ")", "return", "TRANSPORT_LOOKUP", "[", "name", "]", "except", "KeyError", ":", "msg", "=", "'Transport {} is not available. Are the depend...
Return the transport class.
[ "Return", "the", "transport", "class", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/transport/__init__.py#L50-L60
652
napalm-automation/napalm-logs
napalm_logs/listener/zeromq.py
ZMQListener.start
def start(self): ''' Startup the zmq consumer. ''' zmq_uri = '{protocol}://{address}:{port}'.format( protocol=self.protocol, address=self.address, port=self.port ) if self.port else\ ...
python
def start(self): ''' Startup the zmq consumer. ''' zmq_uri = '{protocol}://{address}:{port}'.format( protocol=self.protocol, address=self.address, port=self.port ) if self.port else\ ...
[ "def", "start", "(", "self", ")", ":", "zmq_uri", "=", "'{protocol}://{address}:{port}'", ".", "format", "(", "protocol", "=", "self", ".", "protocol", ",", "address", "=", "self", ".", "address", ",", "port", "=", "self", ".", "port", ")", "if", "self",...
Startup the zmq consumer.
[ "Startup", "the", "zmq", "consumer", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/zeromq.py#L45-L82
653
napalm-automation/napalm-logs
napalm_logs/listener/zeromq.py
ZMQListener.receive
def receive(self): ''' Return the message received. ..note:: In ZMQ we are unable to get the address where we got the message from. ''' try: msg = self.sub.recv() except zmq.Again as error: log.error('Unable to receive messages: %s', e...
python
def receive(self): ''' Return the message received. ..note:: In ZMQ we are unable to get the address where we got the message from. ''' try: msg = self.sub.recv() except zmq.Again as error: log.error('Unable to receive messages: %s', e...
[ "def", "receive", "(", "self", ")", ":", "try", ":", "msg", "=", "self", ".", "sub", ".", "recv", "(", ")", "except", "zmq", ".", "Again", "as", "error", ":", "log", ".", "error", "(", "'Unable to receive messages: %s'", ",", "error", ",", "exc_info", ...
Return the message received. ..note:: In ZMQ we are unable to get the address where we got the message from.
[ "Return", "the", "message", "received", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/zeromq.py#L84-L97
654
napalm-automation/napalm-logs
napalm_logs/listener/zeromq.py
ZMQListener.stop
def stop(self): ''' Shutdown zmq listener. ''' log.info('Stopping the zmq listener class') self.sub.close() self.ctx.term()
python
def stop(self): ''' Shutdown zmq listener. ''' log.info('Stopping the zmq listener class') self.sub.close() self.ctx.term()
[ "def", "stop", "(", "self", ")", ":", "log", ".", "info", "(", "'Stopping the zmq listener class'", ")", "self", ".", "sub", ".", "close", "(", ")", "self", ".", "ctx", ".", "term", "(", ")" ]
Shutdown zmq listener.
[ "Shutdown", "zmq", "listener", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/zeromq.py#L99-L105
655
napalm-automation/napalm-logs
napalm_logs/listener/udp.py
UDPListener.start
def start(self): ''' Create the UDP listener socket. ''' if ':' in self.address: self.skt = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) else: self.skt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) if self.reuse_port: self.skt...
python
def start(self): ''' Create the UDP listener socket. ''' if ':' in self.address: self.skt = socket.socket(socket.AF_INET6, socket.SOCK_DGRAM) else: self.skt = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) if self.reuse_port: self.skt...
[ "def", "start", "(", "self", ")", ":", "if", "':'", "in", "self", ".", "address", ":", "self", ".", "skt", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET6", ",", "socket", ".", "SOCK_DGRAM", ")", "else", ":", "self", ".", "skt", "=", ...
Create the UDP listener socket.
[ "Create", "the", "UDP", "listener", "socket", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/udp.py#L43-L62
656
napalm-automation/napalm-logs
napalm_logs/proc.py
NapalmLogsProc._suicide_when_without_parent
def _suicide_when_without_parent(self, parent_pid): ''' Kill this process when the parent died. ''' while True: time.sleep(5) try: # Check pid alive os.kill(parent_pid, 0) except OSError: # Forcibly exit ...
python
def _suicide_when_without_parent(self, parent_pid): ''' Kill this process when the parent died. ''' while True: time.sleep(5) try: # Check pid alive os.kill(parent_pid, 0) except OSError: # Forcibly exit ...
[ "def", "_suicide_when_without_parent", "(", "self", ",", "parent_pid", ")", ":", "while", "True", ":", "time", ".", "sleep", "(", "5", ")", "try", ":", "# Check pid alive", "os", ".", "kill", "(", "parent_pid", ",", "0", ")", "except", "OSError", ":", "#...
Kill this process when the parent died.
[ "Kill", "this", "process", "when", "the", "parent", "died", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/proc.py#L20-L34
657
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._setup_buffer
def _setup_buffer(self): ''' Setup the buffer subsystem. ''' if not self._buffer_cfg or not isinstance(self._buffer_cfg, dict): return buffer_name = list(self._buffer_cfg.keys())[0] buffer_class = napalm_logs.buffer.get_interface(buffer_name) log.debug...
python
def _setup_buffer(self): ''' Setup the buffer subsystem. ''' if not self._buffer_cfg or not isinstance(self._buffer_cfg, dict): return buffer_name = list(self._buffer_cfg.keys())[0] buffer_class = napalm_logs.buffer.get_interface(buffer_name) log.debug...
[ "def", "_setup_buffer", "(", "self", ")", ":", "if", "not", "self", ".", "_buffer_cfg", "or", "not", "isinstance", "(", "self", ".", "_buffer_cfg", ",", "dict", ")", ":", "return", "buffer_name", "=", "list", "(", "self", ".", "_buffer_cfg", ".", "keys",...
Setup the buffer subsystem.
[ "Setup", "the", "buffer", "subsystem", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L134-L145
658
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._setup_metrics
def _setup_metrics(self): """ Start metric exposition """ path = os.environ.get("prometheus_multiproc_dir") if not os.path.exists(self.metrics_dir): try: log.info("Creating metrics directory") os.makedirs(self.metrics_dir) e...
python
def _setup_metrics(self): """ Start metric exposition """ path = os.environ.get("prometheus_multiproc_dir") if not os.path.exists(self.metrics_dir): try: log.info("Creating metrics directory") os.makedirs(self.metrics_dir) e...
[ "def", "_setup_metrics", "(", "self", ")", ":", "path", "=", "os", ".", "environ", ".", "get", "(", "\"prometheus_multiproc_dir\"", ")", "if", "not", "os", ".", "path", ".", "exists", "(", "self", ".", "metrics_dir", ")", ":", "try", ":", "log", ".", ...
Start metric exposition
[ "Start", "metric", "exposition" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L147-L177
659
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._setup_log
def _setup_log(self): ''' Setup the log object. ''' logging_level = CONFIG.LOGGING_LEVEL.get(self.log_level.lower()) logging.basicConfig(format=self.log_format, level=logging_level)
python
def _setup_log(self): ''' Setup the log object. ''' logging_level = CONFIG.LOGGING_LEVEL.get(self.log_level.lower()) logging.basicConfig(format=self.log_format, level=logging_level)
[ "def", "_setup_log", "(", "self", ")", ":", "logging_level", "=", "CONFIG", ".", "LOGGING_LEVEL", ".", "get", "(", "self", ".", "log_level", ".", "lower", "(", ")", ")", "logging", ".", "basicConfig", "(", "format", "=", "self", ".", "log_format", ",", ...
Setup the log object.
[ "Setup", "the", "log", "object", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L179-L185
660
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._whitelist_blacklist
def _whitelist_blacklist(self, os_name): ''' Determines if the OS should be ignored, depending on the whitelist-blacklist logic configured by the user. ''' return napalm_logs.ext.check_whitelist_blacklist(os_name, w...
python
def _whitelist_blacklist(self, os_name): ''' Determines if the OS should be ignored, depending on the whitelist-blacklist logic configured by the user. ''' return napalm_logs.ext.check_whitelist_blacklist(os_name, w...
[ "def", "_whitelist_blacklist", "(", "self", ",", "os_name", ")", ":", "return", "napalm_logs", ".", "ext", ".", "check_whitelist_blacklist", "(", "os_name", ",", "whitelist", "=", "self", ".", "device_whitelist", ",", "blacklist", "=", "self", ".", "device_black...
Determines if the OS should be ignored, depending on the whitelist-blacklist logic configured by the user.
[ "Determines", "if", "the", "OS", "should", "be", "ignored", "depending", "on", "the", "whitelist", "-", "blacklist", "logic", "configured", "by", "the", "user", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L223-L231
661
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._extract_yaml_docstring
def _extract_yaml_docstring(stream): ''' Extract the comments at the top of the YAML file, from the stream handler. Return the extracted comment as string. ''' comment_lines = [] lines = stream.read().splitlines() for line in lines: line_strip ...
python
def _extract_yaml_docstring(stream): ''' Extract the comments at the top of the YAML file, from the stream handler. Return the extracted comment as string. ''' comment_lines = [] lines = stream.read().splitlines() for line in lines: line_strip ...
[ "def", "_extract_yaml_docstring", "(", "stream", ")", ":", "comment_lines", "=", "[", "]", "lines", "=", "stream", ".", "read", "(", ")", ".", "splitlines", "(", ")", "for", "line", "in", "lines", ":", "line_strip", "=", "line", ".", "strip", "(", ")",...
Extract the comments at the top of the YAML file, from the stream handler. Return the extracted comment as string.
[ "Extract", "the", "comments", "at", "the", "top", "of", "the", "YAML", "file", "from", "the", "stream", "handler", ".", "Return", "the", "extracted", "comment", "as", "string", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L234-L252
662
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._verify_config_dict
def _verify_config_dict(self, valid, config, dev_os, key_path=None): ''' Verify if the config dict is valid. ''' if not key_path: key_path = [] for key, value in valid.items(): self._verify_config_key(key, value, valid, config, dev_os, key_path)
python
def _verify_config_dict(self, valid, config, dev_os, key_path=None): ''' Verify if the config dict is valid. ''' if not key_path: key_path = [] for key, value in valid.items(): self._verify_config_key(key, value, valid, config, dev_os, key_path)
[ "def", "_verify_config_dict", "(", "self", ",", "valid", ",", "config", ",", "dev_os", ",", "key_path", "=", "None", ")", ":", "if", "not", "key_path", ":", "key_path", "=", "[", "]", "for", "key", ",", "value", "in", "valid", ".", "items", "(", ")",...
Verify if the config dict is valid.
[ "Verify", "if", "the", "config", "dict", "is", "valid", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L461-L468
663
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._verify_config
def _verify_config(self): ''' Verify that the config is correct ''' if not self.config_dict: self._raise_config_exception('No config found') # Check for device conifg, if there isn't anything then just log, do not raise an exception for dev_os, dev_config in s...
python
def _verify_config(self): ''' Verify that the config is correct ''' if not self.config_dict: self._raise_config_exception('No config found') # Check for device conifg, if there isn't anything then just log, do not raise an exception for dev_os, dev_config in s...
[ "def", "_verify_config", "(", "self", ")", ":", "if", "not", "self", ".", "config_dict", ":", "self", ".", "_raise_config_exception", "(", "'No config found'", ")", "# Check for device conifg, if there isn't anything then just log, do not raise an exception", "for", "dev_os",...
Verify that the config is correct
[ "Verify", "that", "the", "config", "is", "correct" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L470-L483
664
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._build_config
def _build_config(self): ''' Build the config of the napalm syslog parser. ''' if not self.config_dict: if not self.config_path: # No custom config path requested # Read the native config files self.config_path = os.path.join( ...
python
def _build_config(self): ''' Build the config of the napalm syslog parser. ''' if not self.config_dict: if not self.config_path: # No custom config path requested # Read the native config files self.config_path = os.path.join( ...
[ "def", "_build_config", "(", "self", ")", ":", "if", "not", "self", ".", "config_dict", ":", "if", "not", "self", ".", "config_path", ":", "# No custom config path requested", "# Read the native config files", "self", ".", "config_path", "=", "os", ".", "path", ...
Build the config of the napalm syslog parser.
[ "Build", "the", "config", "of", "the", "napalm", "syslog", "parser", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L485-L507
665
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._start_auth_proc
def _start_auth_proc(self): ''' Start the authenticator process. ''' log.debug('Computing the signing key hex') verify_key = self.__signing_key.verify_key sgn_verify_hex = verify_key.encode(encoder=nacl.encoding.HexEncoder) log.debug('Starting the authenticator su...
python
def _start_auth_proc(self): ''' Start the authenticator process. ''' log.debug('Computing the signing key hex') verify_key = self.__signing_key.verify_key sgn_verify_hex = verify_key.encode(encoder=nacl.encoding.HexEncoder) log.debug('Starting the authenticator su...
[ "def", "_start_auth_proc", "(", "self", ")", ":", "log", ".", "debug", "(", "'Computing the signing key hex'", ")", "verify_key", "=", "self", ".", "__signing_key", ".", "verify_key", "sgn_verify_hex", "=", "verify_key", ".", "encode", "(", "encoder", "=", "nacl...
Start the authenticator process.
[ "Start", "the", "authenticator", "process", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L509-L527
666
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._start_lst_proc
def _start_lst_proc(self, listener_type, listener_opts): ''' Start the listener process. ''' log.debug('Starting the listener process for %s', listener_type) listener = NapalmLogsListenerProc(self.opts, ...
python
def _start_lst_proc(self, listener_type, listener_opts): ''' Start the listener process. ''' log.debug('Starting the listener process for %s', listener_type) listener = NapalmLogsListenerProc(self.opts, ...
[ "def", "_start_lst_proc", "(", "self", ",", "listener_type", ",", "listener_opts", ")", ":", "log", ".", "debug", "(", "'Starting the listener process for %s'", ",", "listener_type", ")", "listener", "=", "NapalmLogsListenerProc", "(", "self", ".", "opts", ",", "s...
Start the listener process.
[ "Start", "the", "listener", "process", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L529-L545
667
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._start_srv_proc
def _start_srv_proc(self, started_os_proc): ''' Start the server process. ''' log.debug('Starting the server process') server = NapalmLogsServerProc(self.opts, self.config_dict, st...
python
def _start_srv_proc(self, started_os_proc): ''' Start the server process. ''' log.debug('Starting the server process') server = NapalmLogsServerProc(self.opts, self.config_dict, st...
[ "def", "_start_srv_proc", "(", "self", ",", "started_os_proc", ")", ":", "log", ".", "debug", "(", "'Starting the server process'", ")", "server", "=", "NapalmLogsServerProc", "(", "self", ".", "opts", ",", "self", ".", "config_dict", ",", "started_os_proc", ","...
Start the server process.
[ "Start", "the", "server", "process", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L547-L561
668
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._start_pub_proc
def _start_pub_proc(self, publisher_type, publisher_opts, pub_id): ''' Start the publisher process. ''' log.debug('Starting the publisher process for %s', publisher_type) publisher = NapalmLogsPublisherProc(s...
python
def _start_pub_proc(self, publisher_type, publisher_opts, pub_id): ''' Start the publisher process. ''' log.debug('Starting the publisher process for %s', publisher_type) publisher = NapalmLogsPublisherProc(s...
[ "def", "_start_pub_proc", "(", "self", ",", "publisher_type", ",", "publisher_opts", ",", "pub_id", ")", ":", "log", ".", "debug", "(", "'Starting the publisher process for %s'", ",", "publisher_type", ")", "publisher", "=", "NapalmLogsPublisherProc", "(", "self", "...
Start the publisher process.
[ "Start", "the", "publisher", "process", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L573-L595
669
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._start_dev_proc
def _start_dev_proc(self, device_os, device_config): ''' Start the device worker process. ''' log.info('Starting the child process for %s', device_os) dos = NapalmLogsDeviceProc(device_os, self.opt...
python
def _start_dev_proc(self, device_os, device_config): ''' Start the device worker process. ''' log.info('Starting the child process for %s', device_os) dos = NapalmLogsDeviceProc(device_os, self.opt...
[ "def", "_start_dev_proc", "(", "self", ",", "device_os", ",", "device_config", ")", ":", "log", ".", "info", "(", "'Starting the child process for %s'", ",", "device_os", ")", "dos", "=", "NapalmLogsDeviceProc", "(", "device_os", ",", "self", ".", "opts", ",", ...
Start the device worker process.
[ "Start", "the", "device", "worker", "process", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L597-L611
670
napalm-automation/napalm-logs
napalm_logs/base.py
NapalmLogs._check_children
def _check_children(self): ''' Check all of the child processes are still running ''' while self.up: time.sleep(1) for process in self._processes: if process.is_alive() is True: continue log.debug('%s is dead. St...
python
def _check_children(self): ''' Check all of the child processes are still running ''' while self.up: time.sleep(1) for process in self._processes: if process.is_alive() is True: continue log.debug('%s is dead. St...
[ "def", "_check_children", "(", "self", ")", ":", "while", "self", ".", "up", ":", "time", ".", "sleep", "(", "1", ")", "for", "process", "in", "self", ".", "_processes", ":", "if", "process", ".", "is_alive", "(", ")", "is", "True", ":", "continue", ...
Check all of the child processes are still running
[ "Check", "all", "of", "the", "child", "processes", "are", "still", "running" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/base.py#L664-L674
671
napalm-automation/napalm-logs
napalm_logs/pub_proxy.py
NapalmLogsPublisherProxy._setup_ipc
def _setup_ipc(self): ''' Setup the IPC PUB and SUB sockets for the proxy. ''' log.debug('Setting up the internal IPC proxy') self.ctx = zmq.Context() # Frontend self.sub = self.ctx.socket(zmq.SUB) self.sub.bind(PUB_PX_IPC_URL) self.sub.setsockopt(...
python
def _setup_ipc(self): ''' Setup the IPC PUB and SUB sockets for the proxy. ''' log.debug('Setting up the internal IPC proxy') self.ctx = zmq.Context() # Frontend self.sub = self.ctx.socket(zmq.SUB) self.sub.bind(PUB_PX_IPC_URL) self.sub.setsockopt(...
[ "def", "_setup_ipc", "(", "self", ")", ":", "log", ".", "debug", "(", "'Setting up the internal IPC proxy'", ")", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "# Frontend", "self", ".", "sub", "=", "self", ".", "ctx", ".", "socket", "(", "...
Setup the IPC PUB and SUB sockets for the proxy.
[ "Setup", "the", "IPC", "PUB", "and", "SUB", "sockets", "for", "the", "proxy", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/pub_proxy.py#L38-L64
672
napalm-automation/napalm-logs
napalm_logs/publisher.py
NapalmLogsPublisherProc._setup_ipc
def _setup_ipc(self): ''' Subscribe to the pub IPC and publish the messages on the right transport. ''' self.ctx = zmq.Context() log.debug('Setting up the %s publisher subscriber #%d', self._transport_type, self.pub_id) self.sub = self.ctx.socket(zmq.SUB) ...
python
def _setup_ipc(self): ''' Subscribe to the pub IPC and publish the messages on the right transport. ''' self.ctx = zmq.Context() log.debug('Setting up the %s publisher subscriber #%d', self._transport_type, self.pub_id) self.sub = self.ctx.socket(zmq.SUB) ...
[ "def", "_setup_ipc", "(", "self", ")", ":", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "log", ".", "debug", "(", "'Setting up the %s publisher subscriber #%d'", ",", "self", ".", "_transport_type", ",", "self", ".", "pub_id", ")", "self", "....
Subscribe to the pub IPC and publish the messages on the right transport.
[ "Subscribe", "to", "the", "pub", "IPC", "and", "publish", "the", "messages", "on", "the", "right", "transport", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/publisher.py#L71-L87
673
napalm-automation/napalm-logs
napalm_logs/publisher.py
NapalmLogsPublisherProc._prepare
def _prepare(self, serialized_obj): ''' Prepare the object to be sent over the untrusted channel. ''' # generating a nonce nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE) # encrypting using the nonce encrypted = self.__safe.encrypt(serialized_obj, nonc...
python
def _prepare(self, serialized_obj): ''' Prepare the object to be sent over the untrusted channel. ''' # generating a nonce nonce = nacl.utils.random(nacl.secret.SecretBox.NONCE_SIZE) # encrypting using the nonce encrypted = self.__safe.encrypt(serialized_obj, nonc...
[ "def", "_prepare", "(", "self", ",", "serialized_obj", ")", ":", "# generating a nonce", "nonce", "=", "nacl", ".", "utils", ".", "random", "(", "nacl", ".", "secret", ".", "SecretBox", ".", "NONCE_SIZE", ")", "# encrypting using the nonce", "encrypted", "=", ...
Prepare the object to be sent over the untrusted channel.
[ "Prepare", "the", "object", "to", "be", "sent", "over", "the", "untrusted", "channel", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/publisher.py#L110-L120
674
napalm-automation/napalm-logs
napalm_logs/listener/__init__.py
get_listener
def get_listener(name): ''' Return the listener class. ''' try: log.debug('Using %s as listener', name) return LISTENER_LOOKUP[name] except KeyError: msg = 'Listener {} is not available. Are the dependencies installed?'.format(name) log.error(msg, exc_info=True) ...
python
def get_listener(name): ''' Return the listener class. ''' try: log.debug('Using %s as listener', name) return LISTENER_LOOKUP[name] except KeyError: msg = 'Listener {} is not available. Are the dependencies installed?'.format(name) log.error(msg, exc_info=True) ...
[ "def", "get_listener", "(", "name", ")", ":", "try", ":", "log", ".", "debug", "(", "'Using %s as listener'", ",", "name", ")", "return", "LISTENER_LOOKUP", "[", "name", "]", "except", "KeyError", ":", "msg", "=", "'Listener {} is not available. Are the dependenci...
Return the listener class.
[ "Return", "the", "listener", "class", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/__init__.py#L41-L51
675
napalm-automation/napalm-logs
napalm_logs/utils/__init__.py
ClientAuth._start_keep_alive
def _start_keep_alive(self): ''' Start the keep alive thread as a daemon ''' keep_alive_thread = threading.Thread(target=self.keep_alive) keep_alive_thread.daemon = True keep_alive_thread.start()
python
def _start_keep_alive(self): ''' Start the keep alive thread as a daemon ''' keep_alive_thread = threading.Thread(target=self.keep_alive) keep_alive_thread.daemon = True keep_alive_thread.start()
[ "def", "_start_keep_alive", "(", "self", ")", ":", "keep_alive_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "keep_alive", ")", "keep_alive_thread", ".", "daemon", "=", "True", "keep_alive_thread", ".", "start", "(", ")" ]
Start the keep alive thread as a daemon
[ "Start", "the", "keep", "alive", "thread", "as", "a", "daemon" ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L61-L67
676
napalm-automation/napalm-logs
napalm_logs/utils/__init__.py
ClientAuth.keep_alive
def keep_alive(self): ''' Send a keep alive request periodically to make sure that the server is still alive. If not then try to reconnect. ''' self.ssl_skt.settimeout(defaults.AUTH_KEEP_ALIVE_INTERVAL) while self.__up: try: log.debug('Sending ...
python
def keep_alive(self): ''' Send a keep alive request periodically to make sure that the server is still alive. If not then try to reconnect. ''' self.ssl_skt.settimeout(defaults.AUTH_KEEP_ALIVE_INTERVAL) while self.__up: try: log.debug('Sending ...
[ "def", "keep_alive", "(", "self", ")", ":", "self", ".", "ssl_skt", ".", "settimeout", "(", "defaults", ".", "AUTH_KEEP_ALIVE_INTERVAL", ")", "while", "self", ".", "__up", ":", "try", ":", "log", ".", "debug", "(", "'Sending keep-alive message to the server'", ...
Send a keep alive request periodically to make sure that the server is still alive. If not then try to reconnect.
[ "Send", "a", "keep", "alive", "request", "periodically", "to", "make", "sure", "that", "the", "server", "is", "still", "alive", ".", "If", "not", "then", "try", "to", "reconnect", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L69-L92
677
napalm-automation/napalm-logs
napalm_logs/utils/__init__.py
ClientAuth.reconnect
def reconnect(self): ''' Try to reconnect and re-authenticate with the server. ''' log.debug('Closing the SSH socket.') try: self.ssl_skt.close() except socket.error: log.error('The socket seems to be closed already.') log.debug('Re-opening...
python
def reconnect(self): ''' Try to reconnect and re-authenticate with the server. ''' log.debug('Closing the SSH socket.') try: self.ssl_skt.close() except socket.error: log.error('The socket seems to be closed already.') log.debug('Re-opening...
[ "def", "reconnect", "(", "self", ")", ":", "log", ".", "debug", "(", "'Closing the SSH socket.'", ")", "try", ":", "self", ".", "ssl_skt", ".", "close", "(", ")", "except", "socket", ".", "error", ":", "log", ".", "error", "(", "'The socket seems to be clo...
Try to reconnect and re-authenticate with the server.
[ "Try", "to", "reconnect", "and", "re", "-", "authenticate", "with", "the", "server", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L94-L104
678
napalm-automation/napalm-logs
napalm_logs/utils/__init__.py
ClientAuth.authenticate
def authenticate(self): ''' Authenticate the client and return the private and signature keys. Establish a connection through a secured socket, then do the handshake using the napalm-logs auth algorithm. ''' log.debug('Authenticate to %s:%d, using the cer...
python
def authenticate(self): ''' Authenticate the client and return the private and signature keys. Establish a connection through a secured socket, then do the handshake using the napalm-logs auth algorithm. ''' log.debug('Authenticate to %s:%d, using the cer...
[ "def", "authenticate", "(", "self", ")", ":", "log", ".", "debug", "(", "'Authenticate to %s:%d, using the certificate %s'", ",", "self", ".", "address", ",", "self", ".", "port", ",", "self", ".", "certificate", ")", "if", "':'", "in", "self", ".", "address...
Authenticate the client and return the private and signature keys. Establish a connection through a secured socket, then do the handshake using the napalm-logs auth algorithm.
[ "Authenticate", "the", "client", "and", "return", "the", "private", "and", "signature", "keys", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L106-L150
679
napalm-automation/napalm-logs
napalm_logs/utils/__init__.py
ClientAuth.decrypt
def decrypt(self, binary): ''' Decrypt and unpack the original OpenConfig object, serialized using MessagePack. Raise BadSignatureException when the signature was forged or corrupted. ''' try: encrypted = self.verify_key.verify(binary) except B...
python
def decrypt(self, binary): ''' Decrypt and unpack the original OpenConfig object, serialized using MessagePack. Raise BadSignatureException when the signature was forged or corrupted. ''' try: encrypted = self.verify_key.verify(binary) except B...
[ "def", "decrypt", "(", "self", ",", "binary", ")", ":", "try", ":", "encrypted", "=", "self", ".", "verify_key", ".", "verify", "(", "binary", ")", "except", "BadSignatureError", ":", "log", ".", "error", "(", "'Signature was forged or corrupt'", ",", "exc_i...
Decrypt and unpack the original OpenConfig object, serialized using MessagePack. Raise BadSignatureException when the signature was forged or corrupted.
[ "Decrypt", "and", "unpack", "the", "original", "OpenConfig", "object", "serialized", "using", "MessagePack", ".", "Raise", "BadSignatureException", "when", "the", "signature", "was", "forged", "or", "corrupted", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/utils/__init__.py#L152-L169
680
napalm-automation/napalm-logs
napalm_logs/listener/tcp.py
TCPListener._client_connection
def _client_connection(self, conn, addr): ''' Handle the connecition with one client. ''' log.debug('Established connection with %s:%d', addr[0], addr[1]) conn.settimeout(self.socket_timeout) try: while self.__up: msg = conn.recv(self.buffer_si...
python
def _client_connection(self, conn, addr): ''' Handle the connecition with one client. ''' log.debug('Established connection with %s:%d', addr[0], addr[1]) conn.settimeout(self.socket_timeout) try: while self.__up: msg = conn.recv(self.buffer_si...
[ "def", "_client_connection", "(", "self", ",", "conn", ",", "addr", ")", ":", "log", ".", "debug", "(", "'Established connection with %s:%d'", ",", "addr", "[", "0", "]", ",", "addr", "[", "1", "]", ")", "conn", ".", "settimeout", "(", "self", ".", "so...
Handle the connecition with one client.
[ "Handle", "the", "connecition", "with", "one", "client", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L53-L75
681
napalm-automation/napalm-logs
napalm_logs/listener/tcp.py
TCPListener._serve_clients
def _serve_clients(self): ''' Accept cients and serve, one separate thread per client. ''' self.__up = True while self.__up: log.debug('Waiting for a client to connect') try: conn, addr = self.skt.accept() log.debug('Receive...
python
def _serve_clients(self): ''' Accept cients and serve, one separate thread per client. ''' self.__up = True while self.__up: log.debug('Waiting for a client to connect') try: conn, addr = self.skt.accept() log.debug('Receive...
[ "def", "_serve_clients", "(", "self", ")", ":", "self", ".", "__up", "=", "True", "while", "self", ".", "__up", ":", "log", ".", "debug", "(", "'Waiting for a client to connect'", ")", "try", ":", "conn", ",", "addr", "=", "self", ".", "skt", ".", "acc...
Accept cients and serve, one separate thread per client.
[ "Accept", "cients", "and", "serve", "one", "separate", "thread", "per", "client", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L77-L94
682
napalm-automation/napalm-logs
napalm_logs/listener/tcp.py
TCPListener.start
def start(self): ''' Start listening for messages. ''' log.debug('Creating the TCP server') if ':' in self.address: self.skt = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) else: self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ...
python
def start(self): ''' Start listening for messages. ''' log.debug('Creating the TCP server') if ':' in self.address: self.skt = socket.socket(socket.AF_INET6, socket.SOCK_STREAM) else: self.skt = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ...
[ "def", "start", "(", "self", ")", ":", "log", ".", "debug", "(", "'Creating the TCP server'", ")", "if", "':'", "in", "self", ".", "address", ":", "self", ".", "skt", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET6", ",", "socket", ".", "...
Start listening for messages.
[ "Start", "listening", "for", "messages", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L96-L120
683
napalm-automation/napalm-logs
napalm_logs/listener/tcp.py
TCPListener.receive
def receive(self): ''' Return one message dequeued from the listen buffer. ''' while self.buffer.empty() and self.__up: # This sequence is skipped when the buffer is not empty. sleep_ms = random.randint(0, 1000) # log.debug('The message queue is empty,...
python
def receive(self): ''' Return one message dequeued from the listen buffer. ''' while self.buffer.empty() and self.__up: # This sequence is skipped when the buffer is not empty. sleep_ms = random.randint(0, 1000) # log.debug('The message queue is empty,...
[ "def", "receive", "(", "self", ")", ":", "while", "self", ".", "buffer", ".", "empty", "(", ")", "and", "self", ".", "__up", ":", "# This sequence is skipped when the buffer is not empty.", "sleep_ms", "=", "random", ".", "randint", "(", "0", ",", "1000", ")...
Return one message dequeued from the listen buffer.
[ "Return", "one", "message", "dequeued", "from", "the", "listen", "buffer", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L122-L134
684
napalm-automation/napalm-logs
napalm_logs/listener/tcp.py
TCPListener.stop
def stop(self): ''' Closing the socket. ''' log.info('Stopping the TCP listener') self.__up = False try: self.skt.shutdown(socket.SHUT_RDWR) except socket.error: log.error('The following error may not be critical:', exc_info=True) s...
python
def stop(self): ''' Closing the socket. ''' log.info('Stopping the TCP listener') self.__up = False try: self.skt.shutdown(socket.SHUT_RDWR) except socket.error: log.error('The following error may not be critical:', exc_info=True) s...
[ "def", "stop", "(", "self", ")", ":", "log", ".", "info", "(", "'Stopping the TCP listener'", ")", "self", ".", "__up", "=", "False", "try", ":", "self", ".", "skt", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "except", "socket", ".", "error...
Closing the socket.
[ "Closing", "the", "socket", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener/tcp.py#L136-L146
685
napalm-automation/napalm-logs
napalm_logs/listener_proc.py
NapalmLogsListenerProc._setup_ipc
def _setup_ipc(self): ''' Setup the listener ICP pusher. ''' log.debug('Setting up the listener IPC pusher') self.ctx = zmq.Context() self.pub = self.ctx.socket(zmq.PUSH) self.pub.connect(LST_IPC_URL) log.debug('Setting HWM for the listener: %d', self.opts...
python
def _setup_ipc(self): ''' Setup the listener ICP pusher. ''' log.debug('Setting up the listener IPC pusher') self.ctx = zmq.Context() self.pub = self.ctx.socket(zmq.PUSH) self.pub.connect(LST_IPC_URL) log.debug('Setting HWM for the listener: %d', self.opts...
[ "def", "_setup_ipc", "(", "self", ")", ":", "log", ".", "debug", "(", "'Setting up the listener IPC pusher'", ")", "self", ".", "ctx", "=", "zmq", ".", "Context", "(", ")", "self", ".", "pub", "=", "self", ".", "ctx", ".", "socket", "(", "zmq", ".", ...
Setup the listener ICP pusher.
[ "Setup", "the", "listener", "ICP", "pusher", "." ]
4b89100a6e4f994aa004f3ea42a06dc803a7ccb0
https://github.com/napalm-automation/napalm-logs/blob/4b89100a6e4f994aa004f3ea42a06dc803a7ccb0/napalm_logs/listener_proc.py#L62-L76
686
poppy-project/pypot
pypot/utils/stoppablethread.py
make_update_loop
def make_update_loop(thread, update_func): """ Makes a run loop which calls an update function at a predefined frequency. """ while not thread.should_stop(): if thread.should_pause(): thread.wait_to_resume() start = time.time() if hasattr(thread, '_updated'): thr...
python
def make_update_loop(thread, update_func): """ Makes a run loop which calls an update function at a predefined frequency. """ while not thread.should_stop(): if thread.should_pause(): thread.wait_to_resume() start = time.time() if hasattr(thread, '_updated'): thr...
[ "def", "make_update_loop", "(", "thread", ",", "update_func", ")", ":", "while", "not", "thread", ".", "should_stop", "(", ")", ":", "if", "thread", ".", "should_pause", "(", ")", ":", "thread", ".", "wait_to_resume", "(", ")", "start", "=", "time", ".",...
Makes a run loop which calls an update function at a predefined frequency.
[ "Makes", "a", "run", "loop", "which", "calls", "an", "update", "function", "at", "a", "predefined", "frequency", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/stoppablethread.py#L166-L183
687
poppy-project/pypot
pypot/utils/stoppablethread.py
StoppableThread.start
def start(self): """ Start the run method as a new thread. It will first stop the thread if it is already running. """ if self.running: self.stop() self._thread = threading.Thread(target=self._wrapped_target) self._thread.daemon = True self._thread....
python
def start(self): """ Start the run method as a new thread. It will first stop the thread if it is already running. """ if self.running: self.stop() self._thread = threading.Thread(target=self._wrapped_target) self._thread.daemon = True self._thread....
[ "def", "start", "(", "self", ")", ":", "if", "self", ".", "running", ":", "self", ".", "stop", "(", ")", "self", ".", "_thread", "=", "threading", ".", "Thread", "(", "target", "=", "self", ".", "_wrapped_target", ")", "self", ".", "_thread", ".", ...
Start the run method as a new thread. It will first stop the thread if it is already running.
[ "Start", "the", "run", "method", "as", "a", "new", "thread", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/stoppablethread.py#L33-L44
688
poppy-project/pypot
pypot/utils/stoppablethread.py
StoppableThread.wait_to_start
def wait_to_start(self, allow_failure=False): """ Wait for the thread to actually starts. """ self._started.wait() if self._crashed and not allow_failure: self._thread.join() raise RuntimeError('Setup failed, see {} Traceback' 'for details....
python
def wait_to_start(self, allow_failure=False): """ Wait for the thread to actually starts. """ self._started.wait() if self._crashed and not allow_failure: self._thread.join() raise RuntimeError('Setup failed, see {} Traceback' 'for details....
[ "def", "wait_to_start", "(", "self", ",", "allow_failure", "=", "False", ")", ":", "self", ".", "_started", ".", "wait", "(", ")", "if", "self", ".", "_crashed", "and", "not", "allow_failure", ":", "self", ".", "_thread", ".", "join", "(", ")", "raise"...
Wait for the thread to actually starts.
[ "Wait", "for", "the", "thread", "to", "actually", "starts", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/utils/stoppablethread.py#L82-L89
689
poppy-project/pypot
pypot/vrep/__init__.py
from_vrep
def from_vrep(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None, tracked_objects=[], tracked_collisions=[], id=None, shared_vrep_io=None): """ Create a robot from a V-REP instance. :param config: robot configuration (either the path to the json or directly the dictionary) ...
python
def from_vrep(config, vrep_host='127.0.0.1', vrep_port=19997, scene=None, tracked_objects=[], tracked_collisions=[], id=None, shared_vrep_io=None): """ Create a robot from a V-REP instance. :param config: robot configuration (either the path to the json or directly the dictionary) ...
[ "def", "from_vrep", "(", "config", ",", "vrep_host", "=", "'127.0.0.1'", ",", "vrep_port", "=", "19997", ",", "scene", "=", "None", ",", "tracked_objects", "=", "[", "]", ",", "tracked_collisions", "=", "[", "]", ",", "id", "=", "None", ",", "shared_vrep...
Create a robot from a V-REP instance. :param config: robot configuration (either the path to the json or directly the dictionary) :type config: str or dict :param str vrep_host: host of the V-REP server :param int vrep_port: port of the V-REP server :param str scene: path to the V-REP scene to load...
[ "Create", "a", "robot", "from", "a", "V", "-", "REP", "instance", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/__init__.py#L52-L176
690
poppy-project/pypot
pypot/dynamixel/io/io.py
DxlIO.set_wheel_mode
def set_wheel_mode(self, ids): """ Sets the specified motors to wheel mode. """ self.set_control_mode(dict(zip(ids, itertools.repeat('wheel'))))
python
def set_wheel_mode(self, ids): """ Sets the specified motors to wheel mode. """ self.set_control_mode(dict(zip(ids, itertools.repeat('wheel'))))
[ "def", "set_wheel_mode", "(", "self", ",", "ids", ")", ":", "self", ".", "set_control_mode", "(", "dict", "(", "zip", "(", "ids", ",", "itertools", ".", "repeat", "(", "'wheel'", ")", ")", ")", ")" ]
Sets the specified motors to wheel mode.
[ "Sets", "the", "specified", "motors", "to", "wheel", "mode", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io.py#L30-L32
691
poppy-project/pypot
pypot/dynamixel/io/io.py
DxlIO.set_joint_mode
def set_joint_mode(self, ids): """ Sets the specified motors to joint mode. """ self.set_control_mode(dict(zip(ids, itertools.repeat('joint'))))
python
def set_joint_mode(self, ids): """ Sets the specified motors to joint mode. """ self.set_control_mode(dict(zip(ids, itertools.repeat('joint'))))
[ "def", "set_joint_mode", "(", "self", ",", "ids", ")", ":", "self", ".", "set_control_mode", "(", "dict", "(", "zip", "(", "ids", ",", "itertools", ".", "repeat", "(", "'joint'", ")", ")", ")", ")" ]
Sets the specified motors to joint mode.
[ "Sets", "the", "specified", "motors", "to", "joint", "mode", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io.py#L34-L36
692
poppy-project/pypot
pypot/dynamixel/io/io.py
DxlIO.set_angle_limit
def set_angle_limit(self, limit_for_id, **kwargs): """ Sets the angle limit to the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert if 'wheel' in self.get_control_mode(limit_for_id.keys()): raise ValueError('can not change the angle limit o...
python
def set_angle_limit(self, limit_for_id, **kwargs): """ Sets the angle limit to the specified motors. """ convert = kwargs['convert'] if 'convert' in kwargs else self._convert if 'wheel' in self.get_control_mode(limit_for_id.keys()): raise ValueError('can not change the angle limit o...
[ "def", "set_angle_limit", "(", "self", ",", "limit_for_id", ",", "*", "*", "kwargs", ")", ":", "convert", "=", "kwargs", "[", "'convert'", "]", "if", "'convert'", "in", "kwargs", "else", "self", ".", "_convert", "if", "'wheel'", "in", "self", ".", "get_c...
Sets the angle limit to the specified motors.
[ "Sets", "the", "angle", "limit", "to", "the", "specified", "motors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/dynamixel/io/io.py#L55-L65
693
poppy-project/pypot
pypot/robot/robot.py
Robot.close
def close(self): """ Cleans the robot by stopping synchronization and all controllers.""" self.stop_sync() [c.io.close() for c in self._controllers if c.io is not None]
python
def close(self): """ Cleans the robot by stopping synchronization and all controllers.""" self.stop_sync() [c.io.close() for c in self._controllers if c.io is not None]
[ "def", "close", "(", "self", ")", ":", "self", ".", "stop_sync", "(", ")", "[", "c", ".", "io", ".", "close", "(", ")", "for", "c", "in", "self", ".", "_controllers", "if", "c", ".", "io", "is", "not", "None", "]" ]
Cleans the robot by stopping synchronization and all controllers.
[ "Cleans", "the", "robot", "by", "stopping", "synchronization", "and", "all", "controllers", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L51-L54
694
poppy-project/pypot
pypot/robot/robot.py
Robot.goto_position
def goto_position(self, position_for_motors, duration, control=None, wait=False): """ Moves a subset of the motors to a position within a specific duration. :param dict position_for_motors: which motors you want to move {motor_name: pos, motor_name: pos,...} :param float duration: durat...
python
def goto_position(self, position_for_motors, duration, control=None, wait=False): """ Moves a subset of the motors to a position within a specific duration. :param dict position_for_motors: which motors you want to move {motor_name: pos, motor_name: pos,...} :param float duration: durat...
[ "def", "goto_position", "(", "self", ",", "position_for_motors", ",", "duration", ",", "control", "=", "None", ",", "wait", "=", "False", ")", ":", "for", "i", ",", "(", "motor_name", ",", "position", ")", "in", "enumerate", "(", "position_for_motors", "."...
Moves a subset of the motors to a position within a specific duration. :param dict position_for_motors: which motors you want to move {motor_name: pos, motor_name: pos,...} :param float duration: duration of the move :param str control: control type ('dummy', 'minjerk') ...
[ "Moves", "a", "subset", "of", "the", "motors", "to", "a", "position", "within", "a", "specific", "duration", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L126-L141
695
poppy-project/pypot
pypot/robot/robot.py
Robot.power_up
def power_up(self): """ Changes all settings to guarantee the motors will be used at their maximum power. """ for m in self.motors: m.compliant = False m.moving_speed = 0 m.torque_limit = 100.0
python
def power_up(self): """ Changes all settings to guarantee the motors will be used at their maximum power. """ for m in self.motors: m.compliant = False m.moving_speed = 0 m.torque_limit = 100.0
[ "def", "power_up", "(", "self", ")", ":", "for", "m", "in", "self", ".", "motors", ":", "m", ".", "compliant", "=", "False", "m", ".", "moving_speed", "=", "0", "m", ".", "torque_limit", "=", "100.0" ]
Changes all settings to guarantee the motors will be used at their maximum power.
[ "Changes", "all", "settings", "to", "guarantee", "the", "motors", "will", "be", "used", "at", "their", "maximum", "power", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L143-L148
696
poppy-project/pypot
pypot/robot/robot.py
Robot.to_config
def to_config(self): """ Generates the config for the current robot. .. note:: The generated config should be used as a basis and must probably be modified. """ from ..dynamixel.controller import DxlController dxl_controllers = [c for c in self._controllers ...
python
def to_config(self): """ Generates the config for the current robot. .. note:: The generated config should be used as a basis and must probably be modified. """ from ..dynamixel.controller import DxlController dxl_controllers = [c for c in self._controllers ...
[ "def", "to_config", "(", "self", ")", ":", "from", ".", ".", "dynamixel", ".", "controller", "import", "DxlController", "dxl_controllers", "=", "[", "c", "for", "c", "in", "self", ".", "_controllers", "if", "isinstance", "(", "c", ",", "DxlController", ")"...
Generates the config for the current robot. .. note:: The generated config should be used as a basis and must probably be modified.
[ "Generates", "the", "config", "for", "the", "current", "robot", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/robot/robot.py#L150-L187
697
poppy-project/pypot
pypot/vrep/controller.py
VrepController.update
def update(self): """ Synchronization update loop. At each update all motor position are read from vrep and set to the motors. The motors target position are also send to v-rep. """ # Read all the angle limits h, _, l, _ = self.io.call_remote_api('simxGetObjectGroupData', ...
python
def update(self): """ Synchronization update loop. At each update all motor position are read from vrep and set to the motors. The motors target position are also send to v-rep. """ # Read all the angle limits h, _, l, _ = self.io.call_remote_api('simxGetObjectGroupData', ...
[ "def", "update", "(", "self", ")", ":", "# Read all the angle limits", "h", ",", "_", ",", "l", ",", "_", "=", "self", ".", "io", ".", "call_remote_api", "(", "'simxGetObjectGroupData'", ",", "remote_api", ".", "sim_object_joint_type", ",", "16", ",", "strea...
Synchronization update loop. At each update all motor position are read from vrep and set to the motors. The motors target position are also send to v-rep.
[ "Synchronization", "update", "loop", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/controller.py#L41-L82
698
poppy-project/pypot
pypot/vrep/controller.py
VrepObjectTracker.update
def update(self): """ Updates the position and orientation of the tracked objects. """ for s in self.sensors: s.position = self.io.get_object_position(object_name=s.name) s.orientation = self.io.get_object_orientation(object_name=s.name)
python
def update(self): """ Updates the position and orientation of the tracked objects. """ for s in self.sensors: s.position = self.io.get_object_position(object_name=s.name) s.orientation = self.io.get_object_orientation(object_name=s.name)
[ "def", "update", "(", "self", ")", ":", "for", "s", "in", "self", ".", "sensors", ":", "s", ".", "position", "=", "self", ".", "io", ".", "get_object_position", "(", "object_name", "=", "s", ".", "name", ")", "s", ".", "orientation", "=", "self", "...
Updates the position and orientation of the tracked objects.
[ "Updates", "the", "position", "and", "orientation", "of", "the", "tracked", "objects", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/controller.py#L149-L153
699
poppy-project/pypot
pypot/vrep/controller.py
VrepCollisionTracker.update
def update(self): """ Update the state of the collision detectors. """ for s in self.sensors: s.colliding = self.io.get_collision_state(collision_name=s.name)
python
def update(self): """ Update the state of the collision detectors. """ for s in self.sensors: s.colliding = self.io.get_collision_state(collision_name=s.name)
[ "def", "update", "(", "self", ")", ":", "for", "s", "in", "self", ".", "sensors", ":", "s", ".", "colliding", "=", "self", ".", "io", ".", "get_collision_state", "(", "collision_name", "=", "s", ".", "name", ")" ]
Update the state of the collision detectors.
[ "Update", "the", "state", "of", "the", "collision", "detectors", "." ]
d9c6551bbc87d45d9d1f0bc15e35b616d0002afd
https://github.com/poppy-project/pypot/blob/d9c6551bbc87d45d9d1f0bc15e35b616d0002afd/pypot/vrep/controller.py#L180-L184