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
partition
stringclasses
1 value
maartenbreddels/ipyvolume
ipyvolume/pylab.py
screenshot
def screenshot( width=None, height=None, format="png", fig=None, timeout_seconds=10, output_widget=None, headless=False, devmode=False, ): """Save the figure to a PIL.Image object. :param int width: the width of the image in pixels :param int height: the height of the image ...
python
def screenshot( width=None, height=None, format="png", fig=None, timeout_seconds=10, output_widget=None, headless=False, devmode=False, ): """Save the figure to a PIL.Image object. :param int width: the width of the image in pixels :param int height: the height of the image ...
[ "def", "screenshot", "(", "width", "=", "None", ",", "height", "=", "None", ",", "format", "=", "\"png\"", ",", "fig", "=", "None", ",", "timeout_seconds", "=", "10", ",", "output_widget", "=", "None", ",", "headless", "=", "False", ",", "devmode", "="...
Save the figure to a PIL.Image object. :param int width: the width of the image in pixels :param int height: the height of the image in pixels :param format: format of output data (png, jpeg or svg) :type fig: ipyvolume.widgets.Figure or None :param fig: if None use the current figure :type tim...
[ "Save", "the", "figure", "to", "a", "PIL", ".", "Image", "object", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1059-L1097
train
maartenbreddels/ipyvolume
ipyvolume/pylab.py
savefig
def savefig( filename, width=None, height=None, fig=None, timeout_seconds=10, output_widget=None, headless=False, devmode=False ): """Save the figure to an image file. :param str filename: must have extension .png, .jpeg or .svg :param int width: the width of the image in pixels :param int height: ...
python
def savefig( filename, width=None, height=None, fig=None, timeout_seconds=10, output_widget=None, headless=False, devmode=False ): """Save the figure to an image file. :param str filename: must have extension .png, .jpeg or .svg :param int width: the width of the image in pixels :param int height: ...
[ "def", "savefig", "(", "filename", ",", "width", "=", "None", ",", "height", "=", "None", ",", "fig", "=", "None", ",", "timeout_seconds", "=", "10", ",", "output_widget", "=", "None", ",", "headless", "=", "False", ",", "devmode", "=", "False", ")", ...
Save the figure to an image file. :param str filename: must have extension .png, .jpeg or .svg :param int width: the width of the image in pixels :param int height: the height of the image in pixels :type fig: ipyvolume.widgets.Figure or None :param fig: if None use the current figure :param fl...
[ "Save", "the", "figure", "to", "an", "image", "file", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1100-L1130
train
maartenbreddels/ipyvolume
ipyvolume/pylab.py
xyzlabel
def xyzlabel(labelx, labely, labelz): """Set all labels at once.""" xlabel(labelx) ylabel(labely) zlabel(labelz)
python
def xyzlabel(labelx, labely, labelz): """Set all labels at once.""" xlabel(labelx) ylabel(labely) zlabel(labelz)
[ "def", "xyzlabel", "(", "labelx", ",", "labely", ",", "labelz", ")", ":", "xlabel", "(", "labelx", ")", "ylabel", "(", "labely", ")", "zlabel", "(", "labelz", ")" ]
Set all labels at once.
[ "Set", "all", "labels", "at", "once", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1151-L1155
train
maartenbreddels/ipyvolume
ipyvolume/pylab.py
view
def view(azimuth=None, elevation=None, distance=None): """Set camera angles and distance and return the current. :param float azimuth: rotation around the axis pointing up in degrees :param float elevation: rotation where +90 means 'up', -90 means 'down', in degrees :param float distance: radial distan...
python
def view(azimuth=None, elevation=None, distance=None): """Set camera angles and distance and return the current. :param float azimuth: rotation around the axis pointing up in degrees :param float elevation: rotation where +90 means 'up', -90 means 'down', in degrees :param float distance: radial distan...
[ "def", "view", "(", "azimuth", "=", "None", ",", "elevation", "=", "None", ",", "distance", "=", "None", ")", ":", "fig", "=", "gcf", "(", ")", "# first calculate the current values", "x", ",", "y", ",", "z", "=", "fig", ".", "camera", ".", "position",...
Set camera angles and distance and return the current. :param float azimuth: rotation around the axis pointing up in degrees :param float elevation: rotation where +90 means 'up', -90 means 'down', in degrees :param float distance: radial distance from the center to the camera.
[ "Set", "camera", "angles", "and", "distance", "and", "return", "the", "current", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1158-L1182
train
maartenbreddels/ipyvolume
ipyvolume/pylab.py
plot_plane
def plot_plane(where="back", texture=None): """Plot a plane at a particular location in the viewbox. :param str where: 'back', 'front', 'left', 'right', 'top', 'bottom' :param texture: {texture} :return: :any:`Mesh` """ fig = gcf() xmin, xmax = fig.xlim ymin, ymax = fig.ylim zmin, z...
python
def plot_plane(where="back", texture=None): """Plot a plane at a particular location in the viewbox. :param str where: 'back', 'front', 'left', 'right', 'top', 'bottom' :param texture: {texture} :return: :any:`Mesh` """ fig = gcf() xmin, xmax = fig.xlim ymin, ymax = fig.ylim zmin, z...
[ "def", "plot_plane", "(", "where", "=", "\"back\"", ",", "texture", "=", "None", ")", ":", "fig", "=", "gcf", "(", ")", "xmin", ",", "xmax", "=", "fig", ".", "xlim", "ymin", ",", "ymax", "=", "fig", ".", "ylim", "zmin", ",", "zmax", "=", "fig", ...
Plot a plane at a particular location in the viewbox. :param str where: 'back', 'front', 'left', 'right', 'top', 'bottom' :param texture: {texture} :return: :any:`Mesh`
[ "Plot", "a", "plane", "at", "a", "particular", "location", "in", "the", "viewbox", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1306-L1347
train
maartenbreddels/ipyvolume
ipyvolume/pylab.py
_make_triangles_lines
def _make_triangles_lines(shape, wrapx=False, wrapy=False): """Transform rectangular regular grid into triangles. :param x: {x2d} :param y: {y2d} :param z: {z2d} :param bool wrapx: when True, the x direction is assumed to wrap, and polygons are drawn between the end end begin points :param bool...
python
def _make_triangles_lines(shape, wrapx=False, wrapy=False): """Transform rectangular regular grid into triangles. :param x: {x2d} :param y: {y2d} :param z: {z2d} :param bool wrapx: when True, the x direction is assumed to wrap, and polygons are drawn between the end end begin points :param bool...
[ "def", "_make_triangles_lines", "(", "shape", ",", "wrapx", "=", "False", ",", "wrapy", "=", "False", ")", ":", "nx", ",", "ny", "=", "shape", "mx", "=", "nx", "if", "wrapx", "else", "nx", "-", "1", "my", "=", "ny", "if", "wrapy", "else", "ny", "...
Transform rectangular regular grid into triangles. :param x: {x2d} :param y: {y2d} :param z: {z2d} :param bool wrapx: when True, the x direction is assumed to wrap, and polygons are drawn between the end end begin points :param bool wrapy: simular for the y coordinate :return: triangles and lin...
[ "Transform", "rectangular", "regular", "grid", "into", "triangles", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/pylab.py#L1443-L1513
train
maartenbreddels/ipyvolume
ipyvolume/embed.py
save_ipyvolumejs
def save_ipyvolumejs( target="", devmode=False, version=ipyvolume._version.__version_js__, version3js=__version_threejs__ ): """Output the ipyvolume javascript to a local file. :type target: str :param bool devmode: if True get index.js from js/dist directory :param str version: version number of i...
python
def save_ipyvolumejs( target="", devmode=False, version=ipyvolume._version.__version_js__, version3js=__version_threejs__ ): """Output the ipyvolume javascript to a local file. :type target: str :param bool devmode: if True get index.js from js/dist directory :param str version: version number of i...
[ "def", "save_ipyvolumejs", "(", "target", "=", "\"\"", ",", "devmode", "=", "False", ",", "version", "=", "ipyvolume", ".", "_version", ".", "__version_js__", ",", "version3js", "=", "__version_threejs__", ")", ":", "url", "=", "\"https://unpkg.com/ipyvolume@{vers...
Output the ipyvolume javascript to a local file. :type target: str :param bool devmode: if True get index.js from js/dist directory :param str version: version number of ipyvolume :param str version3js: version number of threejs
[ "Output", "the", "ipyvolume", "javascript", "to", "a", "local", "file", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/embed.py#L28-L60
train
maartenbreddels/ipyvolume
ipyvolume/embed.py
save_requirejs
def save_requirejs(target="", version="2.3.4"): """Download and save the require javascript to a local file. :type target: str :type version: str """ url = "https://cdnjs.cloudflare.com/ajax/libs/require.js/{version}/require.min.js".format(version=version) filename = "require.min.v{0}.js".forma...
python
def save_requirejs(target="", version="2.3.4"): """Download and save the require javascript to a local file. :type target: str :type version: str """ url = "https://cdnjs.cloudflare.com/ajax/libs/require.js/{version}/require.min.js".format(version=version) filename = "require.min.v{0}.js".forma...
[ "def", "save_requirejs", "(", "target", "=", "\"\"", ",", "version", "=", "\"2.3.4\"", ")", ":", "url", "=", "\"https://cdnjs.cloudflare.com/ajax/libs/require.js/{version}/require.min.js\"", ".", "format", "(", "version", "=", "version", ")", "filename", "=", "\"requi...
Download and save the require javascript to a local file. :type target: str :type version: str
[ "Download", "and", "save", "the", "require", "javascript", "to", "a", "local", "file", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/embed.py#L63-L73
train
maartenbreddels/ipyvolume
ipyvolume/embed.py
save_embed_js
def save_embed_js(target="", version=wembed.__html_manager_version__): """Download and save the ipywidgets embedding javascript to a local file. :type target: str :type version: str """ url = u'https://unpkg.com/@jupyter-widgets/html-manager@{0:s}/dist/embed-amd.js'.format(version) if version....
python
def save_embed_js(target="", version=wembed.__html_manager_version__): """Download and save the ipywidgets embedding javascript to a local file. :type target: str :type version: str """ url = u'https://unpkg.com/@jupyter-widgets/html-manager@{0:s}/dist/embed-amd.js'.format(version) if version....
[ "def", "save_embed_js", "(", "target", "=", "\"\"", ",", "version", "=", "wembed", ".", "__html_manager_version__", ")", ":", "url", "=", "u'https://unpkg.com/@jupyter-widgets/html-manager@{0:s}/dist/embed-amd.js'", ".", "format", "(", "version", ")", "if", "version", ...
Download and save the ipywidgets embedding javascript to a local file. :type target: str :type version: str
[ "Download", "and", "save", "the", "ipywidgets", "embedding", "javascript", "to", "a", "local", "file", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/embed.py#L76-L90
train
maartenbreddels/ipyvolume
ipyvolume/embed.py
save_font_awesome
def save_font_awesome(dirpath='', version="4.7.0"): """Download and save the font-awesome package to a local directory. :type dirpath: str :type url: str """ directory_name = "font-awesome-{0:s}".format(version) directory_path = os.path.join(dirpath, directory_name) if os.path.exists(direc...
python
def save_font_awesome(dirpath='', version="4.7.0"): """Download and save the font-awesome package to a local directory. :type dirpath: str :type url: str """ directory_name = "font-awesome-{0:s}".format(version) directory_path = os.path.join(dirpath, directory_name) if os.path.exists(direc...
[ "def", "save_font_awesome", "(", "dirpath", "=", "''", ",", "version", "=", "\"4.7.0\"", ")", ":", "directory_name", "=", "\"font-awesome-{0:s}\"", ".", "format", "(", "version", ")", "directory_path", "=", "os", ".", "path", ".", "join", "(", "dirpath", ","...
Download and save the font-awesome package to a local directory. :type dirpath: str :type url: str
[ "Download", "and", "save", "the", "font", "-", "awesome", "package", "to", "a", "local", "directory", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/embed.py#L94-L118
train
maartenbreddels/ipyvolume
ipyvolume/utils.py
download_to_bytes
def download_to_bytes(url, chunk_size=1024 * 1024 * 10, loadbar_length=10): """Download a url to bytes. if chunk_size is not None, prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :param url: str or url :param chunk_size: None or int in bytes :param loadbar...
python
def download_to_bytes(url, chunk_size=1024 * 1024 * 10, loadbar_length=10): """Download a url to bytes. if chunk_size is not None, prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :param url: str or url :param chunk_size: None or int in bytes :param loadbar...
[ "def", "download_to_bytes", "(", "url", ",", "chunk_size", "=", "1024", "*", "1024", "*", "10", ",", "loadbar_length", "=", "10", ")", ":", "stream", "=", "False", "if", "chunk_size", "is", "None", "else", "True", "print", "(", "\"Downloading {0:s}: \"", "...
Download a url to bytes. if chunk_size is not None, prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :param url: str or url :param chunk_size: None or int in bytes :param loadbar_length: int length of load bar :return: (bytes, encoding)
[ "Download", "a", "url", "to", "bytes", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/utils.py#L40-L95
train
maartenbreddels/ipyvolume
ipyvolume/utils.py
download_yield_bytes
def download_yield_bytes(url, chunk_size=1024 * 1024 * 10): """Yield a downloaded url as byte chunks. :param url: str or url :param chunk_size: None or int in bytes :yield: byte chunks """ response = requests.get(url, stream=True) # raise error if download was unsuccessful response.rais...
python
def download_yield_bytes(url, chunk_size=1024 * 1024 * 10): """Yield a downloaded url as byte chunks. :param url: str or url :param chunk_size: None or int in bytes :yield: byte chunks """ response = requests.get(url, stream=True) # raise error if download was unsuccessful response.rais...
[ "def", "download_yield_bytes", "(", "url", ",", "chunk_size", "=", "1024", "*", "1024", "*", "10", ")", ":", "response", "=", "requests", ".", "get", "(", "url", ",", "stream", "=", "True", ")", "# raise error if download was unsuccessful", "response", ".", ...
Yield a downloaded url as byte chunks. :param url: str or url :param chunk_size: None or int in bytes :yield: byte chunks
[ "Yield", "a", "downloaded", "url", "as", "byte", "chunks", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/utils.py#L98-L119
train
maartenbreddels/ipyvolume
ipyvolume/utils.py
download_to_file
def download_to_file(url, filepath, resume=False, overwrite=False, chunk_size=1024 * 1024 * 10, loadbar_length=10): """Download a url. prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :type url: str :type filepath: str :param filepath: path to download to ...
python
def download_to_file(url, filepath, resume=False, overwrite=False, chunk_size=1024 * 1024 * 10, loadbar_length=10): """Download a url. prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :type url: str :type filepath: str :param filepath: path to download to ...
[ "def", "download_to_file", "(", "url", ",", "filepath", ",", "resume", "=", "False", ",", "overwrite", "=", "False", ",", "chunk_size", "=", "1024", "*", "1024", "*", "10", ",", "loadbar_length", "=", "10", ")", ":", "resume_header", "=", "None", "loaded...
Download a url. prints a simple loading bar [=*loadbar_length] to show progress (in console and notebook) :type url: str :type filepath: str :param filepath: path to download to :param resume: if True resume download from existing file chunk :param overwrite: if True remove any existing filepa...
[ "Download", "a", "url", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/utils.py#L122-L193
train
maartenbreddels/ipyvolume
ipyvolume/astro.py
_randomSO3
def _randomSO3(): """Return random rotatation matrix, algo by James Arvo.""" u1 = np.random.random() u2 = np.random.random() u3 = np.random.random() R = np.array( [ [np.cos(2 * np.pi * u1), np.sin(2 * np.pi * u1), 0], [-np.sin(2 * np.pi * u1), np.cos(2 * np.pi * u1), ...
python
def _randomSO3(): """Return random rotatation matrix, algo by James Arvo.""" u1 = np.random.random() u2 = np.random.random() u3 = np.random.random() R = np.array( [ [np.cos(2 * np.pi * u1), np.sin(2 * np.pi * u1), 0], [-np.sin(2 * np.pi * u1), np.cos(2 * np.pi * u1), ...
[ "def", "_randomSO3", "(", ")", ":", "u1", "=", "np", ".", "random", ".", "random", "(", ")", "u2", "=", "np", ".", "random", ".", "random", "(", ")", "u3", "=", "np", ".", "random", ".", "random", "(", ")", "R", "=", "np", ".", "array", "(", ...
Return random rotatation matrix, algo by James Arvo.
[ "Return", "random", "rotatation", "matrix", "algo", "by", "James", "Arvo", "." ]
e68b72852b61276f8e6793bc8811f5b2432a155f
https://github.com/maartenbreddels/ipyvolume/blob/e68b72852b61276f8e6793bc8811f5b2432a155f/ipyvolume/astro.py#L11-L25
train
jaegertracing/jaeger-client-python
jaeger_client/throttler.py
RemoteThrottler._set_client_id
def _set_client_id(self, client_id): """ Method for tracer to set client ID of throttler. """ with self.lock: if self.client_id is None: self.client_id = client_id
python
def _set_client_id(self, client_id): """ Method for tracer to set client ID of throttler. """ with self.lock: if self.client_id is None: self.client_id = client_id
[ "def", "_set_client_id", "(", "self", ",", "client_id", ")", ":", "with", "self", ".", "lock", ":", "if", "self", ".", "client_id", "is", "None", ":", "self", ".", "client_id", "=", "client_id" ]
Method for tracer to set client ID of throttler.
[ "Method", "for", "tracer", "to", "set", "client", "ID", "of", "throttler", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/throttler.py#L81-L87
train
jaegertracing/jaeger-client-python
jaeger_client/throttler.py
RemoteThrottler._init_polling
def _init_polling(self): """ Bootstrap polling for throttler. To avoid spiky traffic from throttler clients, we use a random delay before the first poll. """ with self.lock: if not self.running: return r = random.Random() ...
python
def _init_polling(self): """ Bootstrap polling for throttler. To avoid spiky traffic from throttler clients, we use a random delay before the first poll. """ with self.lock: if not self.running: return r = random.Random() ...
[ "def", "_init_polling", "(", "self", ")", ":", "with", "self", ".", "lock", ":", "if", "not", "self", ".", "running", ":", "return", "r", "=", "random", ".", "Random", "(", ")", "delay", "=", "r", ".", "random", "(", ")", "*", "self", ".", "refre...
Bootstrap polling for throttler. To avoid spiky traffic from throttler clients, we use a random delay before the first poll.
[ "Bootstrap", "polling", "for", "throttler", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/throttler.py#L89-L105
train
jaegertracing/jaeger-client-python
jaeger_client/reporter.py
Reporter.close
def close(self): """ Ensure that all spans from the queue are submitted. Returns Future that will be completed once the queue is empty. """ with self.stop_lock: self.stopped = True return ioloop_util.submit(self._flush, io_loop=self.io_loop)
python
def close(self): """ Ensure that all spans from the queue are submitted. Returns Future that will be completed once the queue is empty. """ with self.stop_lock: self.stopped = True return ioloop_util.submit(self._flush, io_loop=self.io_loop)
[ "def", "close", "(", "self", ")", ":", "with", "self", ".", "stop_lock", ":", "self", ".", "stopped", "=", "True", "return", "ioloop_util", ".", "submit", "(", "self", ".", "_flush", ",", "io_loop", "=", "self", ".", "io_loop", ")" ]
Ensure that all spans from the queue are submitted. Returns Future that will be completed once the queue is empty.
[ "Ensure", "that", "all", "spans", "from", "the", "queue", "are", "submitted", ".", "Returns", "Future", "that", "will", "be", "completed", "once", "the", "queue", "is", "empty", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/reporter.py#L218-L226
train
jaegertracing/jaeger-client-python
jaeger_client/span.py
Span.finish
def finish(self, finish_time=None): """Indicate that the work represented by this span has been completed or terminated, and is ready to be sent to the Reporter. If any tags / logs need to be added to the span, it should be done before calling finish(), otherwise they may be ignored. ...
python
def finish(self, finish_time=None): """Indicate that the work represented by this span has been completed or terminated, and is ready to be sent to the Reporter. If any tags / logs need to be added to the span, it should be done before calling finish(), otherwise they may be ignored. ...
[ "def", "finish", "(", "self", ",", "finish_time", "=", "None", ")", ":", "if", "not", "self", ".", "is_sampled", "(", ")", ":", "return", "self", ".", "end_time", "=", "finish_time", "or", "time", ".", "time", "(", ")", "# no locking", "self", ".", "...
Indicate that the work represented by this span has been completed or terminated, and is ready to be sent to the Reporter. If any tags / logs need to be added to the span, it should be done before calling finish(), otherwise they may be ignored. :param finish_time: an explicit Span fin...
[ "Indicate", "that", "the", "work", "represented", "by", "this", "span", "has", "been", "completed", "or", "terminated", "and", "is", "ready", "to", "be", "sent", "to", "the", "Reporter", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/span.py#L60-L74
train
jaegertracing/jaeger-client-python
jaeger_client/span.py
Span._set_sampling_priority
def _set_sampling_priority(self, value): """ N.B. Caller must be holding update_lock. """ # Ignore debug spans trying to re-enable debug. if self.is_debug() and value: return False try: value_num = int(value) except ValueError: ...
python
def _set_sampling_priority(self, value): """ N.B. Caller must be holding update_lock. """ # Ignore debug spans trying to re-enable debug. if self.is_debug() and value: return False try: value_num = int(value) except ValueError: ...
[ "def", "_set_sampling_priority", "(", "self", ",", "value", ")", ":", "# Ignore debug spans trying to re-enable debug.", "if", "self", ".", "is_debug", "(", ")", "and", "value", ":", "return", "False", "try", ":", "value_num", "=", "int", "(", "value", ")", "e...
N.B. Caller must be holding update_lock.
[ "N", ".", "B", ".", "Caller", "must", "be", "holding", "update_lock", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/span.py#L92-L111
train
jaegertracing/jaeger-client-python
jaeger_client/TUDPTransport.py
TUDPTransport.write
def write(self, buf): """Raw write to the UDP socket.""" return self.transport_sock.sendto( buf, (self.transport_host, self.transport_port) )
python
def write(self, buf): """Raw write to the UDP socket.""" return self.transport_sock.sendto( buf, (self.transport_host, self.transport_port) )
[ "def", "write", "(", "self", ",", "buf", ")", ":", "return", "self", ".", "transport_sock", ".", "sendto", "(", "buf", ",", "(", "self", ".", "transport_host", ",", "self", ".", "transport_port", ")", ")" ]
Raw write to the UDP socket.
[ "Raw", "write", "to", "the", "UDP", "socket", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/TUDPTransport.py#L39-L44
train
jaegertracing/jaeger-client-python
jaeger_client/config.py
Config.initialize_tracer
def initialize_tracer(self, io_loop=None): """ Initialize Jaeger Tracer based on the passed `jaeger_client.Config`. Save it to `opentracing.tracer` global variable. Only the first call to this method has any effect. """ with Config._initialized_lock: if Confi...
python
def initialize_tracer(self, io_loop=None): """ Initialize Jaeger Tracer based on the passed `jaeger_client.Config`. Save it to `opentracing.tracer` global variable. Only the first call to this method has any effect. """ with Config._initialized_lock: if Confi...
[ "def", "initialize_tracer", "(", "self", ",", "io_loop", "=", "None", ")", ":", "with", "Config", ".", "_initialized_lock", ":", "if", "Config", ".", "_initialized", ":", "logger", ".", "warn", "(", "'Jaeger tracer already initialized, skipping'", ")", "return", ...
Initialize Jaeger Tracer based on the passed `jaeger_client.Config`. Save it to `opentracing.tracer` global variable. Only the first call to this method has any effect.
[ "Initialize", "Jaeger", "Tracer", "based", "on", "the", "passed", "jaeger_client", ".", "Config", ".", "Save", "it", "to", "opentracing", ".", "tracer", "global", "variable", ".", "Only", "the", "first", "call", "to", "this", "method", "has", "any", "effect"...
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/config.py#L340-L356
train
jaegertracing/jaeger-client-python
jaeger_client/config.py
Config.new_tracer
def new_tracer(self, io_loop=None): """ Create a new Jaeger Tracer based on the passed `jaeger_client.Config`. Does not set `opentracing.tracer` global variable. """ channel = self._create_local_agent_channel(io_loop=io_loop) sampler = self.sampler if not sampler:...
python
def new_tracer(self, io_loop=None): """ Create a new Jaeger Tracer based on the passed `jaeger_client.Config`. Does not set `opentracing.tracer` global variable. """ channel = self._create_local_agent_channel(io_loop=io_loop) sampler = self.sampler if not sampler:...
[ "def", "new_tracer", "(", "self", ",", "io_loop", "=", "None", ")", ":", "channel", "=", "self", ".", "_create_local_agent_channel", "(", "io_loop", "=", "io_loop", ")", "sampler", "=", "self", ".", "sampler", "if", "not", "sampler", ":", "sampler", "=", ...
Create a new Jaeger Tracer based on the passed `jaeger_client.Config`. Does not set `opentracing.tracer` global variable.
[ "Create", "a", "new", "Jaeger", "Tracer", "based", "on", "the", "passed", "jaeger_client", ".", "Config", ".", "Does", "not", "set", "opentracing", ".", "tracer", "global", "variable", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/config.py#L358-L403
train
jaegertracing/jaeger-client-python
jaeger_client/config.py
Config._create_local_agent_channel
def _create_local_agent_channel(self, io_loop): """ Create an out-of-process channel communicating to local jaeger-agent. Spans are submitted as SOCK_DGRAM Thrift, sampling strategy is polled via JSON HTTP. :param self: instance of Config """ logger.info('Initial...
python
def _create_local_agent_channel(self, io_loop): """ Create an out-of-process channel communicating to local jaeger-agent. Spans are submitted as SOCK_DGRAM Thrift, sampling strategy is polled via JSON HTTP. :param self: instance of Config """ logger.info('Initial...
[ "def", "_create_local_agent_channel", "(", "self", ",", "io_loop", ")", ":", "logger", ".", "info", "(", "'Initializing Jaeger Tracer with UDP reporter'", ")", "return", "LocalAgentSender", "(", "host", "=", "self", ".", "local_agent_reporting_host", ",", "sampling_port...
Create an out-of-process channel communicating to local jaeger-agent. Spans are submitted as SOCK_DGRAM Thrift, sampling strategy is polled via JSON HTTP. :param self: instance of Config
[ "Create", "an", "out", "-", "of", "-", "process", "channel", "communicating", "to", "local", "jaeger", "-", "agent", ".", "Spans", "are", "submitted", "as", "SOCK_DGRAM", "Thrift", "sampling", "strategy", "is", "polled", "via", "JSON", "HTTP", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/config.py#L427-L442
train
jaegertracing/jaeger-client-python
jaeger_client/codecs.py
span_context_from_string
def span_context_from_string(value): """ Decode span ID from a string into a TraceContext. Returns None if the string value is malformed. :param value: formatted {trace_id}:{span_id}:{parent_id}:{flags} """ if type(value) is list and len(value) > 0: # sometimes headers are presented as ...
python
def span_context_from_string(value): """ Decode span ID from a string into a TraceContext. Returns None if the string value is malformed. :param value: formatted {trace_id}:{span_id}:{parent_id}:{flags} """ if type(value) is list and len(value) > 0: # sometimes headers are presented as ...
[ "def", "span_context_from_string", "(", "value", ")", ":", "if", "type", "(", "value", ")", "is", "list", "and", "len", "(", "value", ")", ">", "0", ":", "# sometimes headers are presented as arrays of values", "if", "len", "(", "value", ")", ">", "1", ":", ...
Decode span ID from a string into a TraceContext. Returns None if the string value is malformed. :param value: formatted {trace_id}:{span_id}:{parent_id}:{flags}
[ "Decode", "span", "ID", "from", "a", "string", "into", "a", "TraceContext", ".", "Returns", "None", "if", "the", "string", "value", "is", "malformed", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/codecs.py#L173-L206
train
jaegertracing/jaeger-client-python
jaeger_client/thrift.py
parse_sampling_strategy
def parse_sampling_strategy(response): """ Parse SamplingStrategyResponse and converts to a Sampler. :param response: :return: Returns Go-style (value, error) pair """ s_type = response.strategyType if s_type == sampling_manager.SamplingStrategyType.PROBABILISTIC: if response.probab...
python
def parse_sampling_strategy(response): """ Parse SamplingStrategyResponse and converts to a Sampler. :param response: :return: Returns Go-style (value, error) pair """ s_type = response.strategyType if s_type == sampling_manager.SamplingStrategyType.PROBABILISTIC: if response.probab...
[ "def", "parse_sampling_strategy", "(", "response", ")", ":", "s_type", "=", "response", ".", "strategyType", "if", "s_type", "==", "sampling_manager", ".", "SamplingStrategyType", ".", "PROBABILISTIC", ":", "if", "response", ".", "probabilisticSampling", "is", "None...
Parse SamplingStrategyResponse and converts to a Sampler. :param response: :return: Returns Go-style (value, error) pair
[ "Parse", "SamplingStrategyResponse", "and", "converts", "to", "a", "Sampler", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/thrift.py#L208-L239
train
jaegertracing/jaeger-client-python
jaeger_client/span_context.py
SpanContext.with_debug_id
def with_debug_id(debug_id): """Deprecated, not used by Jaeger.""" ctx = SpanContext( trace_id=None, span_id=None, parent_id=None, flags=None ) ctx._debug_id = debug_id return ctx
python
def with_debug_id(debug_id): """Deprecated, not used by Jaeger.""" ctx = SpanContext( trace_id=None, span_id=None, parent_id=None, flags=None ) ctx._debug_id = debug_id return ctx
[ "def", "with_debug_id", "(", "debug_id", ")", ":", "ctx", "=", "SpanContext", "(", "trace_id", "=", "None", ",", "span_id", "=", "None", ",", "parent_id", "=", "None", ",", "flags", "=", "None", ")", "ctx", ".", "_debug_id", "=", "debug_id", "return", ...
Deprecated, not used by Jaeger.
[ "Deprecated", "not", "used", "by", "Jaeger", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/span_context.py#L65-L71
train
jaegertracing/jaeger-client-python
jaeger_client/tracer.py
Tracer.start_span
def start_span(self, operation_name=None, child_of=None, references=None, tags=None, start_time=None, ignore_active_span=False, ): """ Start and return a new Span represen...
python
def start_span(self, operation_name=None, child_of=None, references=None, tags=None, start_time=None, ignore_active_span=False, ): """ Start and return a new Span represen...
[ "def", "start_span", "(", "self", ",", "operation_name", "=", "None", ",", "child_of", "=", "None", ",", "references", "=", "None", ",", "tags", "=", "None", ",", "start_time", "=", "None", ",", "ignore_active_span", "=", "False", ",", ")", ":", "parent"...
Start and return a new Span representing a unit of work. :param operation_name: name of the operation represented by the new span from the perspective of the current service. :param child_of: shortcut for 'child_of' reference :param references: (optional) either a single Reference o...
[ "Start", "and", "return", "a", "new", "Span", "representing", "a", "unit", "of", "work", "." ]
06face094757c645a6d81f0e073c001931a22a05
https://github.com/jaegertracing/jaeger-client-python/blob/06face094757c645a6d81f0e073c001931a22a05/jaeger_client/tracer.py#L118-L213
train
RedHatInsights/insights-core
insights/combiners/lvm.py
merge_lvm_data
def merge_lvm_data(primary, secondary, name_key): """ Returns a dictionary containing the set of data from primary and secondary where values in primary will always be returned if present, and values in secondary will only be returned if not present in primary, or if the value in primary is `None`. ...
python
def merge_lvm_data(primary, secondary, name_key): """ Returns a dictionary containing the set of data from primary and secondary where values in primary will always be returned if present, and values in secondary will only be returned if not present in primary, or if the value in primary is `None`. ...
[ "def", "merge_lvm_data", "(", "primary", ",", "secondary", ",", "name_key", ")", ":", "pri_data", "=", "to_name_key_dict", "(", "primary", ",", "name_key", ")", "# Prime results with secondary data, to be updated with primary data", "combined_data", "=", "to_name_key_dict",...
Returns a dictionary containing the set of data from primary and secondary where values in primary will always be returned if present, and values in secondary will only be returned if not present in primary, or if the value in primary is `None`. Sample input Data:: primary = [ {'a'...
[ "Returns", "a", "dictionary", "containing", "the", "set", "of", "data", "from", "primary", "and", "secondary", "where", "values", "in", "primary", "will", "always", "be", "returned", "if", "present", "and", "values", "in", "secondary", "will", "only", "be", ...
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/combiners/lvm.py#L112-L157
train
RedHatInsights/insights-core
insights/client/insights_spec.py
InsightsFile.get_output
def get_output(self): ''' Get file content, selecting only lines we are interested in ''' if not os.path.isfile(self.real_path): logger.debug('File %s does not exist', self.real_path) return cmd = [] cmd.append('sed') cmd.append('-rf') ...
python
def get_output(self): ''' Get file content, selecting only lines we are interested in ''' if not os.path.isfile(self.real_path): logger.debug('File %s does not exist', self.real_path) return cmd = [] cmd.append('sed') cmd.append('-rf') ...
[ "def", "get_output", "(", "self", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "self", ".", "real_path", ")", ":", "logger", ".", "debug", "(", "'File %s does not exist'", ",", "self", ".", "real_path", ")", "return", "cmd", "=", "[", ...
Get file content, selecting only lines we are interested in
[ "Get", "file", "content", "selecting", "only", "lines", "we", "are", "interested", "in" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/insights_spec.py#L147-L196
train
RedHatInsights/insights-core
insights/parsers/openvswitch_logs.py
OpenVSwitchLog._parse_line
def _parse_line(self, line): """ Parse line into fields. """ fields = line.split('|', 4) # stop splitting after fourth | found line_info = {'raw_message': line} if len(fields) == 5: line_info.update(dict(zip(self._fieldnames, fields))) return line_inf...
python
def _parse_line(self, line): """ Parse line into fields. """ fields = line.split('|', 4) # stop splitting after fourth | found line_info = {'raw_message': line} if len(fields) == 5: line_info.update(dict(zip(self._fieldnames, fields))) return line_inf...
[ "def", "_parse_line", "(", "self", ",", "line", ")", ":", "fields", "=", "line", ".", "split", "(", "'|'", ",", "4", ")", "# stop splitting after fourth | found", "line_info", "=", "{", "'raw_message'", ":", "line", "}", "if", "len", "(", "fields", ")", ...
Parse line into fields.
[ "Parse", "line", "into", "fields", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/openvswitch_logs.py#L52-L60
train
RedHatInsights/insights-core
insights/core/dr.py
_import_component
def _import_component(name): """ Returns a class, function, or class method specified by the fully qualified name. """ for f in (_get_from_module, _get_from_class): try: return f(name) except: pass log.debug("Couldn't load %s" % name)
python
def _import_component(name): """ Returns a class, function, or class method specified by the fully qualified name. """ for f in (_get_from_module, _get_from_class): try: return f(name) except: pass log.debug("Couldn't load %s" % name)
[ "def", "_import_component", "(", "name", ")", ":", "for", "f", "in", "(", "_get_from_module", ",", "_get_from_class", ")", ":", "try", ":", "return", "f", "(", "name", ")", "except", ":", "pass", "log", ".", "debug", "(", "\"Couldn't load %s\"", "%", "na...
Returns a class, function, or class method specified by the fully qualified name.
[ "Returns", "a", "class", "function", "or", "class", "method", "specified", "by", "the", "fully", "qualified", "name", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L151-L161
train
RedHatInsights/insights-core
insights/core/dr.py
get_name
def get_name(component): """ Attempt to get the string name of component, including module and class if applicable. """ if six.callable(component): name = getattr(component, "__qualname__", component.__name__) return '.'.join([component.__module__, name]) return str(component)
python
def get_name(component): """ Attempt to get the string name of component, including module and class if applicable. """ if six.callable(component): name = getattr(component, "__qualname__", component.__name__) return '.'.join([component.__module__, name]) return str(component)
[ "def", "get_name", "(", "component", ")", ":", "if", "six", ".", "callable", "(", "component", ")", ":", "name", "=", "getattr", "(", "component", ",", "\"__qualname__\"", ",", "component", ".", "__name__", ")", "return", "'.'", ".", "join", "(", "[", ...
Attempt to get the string name of component, including module and class if applicable.
[ "Attempt", "to", "get", "the", "string", "name", "of", "component", "including", "module", "and", "class", "if", "applicable", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L237-L245
train
RedHatInsights/insights-core
insights/core/dr.py
walk_dependencies
def walk_dependencies(root, visitor): """ Call visitor on root and all dependencies reachable from it in breadth first order. Args: root (component): component function or class visitor (function): signature is `func(component, parent)`. The call on root is `visitor(root, N...
python
def walk_dependencies(root, visitor): """ Call visitor on root and all dependencies reachable from it in breadth first order. Args: root (component): component function or class visitor (function): signature is `func(component, parent)`. The call on root is `visitor(root, N...
[ "def", "walk_dependencies", "(", "root", ",", "visitor", ")", ":", "def", "visit", "(", "parent", ",", "visitor", ")", ":", "for", "d", "in", "get_dependencies", "(", "parent", ")", ":", "visitor", "(", "d", ",", "parent", ")", "visit", "(", "d", ","...
Call visitor on root and all dependencies reachable from it in breadth first order. Args: root (component): component function or class visitor (function): signature is `func(component, parent)`. The call on root is `visitor(root, None)`.
[ "Call", "visitor", "on", "root", "and", "all", "dependencies", "reachable", "from", "it", "in", "breadth", "first", "order", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L303-L319
train
RedHatInsights/insights-core
insights/core/dr.py
get_subgraphs
def get_subgraphs(graph=None): """ Given a graph of possibly disconnected components, generate all graphs of connected components. graph is a dictionary of dependencies. Keys are components, and values are sets of components on which they depend. """ graph = graph or DEPENDENCIES keys = set(...
python
def get_subgraphs(graph=None): """ Given a graph of possibly disconnected components, generate all graphs of connected components. graph is a dictionary of dependencies. Keys are components, and values are sets of components on which they depend. """ graph = graph or DEPENDENCIES keys = set(...
[ "def", "get_subgraphs", "(", "graph", "=", "None", ")", ":", "graph", "=", "graph", "or", "DEPENDENCIES", "keys", "=", "set", "(", "graph", ")", "frontier", "=", "set", "(", ")", "seen", "=", "set", "(", ")", "while", "keys", ":", "frontier", ".", ...
Given a graph of possibly disconnected components, generate all graphs of connected components. graph is a dictionary of dependencies. Keys are components, and values are sets of components on which they depend.
[ "Given", "a", "graph", "of", "possibly", "disconnected", "components", "generate", "all", "graphs", "of", "connected", "components", ".", "graph", "is", "a", "dictionary", "of", "dependencies", ".", "Keys", "are", "components", "and", "values", "are", "sets", ...
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L352-L372
train
RedHatInsights/insights-core
insights/core/dr.py
load_components
def load_components(*paths, **kwargs): """ Loads all components on the paths. Each path should be a package or module. All components beneath a path are loaded. Args: paths (str): A package or module to load Keyword Args: include (str): A regular expression of packages and modules ...
python
def load_components(*paths, **kwargs): """ Loads all components on the paths. Each path should be a package or module. All components beneath a path are loaded. Args: paths (str): A package or module to load Keyword Args: include (str): A regular expression of packages and modules ...
[ "def", "load_components", "(", "*", "paths", ",", "*", "*", "kwargs", ")", ":", "num_loaded", "=", "0", "for", "path", "in", "paths", ":", "num_loaded", "+=", "_load_components", "(", "path", ",", "*", "*", "kwargs", ")", "return", "num_loaded" ]
Loads all components on the paths. Each path should be a package or module. All components beneath a path are loaded. Args: paths (str): A package or module to load Keyword Args: include (str): A regular expression of packages and modules to include. Defaults to '.*' ex...
[ "Loads", "all", "components", "on", "the", "paths", ".", "Each", "path", "should", "be", "a", "package", "or", "module", ".", "All", "components", "beneath", "a", "path", "are", "loaded", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L418-L443
train
RedHatInsights/insights-core
insights/core/dr.py
run
def run(components=None, broker=None): """ Executes components in an order that satisfies their dependency relationships. Keyword Args: components: Can be one of a dependency graph, a single component, a component group, or a component type. If it's anything other than a ...
python
def run(components=None, broker=None): """ Executes components in an order that satisfies their dependency relationships. Keyword Args: components: Can be one of a dependency graph, a single component, a component group, or a component type. If it's anything other than a ...
[ "def", "run", "(", "components", "=", "None", ",", "broker", "=", "None", ")", ":", "components", "=", "components", "or", "COMPONENTS", "[", "GROUPS", ".", "single", "]", "components", "=", "_determine_components", "(", "components", ")", "broker", "=", "...
Executes components in an order that satisfies their dependency relationships. Keyword Args: components: Can be one of a dependency graph, a single component, a component group, or a component type. If it's anything other than a dependency graph, the appropriate graph is built f...
[ "Executes", "components", "in", "an", "order", "that", "satisfies", "their", "dependency", "relationships", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L927-L970
train
RedHatInsights/insights-core
insights/core/dr.py
run_incremental
def run_incremental(components=None, broker=None): """ Executes components in an order that satisfies their dependency relationships. Disjoint subgraphs are executed one at a time and a broker containing the results for each is yielded. If a broker is passed here, its instances are used to seed the ...
python
def run_incremental(components=None, broker=None): """ Executes components in an order that satisfies their dependency relationships. Disjoint subgraphs are executed one at a time and a broker containing the results for each is yielded. If a broker is passed here, its instances are used to seed the ...
[ "def", "run_incremental", "(", "components", "=", "None", ",", "broker", "=", "None", ")", ":", "for", "graph", ",", "_broker", "in", "generate_incremental", "(", "components", ",", "broker", ")", ":", "yield", "run", "(", "graph", ",", "broker", "=", "_...
Executes components in an order that satisfies their dependency relationships. Disjoint subgraphs are executed one at a time and a broker containing the results for each is yielded. If a broker is passed here, its instances are used to seed the broker used to hold state for each sub graph. Keyword ...
[ "Executes", "components", "in", "an", "order", "that", "satisfies", "their", "dependency", "relationships", ".", "Disjoint", "subgraphs", "are", "executed", "one", "at", "a", "time", "and", "a", "broker", "containing", "the", "results", "for", "each", "is", "y...
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L982-L1002
train
RedHatInsights/insights-core
insights/core/dr.py
ComponentType.invoke
def invoke(self, results): """ Handles invocation of the component. The default implementation invokes it with positional arguments based on order of dependency declaration. """ args = [results.get(d) for d in self.deps] return self.component(*args)
python
def invoke(self, results): """ Handles invocation of the component. The default implementation invokes it with positional arguments based on order of dependency declaration. """ args = [results.get(d) for d in self.deps] return self.component(*args)
[ "def", "invoke", "(", "self", ",", "results", ")", ":", "args", "=", "[", "results", ".", "get", "(", "d", ")", "for", "d", "in", "self", ".", "deps", "]", "return", "self", ".", "component", "(", "*", "args", ")" ]
Handles invocation of the component. The default implementation invokes it with positional arguments based on order of dependency declaration.
[ "Handles", "invocation", "of", "the", "component", ".", "The", "default", "implementation", "invokes", "it", "with", "positional", "arguments", "based", "on", "order", "of", "dependency", "declaration", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L647-L653
train
RedHatInsights/insights-core
insights/core/dr.py
ComponentType.get_missing_dependencies
def get_missing_dependencies(self, broker): """ Gets required and at-least-one dependencies not provided by the broker. """ missing_required = [r for r in self.requires if r not in broker] missing_at_least_one = [d for d in self.at_least_one if not set(d).intersection(broker)] ...
python
def get_missing_dependencies(self, broker): """ Gets required and at-least-one dependencies not provided by the broker. """ missing_required = [r for r in self.requires if r not in broker] missing_at_least_one = [d for d in self.at_least_one if not set(d).intersection(broker)] ...
[ "def", "get_missing_dependencies", "(", "self", ",", "broker", ")", ":", "missing_required", "=", "[", "r", "for", "r", "in", "self", ".", "requires", "if", "r", "not", "in", "broker", "]", "missing_at_least_one", "=", "[", "d", "for", "d", "in", "self",...
Gets required and at-least-one dependencies not provided by the broker.
[ "Gets", "required", "and", "at", "-", "least", "-", "one", "dependencies", "not", "provided", "by", "the", "broker", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L655-L662
train
RedHatInsights/insights-core
insights/core/dr.py
Broker.observer
def observer(self, component_type=ComponentType): """ You can use ``@broker.observer()`` as a decorator to your callback instead of :func:`Broker.add_observer`. """ def inner(func): self.add_observer(func, component_type) return func return inner
python
def observer(self, component_type=ComponentType): """ You can use ``@broker.observer()`` as a decorator to your callback instead of :func:`Broker.add_observer`. """ def inner(func): self.add_observer(func, component_type) return func return inner
[ "def", "observer", "(", "self", ",", "component_type", "=", "ComponentType", ")", ":", "def", "inner", "(", "func", ")", ":", "self", ".", "add_observer", "(", "func", ",", "component_type", ")", "return", "func", "return", "inner" ]
You can use ``@broker.observer()`` as a decorator to your callback instead of :func:`Broker.add_observer`.
[ "You", "can", "use" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L735-L743
train
RedHatInsights/insights-core
insights/core/dr.py
Broker.add_observer
def add_observer(self, o, component_type=ComponentType): """ Add a callback that will get invoked after each component is called. Args: o (func): the callback function Keyword Args: component_type (ComponentType): the :class:`ComponentType` to observe. ...
python
def add_observer(self, o, component_type=ComponentType): """ Add a callback that will get invoked after each component is called. Args: o (func): the callback function Keyword Args: component_type (ComponentType): the :class:`ComponentType` to observe. ...
[ "def", "add_observer", "(", "self", ",", "o", ",", "component_type", "=", "ComponentType", ")", ":", "self", ".", "observers", "[", "component_type", "]", ".", "add", "(", "o", ")" ]
Add a callback that will get invoked after each component is called. Args: o (func): the callback function Keyword Args: component_type (ComponentType): the :class:`ComponentType` to observe. The callback will fire any time an instance of the class or its ...
[ "Add", "a", "callback", "that", "will", "get", "invoked", "after", "each", "component", "is", "called", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/dr.py#L745-L767
train
RedHatInsights/insights-core
insights/combiners/logrotate_conf.py
get_tree
def get_tree(root=None): """ This is a helper function to get a logrotate configuration component for your local machine or an archive. It's for use in interactive sessions. """ from insights import run return run(LogRotateConfTree, root=root).get(LogRotateConfTree)
python
def get_tree(root=None): """ This is a helper function to get a logrotate configuration component for your local machine or an archive. It's for use in interactive sessions. """ from insights import run return run(LogRotateConfTree, root=root).get(LogRotateConfTree)
[ "def", "get_tree", "(", "root", "=", "None", ")", ":", "from", "insights", "import", "run", "return", "run", "(", "LogRotateConfTree", ",", "root", "=", "root", ")", ".", "get", "(", "LogRotateConfTree", ")" ]
This is a helper function to get a logrotate configuration component for your local machine or an archive. It's for use in interactive sessions.
[ "This", "is", "a", "helper", "function", "to", "get", "a", "logrotate", "configuration", "component", "for", "your", "local", "machine", "or", "an", "archive", ".", "It", "s", "for", "use", "in", "interactive", "sessions", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/combiners/logrotate_conf.py#L231-L237
train
RedHatInsights/insights-core
insights/formats/_syslog.py
SysLogFormat.logit
def logit(self, msg, pid, user, cname, priority=None): """Function for formatting content and logging to syslog""" if self.stream: print(msg, file=self.stream) elif priority == logging.WARNING: self.logger.warning("{0}[pid:{1}] user:{2}: WARNING - {3}".format(cname, pid,...
python
def logit(self, msg, pid, user, cname, priority=None): """Function for formatting content and logging to syslog""" if self.stream: print(msg, file=self.stream) elif priority == logging.WARNING: self.logger.warning("{0}[pid:{1}] user:{2}: WARNING - {3}".format(cname, pid,...
[ "def", "logit", "(", "self", ",", "msg", ",", "pid", ",", "user", ",", "cname", ",", "priority", "=", "None", ")", ":", "if", "self", ".", "stream", ":", "print", "(", "msg", ",", "file", "=", "self", ".", "stream", ")", "elif", "priority", "==",...
Function for formatting content and logging to syslog
[ "Function", "for", "formatting", "content", "and", "logging", "to", "syslog" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/formats/_syslog.py#L45-L55
train
RedHatInsights/insights-core
insights/formats/_syslog.py
SysLogFormat.log_exceptions
def log_exceptions(self, c, broker): """Gets exceptions to be logged and sends to logit function to be logged to syslog""" if c in broker.exceptions: ex = broker.exceptions.get(c) ex = "Exception in {0} - {1}".format(dr.get_name(c), str(ex)) self.logit(ex, self.pid, ...
python
def log_exceptions(self, c, broker): """Gets exceptions to be logged and sends to logit function to be logged to syslog""" if c in broker.exceptions: ex = broker.exceptions.get(c) ex = "Exception in {0} - {1}".format(dr.get_name(c), str(ex)) self.logit(ex, self.pid, ...
[ "def", "log_exceptions", "(", "self", ",", "c", ",", "broker", ")", ":", "if", "c", "in", "broker", ".", "exceptions", ":", "ex", "=", "broker", ".", "exceptions", ".", "get", "(", "c", ")", "ex", "=", "\"Exception in {0} - {1}\"", ".", "format", "(", ...
Gets exceptions to be logged and sends to logit function to be logged to syslog
[ "Gets", "exceptions", "to", "be", "logged", "and", "sends", "to", "logit", "function", "to", "be", "logged", "to", "syslog" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/formats/_syslog.py#L57-L63
train
RedHatInsights/insights-core
insights/formats/_syslog.py
SysLogFormat.log_rule_info
def log_rule_info(self): """Collects rule information and send to logit function to log to syslog""" for c in sorted(self.broker.get_by_type(rule), key=dr.get_name): v = self.broker[c] _type = v.get("type") if _type: if _type != "skip": ...
python
def log_rule_info(self): """Collects rule information and send to logit function to log to syslog""" for c in sorted(self.broker.get_by_type(rule), key=dr.get_name): v = self.broker[c] _type = v.get("type") if _type: if _type != "skip": ...
[ "def", "log_rule_info", "(", "self", ")", ":", "for", "c", "in", "sorted", "(", "self", ".", "broker", ".", "get_by_type", "(", "rule", ")", ",", "key", "=", "dr", ".", "get_name", ")", ":", "v", "=", "self", ".", "broker", "[", "c", "]", "_type"...
Collects rule information and send to logit function to log to syslog
[ "Collects", "rule", "information", "and", "send", "to", "logit", "function", "to", "log", "to", "syslog" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/formats/_syslog.py#L72-L84
train
RedHatInsights/insights-core
insights/client/data_collector.py
DataCollector._run_pre_command
def _run_pre_command(self, pre_cmd): ''' Run a pre command to get external args for a command ''' logger.debug('Executing pre-command: %s', pre_cmd) try: pre_proc = Popen(pre_cmd, stdout=PIPE, stderr=STDOUT, shell=True) except OSError as err: if er...
python
def _run_pre_command(self, pre_cmd): ''' Run a pre command to get external args for a command ''' logger.debug('Executing pre-command: %s', pre_cmd) try: pre_proc = Popen(pre_cmd, stdout=PIPE, stderr=STDOUT, shell=True) except OSError as err: if er...
[ "def", "_run_pre_command", "(", "self", ",", "pre_cmd", ")", ":", "logger", ".", "debug", "(", "'Executing pre-command: %s'", ",", "pre_cmd", ")", "try", ":", "pre_proc", "=", "Popen", "(", "pre_cmd", ",", "stdout", "=", "PIPE", ",", "stderr", "=", "STDOUT...
Run a pre command to get external args for a command
[ "Run", "a", "pre", "command", "to", "get", "external", "args", "for", "a", "command" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/data_collector.py#L51-L72
train
RedHatInsights/insights-core
insights/client/data_collector.py
DataCollector._parse_file_spec
def _parse_file_spec(self, spec): ''' Separate wildcard specs into more specs ''' # separate wildcard specs into more specs if '*' in spec['file']: expanded_paths = _expand_paths(spec['file']) if not expanded_paths: return [] ex...
python
def _parse_file_spec(self, spec): ''' Separate wildcard specs into more specs ''' # separate wildcard specs into more specs if '*' in spec['file']: expanded_paths = _expand_paths(spec['file']) if not expanded_paths: return [] ex...
[ "def", "_parse_file_spec", "(", "self", ",", "spec", ")", ":", "# separate wildcard specs into more specs", "if", "'*'", "in", "spec", "[", "'file'", "]", ":", "expanded_paths", "=", "_expand_paths", "(", "spec", "[", "'file'", "]", ")", "if", "not", "expanded...
Separate wildcard specs into more specs
[ "Separate", "wildcard", "specs", "into", "more", "specs" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/data_collector.py#L74-L91
train
RedHatInsights/insights-core
insights/client/data_collector.py
DataCollector._parse_glob_spec
def _parse_glob_spec(self, spec): ''' Grab globs of things ''' some_globs = glob.glob(spec['glob']) if not some_globs: return [] el_globs = [] for g in some_globs: _spec = copy.copy(spec) _spec['file'] = g el_globs.a...
python
def _parse_glob_spec(self, spec): ''' Grab globs of things ''' some_globs = glob.glob(spec['glob']) if not some_globs: return [] el_globs = [] for g in some_globs: _spec = copy.copy(spec) _spec['file'] = g el_globs.a...
[ "def", "_parse_glob_spec", "(", "self", ",", "spec", ")", ":", "some_globs", "=", "glob", ".", "glob", "(", "spec", "[", "'glob'", "]", ")", "if", "not", "some_globs", ":", "return", "[", "]", "el_globs", "=", "[", "]", "for", "g", "in", "some_globs"...
Grab globs of things
[ "Grab", "globs", "of", "things" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/data_collector.py#L93-L105
train
RedHatInsights/insights-core
insights/client/data_collector.py
DataCollector.run_collection
def run_collection(self, conf, rm_conf, branch_info): ''' Run specs and collect all the data ''' if rm_conf is None: rm_conf = {} logger.debug('Beginning to run collection spec...') exclude = None if rm_conf: try: exclude = ...
python
def run_collection(self, conf, rm_conf, branch_info): ''' Run specs and collect all the data ''' if rm_conf is None: rm_conf = {} logger.debug('Beginning to run collection spec...') exclude = None if rm_conf: try: exclude = ...
[ "def", "run_collection", "(", "self", ",", "conf", ",", "rm_conf", ",", "branch_info", ")", ":", "if", "rm_conf", "is", "None", ":", "rm_conf", "=", "{", "}", "logger", ".", "debug", "(", "'Beginning to run collection spec...'", ")", "exclude", "=", "None", ...
Run specs and collect all the data
[ "Run", "specs", "and", "collect", "all", "the", "data" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/data_collector.py#L148-L203
train
RedHatInsights/insights-core
insights/client/data_collector.py
DataCollector.done
def done(self, conf, rm_conf): """ Do finalization stuff """ if self.config.obfuscate: cleaner = SOSCleaner(quiet=True) clean_opts = CleanOptions( self.config, self.archive.tmp_dir, rm_conf, self.hostname_path) fresh = cleaner.clean_rep...
python
def done(self, conf, rm_conf): """ Do finalization stuff """ if self.config.obfuscate: cleaner = SOSCleaner(quiet=True) clean_opts = CleanOptions( self.config, self.archive.tmp_dir, rm_conf, self.hostname_path) fresh = cleaner.clean_rep...
[ "def", "done", "(", "self", ",", "conf", ",", "rm_conf", ")", ":", "if", "self", ".", "config", ".", "obfuscate", ":", "cleaner", "=", "SOSCleaner", "(", "quiet", "=", "True", ")", "clean_opts", "=", "CleanOptions", "(", "self", ".", "config", ",", "...
Do finalization stuff
[ "Do", "finalization", "stuff" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/data_collector.py#L205-L218
train
RedHatInsights/insights-core
insights/specs/default.py
DefaultSpecs.sap_sid_nr
def sap_sid_nr(broker): """ Get the SID and Instance Number Typical output of saphostctrl_listinstances:: # /usr/sap/hostctrl/exe/saphostctrl -function ListInstances Inst Info : SR1 - 01 - liuxc-rhel7-hana-ent - 749, patch 418, changelist 1816226 Returns: (l...
python
def sap_sid_nr(broker): """ Get the SID and Instance Number Typical output of saphostctrl_listinstances:: # /usr/sap/hostctrl/exe/saphostctrl -function ListInstances Inst Info : SR1 - 01 - liuxc-rhel7-hana-ent - 749, patch 418, changelist 1816226 Returns: (l...
[ "def", "sap_sid_nr", "(", "broker", ")", ":", "insts", "=", "broker", "[", "DefaultSpecs", ".", "saphostctrl_listinstances", "]", ".", "content", "hn", "=", "broker", "[", "DefaultSpecs", ".", "hostname", "]", ".", "content", "[", "0", "]", ".", "split", ...
Get the SID and Instance Number Typical output of saphostctrl_listinstances:: # /usr/sap/hostctrl/exe/saphostctrl -function ListInstances Inst Info : SR1 - 01 - liuxc-rhel7-hana-ent - 749, patch 418, changelist 1816226 Returns: (list): List of tuple of SID and Instance Numb...
[ "Get", "the", "SID", "and", "Instance", "Number" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/specs/default.py#L724-L745
train
RedHatInsights/insights-core
insights/util/file_permissions.py
FilePermissions.from_dict
def from_dict(self, dirent): """ Create a new FilePermissions object from the given dictionary. This works with the FileListing parser class, which has already done the hard work of pulling many of these fields out. We create an object with all the dictionary keys available as ...
python
def from_dict(self, dirent): """ Create a new FilePermissions object from the given dictionary. This works with the FileListing parser class, which has already done the hard work of pulling many of these fields out. We create an object with all the dictionary keys available as ...
[ "def", "from_dict", "(", "self", ",", "dirent", ")", ":", "# Check that we have at least as much data as the __init__ requires", "for", "k", "in", "[", "'perms'", ",", "'owner'", ",", "'group'", ",", "'name'", ",", "'dir'", "]", ":", "if", "k", "not", "in", "d...
Create a new FilePermissions object from the given dictionary. This works with the FileListing parser class, which has already done the hard work of pulling many of these fields out. We create an object with all the dictionary keys available as properties, and also split the ``perms`` ...
[ "Create", "a", "new", "FilePermissions", "object", "from", "the", "given", "dictionary", ".", "This", "works", "with", "the", "FileListing", "parser", "class", "which", "has", "already", "done", "the", "hard", "work", "of", "pulling", "many", "of", "these", ...
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/util/file_permissions.py#L88-L107
train
RedHatInsights/insights-core
insights/util/file_permissions.py
FilePermissions.owned_by
def owned_by(self, owner, also_check_group=False): """ Checks if the specified user or user and group own the file. Args: owner (str): the user (or group) name for which we ask about ownership also_check_group (bool): if set to True, both user owner and group owner check...
python
def owned_by(self, owner, also_check_group=False): """ Checks if the specified user or user and group own the file. Args: owner (str): the user (or group) name for which we ask about ownership also_check_group (bool): if set to True, both user owner and group owner check...
[ "def", "owned_by", "(", "self", ",", "owner", ",", "also_check_group", "=", "False", ")", ":", "if", "also_check_group", ":", "return", "self", ".", "owner", "==", "owner", "and", "self", ".", "group", "==", "owner", "else", ":", "return", "self", ".", ...
Checks if the specified user or user and group own the file. Args: owner (str): the user (or group) name for which we ask about ownership also_check_group (bool): if set to True, both user owner and group owner checked if set to False, only user owner che...
[ "Checks", "if", "the", "specified", "user", "or", "user", "and", "group", "own", "the", "file", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/util/file_permissions.py#L109-L124
train
RedHatInsights/insights-core
insights/parsers/multipath_conf.py
get_tree
def get_tree(root=None): """ This is a helper function to get a multipath configuration component for your local machine or an archive. It's for use in interactive sessions. """ from insights import run return run(MultipathConfTree, root=root).get(MultipathConfTree)
python
def get_tree(root=None): """ This is a helper function to get a multipath configuration component for your local machine or an archive. It's for use in interactive sessions. """ from insights import run return run(MultipathConfTree, root=root).get(MultipathConfTree)
[ "def", "get_tree", "(", "root", "=", "None", ")", ":", "from", "insights", "import", "run", "return", "run", "(", "MultipathConfTree", ",", "root", "=", "root", ")", ".", "get", "(", "MultipathConfTree", ")" ]
This is a helper function to get a multipath configuration component for your local machine or an archive. It's for use in interactive sessions.
[ "This", "is", "a", "helper", "function", "to", "get", "a", "multipath", "configuration", "component", "for", "your", "local", "machine", "or", "an", "archive", ".", "It", "s", "for", "use", "in", "interactive", "sessions", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/multipath_conf.py#L188-L194
train
RedHatInsights/insights-core
insights/client/support.py
InsightsSupport._support_diag_dump
def _support_diag_dump(self): ''' Collect log info for debug ''' # check insights config cfg_block = [] pconn = InsightsConnection(self.config) logger.info('Insights version: %s', get_nvr()) reg_check = registration_check(pconn) cfg_block.append(...
python
def _support_diag_dump(self): ''' Collect log info for debug ''' # check insights config cfg_block = [] pconn = InsightsConnection(self.config) logger.info('Insights version: %s', get_nvr()) reg_check = registration_check(pconn) cfg_block.append(...
[ "def", "_support_diag_dump", "(", "self", ")", ":", "# check insights config", "cfg_block", "=", "[", "]", "pconn", "=", "InsightsConnection", "(", "self", ".", "config", ")", "logger", ".", "info", "(", "'Insights version: %s'", ",", "get_nvr", "(", ")", ")",...
Collect log info for debug
[ "Collect", "log", "info", "for", "debug" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/support.py#L94-L165
train
RedHatInsights/insights-core
insights/core/filters.py
add_filter
def add_filter(ds, patterns): """ Add a filter or list of filters to a datasource. A filter is a simple string, and it matches if it is contained anywhere within a line. Args: ds (@datasource component): The datasource to filter patterns (str, [str]): A string, list of strings, or set of ...
python
def add_filter(ds, patterns): """ Add a filter or list of filters to a datasource. A filter is a simple string, and it matches if it is contained anywhere within a line. Args: ds (@datasource component): The datasource to filter patterns (str, [str]): A string, list of strings, or set of ...
[ "def", "add_filter", "(", "ds", ",", "patterns", ")", ":", "if", "not", "plugins", ".", "is_datasource", "(", "ds", ")", ":", "raise", "Exception", "(", "\"Filters are applicable only to datasources.\"", ")", "delegate", "=", "dr", ".", "get_delegate", "(", "d...
Add a filter or list of filters to a datasource. A filter is a simple string, and it matches if it is contained anywhere within a line. Args: ds (@datasource component): The datasource to filter patterns (str, [str]): A string, list of strings, or set of strings to add to the datasour...
[ "Add", "a", "filter", "or", "list", "of", "filters", "to", "a", "datasource", ".", "A", "filter", "is", "a", "simple", "string", "and", "it", "matches", "if", "it", "is", "contained", "anywhere", "within", "a", "line", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L49-L79
train
RedHatInsights/insights-core
insights/core/filters.py
get_filters
def get_filters(component): """ Get the set of filters for the given datasource. Filters added to a ``RegistryPoint`` will be applied to all datasources that implement it. Filters added to a datasource implementation apply only to that implementation. For example, a filter added to ``Specs.ps_...
python
def get_filters(component): """ Get the set of filters for the given datasource. Filters added to a ``RegistryPoint`` will be applied to all datasources that implement it. Filters added to a datasource implementation apply only to that implementation. For example, a filter added to ``Specs.ps_...
[ "def", "get_filters", "(", "component", ")", ":", "def", "inner", "(", "c", ",", "filters", "=", "None", ")", ":", "filters", "=", "filters", "or", "set", "(", ")", "if", "not", "ENABLED", ":", "return", "filters", "if", "not", "plugins", ".", "is_da...
Get the set of filters for the given datasource. Filters added to a ``RegistryPoint`` will be applied to all datasources that implement it. Filters added to a datasource implementation apply only to that implementation. For example, a filter added to ``Specs.ps_auxww`` will apply to ``DefaultSpecs...
[ "Get", "the", "set", "of", "filters", "for", "the", "given", "datasource", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L82-L119
train
RedHatInsights/insights-core
insights/core/filters.py
apply_filters
def apply_filters(target, lines): """ Applys filters to the lines of a datasource. This function is used only in integration tests. Filters are applied in an equivalent but more performant way at run time. """ filters = get_filters(target) if filters: for l in lines: if a...
python
def apply_filters(target, lines): """ Applys filters to the lines of a datasource. This function is used only in integration tests. Filters are applied in an equivalent but more performant way at run time. """ filters = get_filters(target) if filters: for l in lines: if a...
[ "def", "apply_filters", "(", "target", ",", "lines", ")", ":", "filters", "=", "get_filters", "(", "target", ")", "if", "filters", ":", "for", "l", "in", "lines", ":", "if", "any", "(", "f", "in", "l", "for", "f", "in", "filters", ")", ":", "yield"...
Applys filters to the lines of a datasource. This function is used only in integration tests. Filters are applied in an equivalent but more performant way at run time.
[ "Applys", "filters", "to", "the", "lines", "of", "a", "datasource", ".", "This", "function", "is", "used", "only", "in", "integration", "tests", ".", "Filters", "are", "applied", "in", "an", "equivalent", "but", "more", "performant", "way", "at", "run", "t...
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L122-L135
train
RedHatInsights/insights-core
insights/core/filters.py
loads
def loads(string): """Loads the filters dictionary given a string.""" d = _loads(string) for k, v in d.items(): FILTERS[dr.get_component(k) or k] = set(v)
python
def loads(string): """Loads the filters dictionary given a string.""" d = _loads(string) for k, v in d.items(): FILTERS[dr.get_component(k) or k] = set(v)
[ "def", "loads", "(", "string", ")", ":", "d", "=", "_loads", "(", "string", ")", "for", "k", ",", "v", "in", "d", ".", "items", "(", ")", ":", "FILTERS", "[", "dr", ".", "get_component", "(", "k", ")", "or", "k", "]", "=", "set", "(", "v", ...
Loads the filters dictionary given a string.
[ "Loads", "the", "filters", "dictionary", "given", "a", "string", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L143-L147
train
RedHatInsights/insights-core
insights/core/filters.py
load
def load(stream=None): """ Loads filters from a stream, normally an open file. If one is not passed, filters are loaded from a default location within the project. """ if stream: loads(stream.read()) else: data = pkgutil.get_data(insights.__name__, _filename) return l...
python
def load(stream=None): """ Loads filters from a stream, normally an open file. If one is not passed, filters are loaded from a default location within the project. """ if stream: loads(stream.read()) else: data = pkgutil.get_data(insights.__name__, _filename) return l...
[ "def", "load", "(", "stream", "=", "None", ")", ":", "if", "stream", ":", "loads", "(", "stream", ".", "read", "(", ")", ")", "else", ":", "data", "=", "pkgutil", ".", "get_data", "(", "insights", ".", "__name__", ",", "_filename", ")", "return", "...
Loads filters from a stream, normally an open file. If one is not passed, filters are loaded from a default location within the project.
[ "Loads", "filters", "from", "a", "stream", "normally", "an", "open", "file", ".", "If", "one", "is", "not", "passed", "filters", "are", "loaded", "from", "a", "default", "location", "within", "the", "project", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L150-L160
train
RedHatInsights/insights-core
insights/core/filters.py
dumps
def dumps(): """Returns a string representation of the FILTERS dictionary.""" d = {} for k, v in FILTERS.items(): d[dr.get_name(k)] = list(v) return _dumps(d)
python
def dumps(): """Returns a string representation of the FILTERS dictionary.""" d = {} for k, v in FILTERS.items(): d[dr.get_name(k)] = list(v) return _dumps(d)
[ "def", "dumps", "(", ")", ":", "d", "=", "{", "}", "for", "k", ",", "v", "in", "FILTERS", ".", "items", "(", ")", ":", "d", "[", "dr", ".", "get_name", "(", "k", ")", "]", "=", "list", "(", "v", ")", "return", "_dumps", "(", "d", ")" ]
Returns a string representation of the FILTERS dictionary.
[ "Returns", "a", "string", "representation", "of", "the", "FILTERS", "dictionary", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L163-L168
train
RedHatInsights/insights-core
insights/core/filters.py
dump
def dump(stream=None): """ Dumps a string representation of `FILTERS` to a stream, normally an open file. If none is passed, `FILTERS` is dumped to a default location within the project. """ if stream: stream.write(dumps()) else: path = os.path.join(os.path.dirname(insights._...
python
def dump(stream=None): """ Dumps a string representation of `FILTERS` to a stream, normally an open file. If none is passed, `FILTERS` is dumped to a default location within the project. """ if stream: stream.write(dumps()) else: path = os.path.join(os.path.dirname(insights._...
[ "def", "dump", "(", "stream", "=", "None", ")", ":", "if", "stream", ":", "stream", ".", "write", "(", "dumps", "(", ")", ")", "else", ":", "path", "=", "os", ".", "path", ".", "join", "(", "os", ".", "path", ".", "dirname", "(", "insights", "....
Dumps a string representation of `FILTERS` to a stream, normally an open file. If none is passed, `FILTERS` is dumped to a default location within the project.
[ "Dumps", "a", "string", "representation", "of", "FILTERS", "to", "a", "stream", "normally", "an", "open", "file", ".", "If", "none", "is", "passed", "FILTERS", "is", "dumped", "to", "a", "default", "location", "within", "the", "project", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/filters.py#L171-L182
train
RedHatInsights/insights-core
insights/parsers/grub_conf.py
_parse_script
def _parse_script(list, line, line_iter): """ Eliminate any bash script contained in the grub v2 configuration """ ifIdx = 0 while (True): line = next(line_iter) if line.startswith("fi"): if ifIdx == 0: return ifIdx -= 1 elif line.start...
python
def _parse_script(list, line, line_iter): """ Eliminate any bash script contained in the grub v2 configuration """ ifIdx = 0 while (True): line = next(line_iter) if line.startswith("fi"): if ifIdx == 0: return ifIdx -= 1 elif line.start...
[ "def", "_parse_script", "(", "list", ",", "line", ",", "line_iter", ")", ":", "ifIdx", "=", "0", "while", "(", "True", ")", ":", "line", "=", "next", "(", "line_iter", ")", "if", "line", ".", "startswith", "(", "\"fi\"", ")", ":", "if", "ifIdx", "=...
Eliminate any bash script contained in the grub v2 configuration
[ "Eliminate", "any", "bash", "script", "contained", "in", "the", "grub", "v2", "configuration" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/grub_conf.py#L397-L409
train
RedHatInsights/insights-core
insights/parsers/grub_conf.py
_parse_title
def _parse_title(line_iter, cur_line, conf): """ Parse "title" in grub v1 config """ title = [] conf['title'].append(title) title.append(('title_name', cur_line.split('title', 1)[1].strip())) while (True): line = next(line_iter) if line.startswith("title "): retur...
python
def _parse_title(line_iter, cur_line, conf): """ Parse "title" in grub v1 config """ title = [] conf['title'].append(title) title.append(('title_name', cur_line.split('title', 1)[1].strip())) while (True): line = next(line_iter) if line.startswith("title "): retur...
[ "def", "_parse_title", "(", "line_iter", ",", "cur_line", ",", "conf", ")", ":", "title", "=", "[", "]", "conf", "[", "'title'", "]", ".", "append", "(", "title", ")", "title", ".", "append", "(", "(", "'title_name'", ",", "cur_line", ".", "split", "...
Parse "title" in grub v1 config
[ "Parse", "title", "in", "grub", "v1", "config" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/grub_conf.py#L447-L460
train
RedHatInsights/insights-core
insights/parsers/grub_conf.py
GrubConfig.is_kdump_iommu_enabled
def is_kdump_iommu_enabled(self): """ Does any kernel have 'intel_iommu=on' set? Returns: (bool): ``True`` when 'intel_iommu=on' is set, otherwise returns ``False`` """ for line in self._boot_entries: if line.cmdline and IOMMU in line.cmdline: ...
python
def is_kdump_iommu_enabled(self): """ Does any kernel have 'intel_iommu=on' set? Returns: (bool): ``True`` when 'intel_iommu=on' is set, otherwise returns ``False`` """ for line in self._boot_entries: if line.cmdline and IOMMU in line.cmdline: ...
[ "def", "is_kdump_iommu_enabled", "(", "self", ")", ":", "for", "line", "in", "self", ".", "_boot_entries", ":", "if", "line", ".", "cmdline", "and", "IOMMU", "in", "line", ".", "cmdline", ":", "return", "True", "return", "False" ]
Does any kernel have 'intel_iommu=on' set? Returns: (bool): ``True`` when 'intel_iommu=on' is set, otherwise returns ``False``
[ "Does", "any", "kernel", "have", "intel_iommu", "=", "on", "set?" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/grub_conf.py#L177-L188
train
RedHatInsights/insights-core
insights/parsers/grub_conf.py
GrubConfig.kernel_initrds
def kernel_initrds(self): """ Get the `kernel` and `initrd` files referenced in GRUB configuration files Returns: (dict): Returns a dict of the `kernel` and `initrd` files referenced in GRUB configuration files """ kernels = [] initrds = ...
python
def kernel_initrds(self): """ Get the `kernel` and `initrd` files referenced in GRUB configuration files Returns: (dict): Returns a dict of the `kernel` and `initrd` files referenced in GRUB configuration files """ kernels = [] initrds = ...
[ "def", "kernel_initrds", "(", "self", ")", ":", "kernels", "=", "[", "]", "initrds", "=", "[", "]", "name_values", "=", "[", "(", "k", ",", "v", ")", "for", "k", ",", "v", "in", "self", ".", "data", ".", "get", "(", "'configs'", ",", "[", "]", ...
Get the `kernel` and `initrd` files referenced in GRUB configuration files Returns: (dict): Returns a dict of the `kernel` and `initrd` files referenced in GRUB configuration files
[ "Get", "the", "kernel", "and", "initrd", "files", "referenced", "in", "GRUB", "configuration", "files" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/grub_conf.py#L192-L222
train
RedHatInsights/insights-core
insights/core/serde.py
serializer
def serializer(_type): """ Decorator for serializers. A serializer should accept two parameters: An object and a path which is a directory on the filesystem where supplementary data can be stored. This is most often useful for datasources. It should return a dictionary version of the original o...
python
def serializer(_type): """ Decorator for serializers. A serializer should accept two parameters: An object and a path which is a directory on the filesystem where supplementary data can be stored. This is most often useful for datasources. It should return a dictionary version of the original o...
[ "def", "serializer", "(", "_type", ")", ":", "def", "inner", "(", "func", ")", ":", "name", "=", "dr", ".", "get_name", "(", "_type", ")", "if", "name", "in", "SERIALIZERS", ":", "msg", "=", "\"%s already has a serializer registered: %s\"", "raise", "Excepti...
Decorator for serializers. A serializer should accept two parameters: An object and a path which is a directory on the filesystem where supplementary data can be stored. This is most often useful for datasources. It should return a dictionary version of the original object that contains only elements t...
[ "Decorator", "for", "serializers", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/serde.py#L26-L44
train
RedHatInsights/insights-core
insights/core/serde.py
deserializer
def deserializer(_type): """ Decorator for deserializers. A deserializer should accept three parameters: A type, a dictionary, and a path that may contain supplementary data stored by its paired serializer. If the serializer stores supplementary data, the relative path to it should be somewhere...
python
def deserializer(_type): """ Decorator for deserializers. A deserializer should accept three parameters: A type, a dictionary, and a path that may contain supplementary data stored by its paired serializer. If the serializer stores supplementary data, the relative path to it should be somewhere...
[ "def", "deserializer", "(", "_type", ")", ":", "def", "inner", "(", "func", ")", ":", "name", "=", "dr", ".", "get_name", "(", "_type", ")", "if", "name", "in", "DESERIALIZERS", ":", "msg", "=", "\"%s already has a deserializer registered: %s\"", "raise", "E...
Decorator for deserializers. A deserializer should accept three parameters: A type, a dictionary, and a path that may contain supplementary data stored by its paired serializer. If the serializer stores supplementary data, the relative path to it should be somewhere in the dict of the second parameter.
[ "Decorator", "for", "deserializers", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/serde.py#L47-L64
train
RedHatInsights/insights-core
insights/core/serde.py
Hydration.hydrate
def hydrate(self, broker=None): """ Loads a Broker from a previously saved one. A Broker is created if one isn't provided. """ broker = broker or dr.Broker() for path in glob(os.path.join(self.meta_data, "*")): try: with open(path) as f: ...
python
def hydrate(self, broker=None): """ Loads a Broker from a previously saved one. A Broker is created if one isn't provided. """ broker = broker or dr.Broker() for path in glob(os.path.join(self.meta_data, "*")): try: with open(path) as f: ...
[ "def", "hydrate", "(", "self", ",", "broker", "=", "None", ")", ":", "broker", "=", "broker", "or", "dr", ".", "Broker", "(", ")", "for", "path", "in", "glob", "(", "os", ".", "path", ".", "join", "(", "self", ".", "meta_data", ",", "\"*\"", ")",...
Loads a Broker from a previously saved one. A Broker is created if one isn't provided.
[ "Loads", "a", "Broker", "from", "a", "previously", "saved", "one", ".", "A", "Broker", "is", "created", "if", "one", "isn", "t", "provided", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/serde.py#L144-L161
train
RedHatInsights/insights-core
insights/core/serde.py
Hydration.dehydrate
def dehydrate(self, comp, broker): """ Saves a component in the given broker to the file system. """ if not self.meta_data: raise Exception("Hydration meta_path not set. Can't dehydrate.") if not self.created: fs.ensure_path(self.meta_data, mode=0o770) ...
python
def dehydrate(self, comp, broker): """ Saves a component in the given broker to the file system. """ if not self.meta_data: raise Exception("Hydration meta_path not set. Can't dehydrate.") if not self.created: fs.ensure_path(self.meta_data, mode=0o770) ...
[ "def", "dehydrate", "(", "self", ",", "comp", ",", "broker", ")", ":", "if", "not", "self", ".", "meta_data", ":", "raise", "Exception", "(", "\"Hydration meta_path not set. Can't dehydrate.\"", ")", "if", "not", "self", ".", "created", ":", "fs", ".", "ensu...
Saves a component in the given broker to the file system.
[ "Saves", "a", "component", "in", "the", "given", "broker", "to", "the", "file", "system", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/serde.py#L163-L209
train
RedHatInsights/insights-core
insights/core/serde.py
Hydration.make_persister
def make_persister(self, to_persist): """ Returns a function that hydrates components as they are evaluated. The function should be registered as an observer on a Broker just before execution. Args: to_persist (set): Set of components to persist. Skip everything ...
python
def make_persister(self, to_persist): """ Returns a function that hydrates components as they are evaluated. The function should be registered as an observer on a Broker just before execution. Args: to_persist (set): Set of components to persist. Skip everything ...
[ "def", "make_persister", "(", "self", ",", "to_persist", ")", ":", "if", "not", "self", ".", "meta_data", ":", "raise", "Exception", "(", "\"Root not set. Can't create persister.\"", ")", "def", "persister", "(", "c", ",", "broker", ")", ":", "if", "c", "in"...
Returns a function that hydrates components as they are evaluated. The function should be registered as an observer on a Broker just before execution. Args: to_persist (set): Set of components to persist. Skip everything else.
[ "Returns", "a", "function", "that", "hydrates", "components", "as", "they", "are", "evaluated", ".", "The", "function", "should", "be", "registered", "as", "an", "observer", "on", "a", "Broker", "just", "before", "execution", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/core/serde.py#L211-L228
train
RedHatInsights/insights-core
insights/parsers/lvm.py
map_keys
def map_keys(pvs, keys): """ Add human readable key names to dictionary while leaving any existing key names. """ rs = [] for pv in pvs: r = dict((v, None) for k, v in keys.items()) for k, v in pv.items(): if k in keys: r[keys[k]] = v r[k] = v ...
python
def map_keys(pvs, keys): """ Add human readable key names to dictionary while leaving any existing key names. """ rs = [] for pv in pvs: r = dict((v, None) for k, v in keys.items()) for k, v in pv.items(): if k in keys: r[keys[k]] = v r[k] = v ...
[ "def", "map_keys", "(", "pvs", ",", "keys", ")", ":", "rs", "=", "[", "]", "for", "pv", "in", "pvs", ":", "r", "=", "dict", "(", "(", "v", ",", "None", ")", "for", "k", ",", "v", "in", "keys", ".", "items", "(", ")", ")", "for", "k", ",",...
Add human readable key names to dictionary while leaving any existing key names.
[ "Add", "human", "readable", "key", "names", "to", "dictionary", "while", "leaving", "any", "existing", "key", "names", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/lvm.py#L43-L55
train
RedHatInsights/insights-core
insights/configtree/__init__.py
from_dict
def from_dict(dct): """ Convert a dictionary into a configtree. """ def inner(d): results = [] for name, v in d.items(): if isinstance(v, dict): results.append(Section(name=name, children=from_dict(v))) elif isinstance(v, list): if not any...
python
def from_dict(dct): """ Convert a dictionary into a configtree. """ def inner(d): results = [] for name, v in d.items(): if isinstance(v, dict): results.append(Section(name=name, children=from_dict(v))) elif isinstance(v, list): if not any...
[ "def", "from_dict", "(", "dct", ")", ":", "def", "inner", "(", "d", ")", ":", "results", "=", "[", "]", "for", "name", ",", "v", "in", "d", ".", "items", "(", ")", ":", "if", "isinstance", "(", "v", ",", "dict", ")", ":", "results", ".", "app...
Convert a dictionary into a configtree.
[ "Convert", "a", "dictionary", "into", "a", "configtree", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/configtree/__init__.py#L348-L369
train
RedHatInsights/insights-core
insights/configtree/__init__.py
__or
def __or(funcs, args): """ Support list sugar for "or" of two predicates. Used inside `select`. """ results = [] for f in funcs: result = f(args) if result: results.extend(result) return results
python
def __or(funcs, args): """ Support list sugar for "or" of two predicates. Used inside `select`. """ results = [] for f in funcs: result = f(args) if result: results.extend(result) return results
[ "def", "__or", "(", "funcs", ",", "args", ")", ":", "results", "=", "[", "]", "for", "f", "in", "funcs", ":", "result", "=", "f", "(", "args", ")", "if", "result", ":", "results", ".", "extend", "(", "result", ")", "return", "results" ]
Support list sugar for "or" of two predicates. Used inside `select`.
[ "Support", "list", "sugar", "for", "or", "of", "two", "predicates", ".", "Used", "inside", "select", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/configtree/__init__.py#L582-L589
train
RedHatInsights/insights-core
insights/configtree/__init__.py
BinaryBool
def BinaryBool(pred): """ Lifts predicates that take an argument into the DSL. """ class Predicate(Bool): def __init__(self, value, ignore_case=False): self.value = caseless(value) if ignore_case else value self.ignore_case = ignore_case def __call__(self, data): ...
python
def BinaryBool(pred): """ Lifts predicates that take an argument into the DSL. """ class Predicate(Bool): def __init__(self, value, ignore_case=False): self.value = caseless(value) if ignore_case else value self.ignore_case = ignore_case def __call__(self, data): ...
[ "def", "BinaryBool", "(", "pred", ")", ":", "class", "Predicate", "(", "Bool", ")", ":", "def", "__init__", "(", "self", ",", "value", ",", "ignore_case", "=", "False", ")", ":", "self", ".", "value", "=", "caseless", "(", "value", ")", "if", "ignore...
Lifts predicates that take an argument into the DSL.
[ "Lifts", "predicates", "that", "take", "an", "argument", "into", "the", "DSL", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/configtree/__init__.py#L652-L669
train
RedHatInsights/insights-core
insights/configtree/__init__.py
select
def select(*queries, **kwargs): """ Builds a function that will execute the specified queries against a list of Nodes. """ def make_query(*args): def simple_query(nodes): if len(args) == 0: return nodes pred = args[0] results = [] ...
python
def select(*queries, **kwargs): """ Builds a function that will execute the specified queries against a list of Nodes. """ def make_query(*args): def simple_query(nodes): if len(args) == 0: return nodes pred = args[0] results = [] ...
[ "def", "select", "(", "*", "queries", ",", "*", "*", "kwargs", ")", ":", "def", "make_query", "(", "*", "args", ")", ":", "def", "simple_query", "(", "nodes", ")", ":", "if", "len", "(", "args", ")", "==", "0", ":", "return", "nodes", "pred", "="...
Builds a function that will execute the specified queries against a list of Nodes.
[ "Builds", "a", "function", "that", "will", "execute", "the", "specified", "queries", "against", "a", "list", "of", "Nodes", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/configtree/__init__.py#L722-L793
train
RedHatInsights/insights-core
insights/configtree/__init__.py
Node.find
def find(self, *queries, **kwargs): """ Finds the first result found anywhere in the configuration. Pass `one=last` for the last result. Returns `None` if no results are found. """ kwargs["deep"] = True kwargs["roots"] = False if "one" not in kwargs: k...
python
def find(self, *queries, **kwargs): """ Finds the first result found anywhere in the configuration. Pass `one=last` for the last result. Returns `None` if no results are found. """ kwargs["deep"] = True kwargs["roots"] = False if "one" not in kwargs: k...
[ "def", "find", "(", "self", ",", "*", "queries", ",", "*", "*", "kwargs", ")", ":", "kwargs", "[", "\"deep\"", "]", "=", "True", "kwargs", "[", "\"roots\"", "]", "=", "False", "if", "\"one\"", "not", "in", "kwargs", ":", "kwargs", "[", "\"one\"", "...
Finds the first result found anywhere in the configuration. Pass `one=last` for the last result. Returns `None` if no results are found.
[ "Finds", "the", "first", "result", "found", "anywhere", "in", "the", "configuration", ".", "Pass", "one", "=", "last", "for", "the", "last", "result", ".", "Returns", "None", "if", "no", "results", "are", "found", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/configtree/__init__.py#L165-L174
train
RedHatInsights/insights-core
insights/configtree/__init__.py
Node.find_all
def find_all(self, *queries): """ Find all results matching the query anywhere in the configuration. Returns an empty `SearchResult` if no results are found. """ return self.select(*queries, deep=True, roots=False)
python
def find_all(self, *queries): """ Find all results matching the query anywhere in the configuration. Returns an empty `SearchResult` if no results are found. """ return self.select(*queries, deep=True, roots=False)
[ "def", "find_all", "(", "self", ",", "*", "queries", ")", ":", "return", "self", ".", "select", "(", "*", "queries", ",", "deep", "=", "True", ",", "roots", "=", "False", ")" ]
Find all results matching the query anywhere in the configuration. Returns an empty `SearchResult` if no results are found.
[ "Find", "all", "results", "matching", "the", "query", "anywhere", "in", "the", "configuration", ".", "Returns", "an", "empty", "SearchResult", "if", "no", "results", "are", "found", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/configtree/__init__.py#L176-L181
train
RedHatInsights/insights-core
insights/parsers/installed_rpms.py
pad_version
def pad_version(left, right): """Returns two sequences of the same length so that they can be compared. The shorter of the two arguments is lengthened by inserting extra zeros before non-integer components. The algorithm attempts to align character components.""" pair = vcmp(left), vcmp(right) ...
python
def pad_version(left, right): """Returns two sequences of the same length so that they can be compared. The shorter of the two arguments is lengthened by inserting extra zeros before non-integer components. The algorithm attempts to align character components.""" pair = vcmp(left), vcmp(right) ...
[ "def", "pad_version", "(", "left", ",", "right", ")", ":", "pair", "=", "vcmp", "(", "left", ")", ",", "vcmp", "(", "right", ")", "mn", ",", "mx", "=", "min", "(", "pair", ",", "key", "=", "len", ")", ",", "max", "(", "pair", ",", "key", "=",...
Returns two sequences of the same length so that they can be compared. The shorter of the two arguments is lengthened by inserting extra zeros before non-integer components. The algorithm attempts to align character components.
[ "Returns", "two", "sequences", "of", "the", "same", "length", "so", "that", "they", "can", "be", "compared", ".", "The", "shorter", "of", "the", "two", "arguments", "is", "lengthened", "by", "inserting", "extra", "zeros", "before", "non", "-", "integer", "...
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/installed_rpms.py#L254-L278
train
RedHatInsights/insights-core
insights/parsers/installed_rpms.py
InstalledRpm._parse_package
def _parse_package(cls, package_string): """ Helper method for parsing package string. Args: package_string (str): dash separated package string such as 'bash-4.2.39-3.el7' Returns: dict: dictionary containing 'name', 'version', 'release' and 'arch' keys ...
python
def _parse_package(cls, package_string): """ Helper method for parsing package string. Args: package_string (str): dash separated package string such as 'bash-4.2.39-3.el7' Returns: dict: dictionary containing 'name', 'version', 'release' and 'arch' keys ...
[ "def", "_parse_package", "(", "cls", ",", "package_string", ")", ":", "pkg", ",", "arch", "=", "rsplit", "(", "package_string", ",", "cls", ".", "_arch_sep", "(", "package_string", ")", ")", "if", "arch", "not", "in", "KNOWN_ARCHITECTURES", ":", "pkg", ","...
Helper method for parsing package string. Args: package_string (str): dash separated package string such as 'bash-4.2.39-3.el7' Returns: dict: dictionary containing 'name', 'version', 'release' and 'arch' keys
[ "Helper", "method", "for", "parsing", "package", "string", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/installed_rpms.py#L431-L457
train
RedHatInsights/insights-core
insights/parsers/installed_rpms.py
InstalledRpm._parse_line
def _parse_line(cls, line): """ Helper method for parsing package line with or without SOS report information. Args: line (str): package line with or without SOS report information Returns: dict: dictionary containing 'name', 'version', 'release' and 'arch' keys...
python
def _parse_line(cls, line): """ Helper method for parsing package line with or without SOS report information. Args: line (str): package line with or without SOS report information Returns: dict: dictionary containing 'name', 'version', 'release' and 'arch' keys...
[ "def", "_parse_line", "(", "cls", ",", "line", ")", ":", "try", ":", "pkg", ",", "rest", "=", "line", ".", "split", "(", "None", ",", "1", ")", "except", "ValueError", ":", "rpm", "=", "cls", ".", "_parse_package", "(", "line", ".", "strip", "(", ...
Helper method for parsing package line with or without SOS report information. Args: line (str): package line with or without SOS report information Returns: dict: dictionary containing 'name', 'version', 'release' and 'arch' keys plus additionally 'installtim...
[ "Helper", "method", "for", "parsing", "package", "line", "with", "or", "without", "SOS", "report", "information", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/installed_rpms.py#L460-L481
train
RedHatInsights/insights-core
insights/contrib/importlib.py
_resolve_name
def _resolve_name(name, package, level): """Return the absolute name of the module to be imported.""" if not hasattr(package, 'rindex'): raise ValueError("'package' not set to a string") dot = len(package) for x in xrange(level, 1, -1): try: dot = package.rindex('.', 0, dot) ...
python
def _resolve_name(name, package, level): """Return the absolute name of the module to be imported.""" if not hasattr(package, 'rindex'): raise ValueError("'package' not set to a string") dot = len(package) for x in xrange(level, 1, -1): try: dot = package.rindex('.', 0, dot) ...
[ "def", "_resolve_name", "(", "name", ",", "package", ",", "level", ")", ":", "if", "not", "hasattr", "(", "package", ",", "'rindex'", ")", ":", "raise", "ValueError", "(", "\"'package' not set to a string\"", ")", "dot", "=", "len", "(", "package", ")", "f...
Return the absolute name of the module to be imported.
[ "Return", "the", "absolute", "name", "of", "the", "module", "to", "be", "imported", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/contrib/importlib.py#L6-L17
train
RedHatInsights/insights-core
insights/parsers/krb5.py
_handle_key_value
def _handle_key_value(t_dict, key, value): """ Function to handle key has multi value, and return the values as list. """ if key in t_dict: val = t_dict[key] if isinstance(val, str): val = [val] val.append(value) return val return value
python
def _handle_key_value(t_dict, key, value): """ Function to handle key has multi value, and return the values as list. """ if key in t_dict: val = t_dict[key] if isinstance(val, str): val = [val] val.append(value) return val return value
[ "def", "_handle_key_value", "(", "t_dict", ",", "key", ",", "value", ")", ":", "if", "key", "in", "t_dict", ":", "val", "=", "t_dict", "[", "key", "]", "if", "isinstance", "(", "val", ",", "str", ")", ":", "val", "=", "[", "val", "]", "val", ".",...
Function to handle key has multi value, and return the values as list.
[ "Function", "to", "handle", "key", "has", "multi", "value", "and", "return", "the", "values", "as", "list", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/krb5.py#L63-L73
train
RedHatInsights/insights-core
insights/formats/__init__.py
get_formatter
def get_formatter(name): """ Looks up a formatter class given a prefix to it. The names are sorted, and the first matching class is returned. """ for k in sorted(_FORMATTERS): if k.startswith(name): return _FORMATTERS[k]
python
def get_formatter(name): """ Looks up a formatter class given a prefix to it. The names are sorted, and the first matching class is returned. """ for k in sorted(_FORMATTERS): if k.startswith(name): return _FORMATTERS[k]
[ "def", "get_formatter", "(", "name", ")", ":", "for", "k", "in", "sorted", "(", "_FORMATTERS", ")", ":", "if", "k", ".", "startswith", "(", "name", ")", ":", "return", "_FORMATTERS", "[", "k", "]" ]
Looks up a formatter class given a prefix to it. The names are sorted, and the first matching class is returned.
[ "Looks", "up", "a", "formatter", "class", "given", "a", "prefix", "to", "it", ".", "The", "names", "are", "sorted", "and", "the", "first", "matching", "class", "is", "returned", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/formats/__init__.py#L10-L17
train
RedHatInsights/insights-core
insights/parsers/nfs_exports.py
NFSExportsBase.all_options
def all_options(self): """Returns the set of all options used in all export entries""" items = chain.from_iterable(hosts.values() for hosts in self.data.values()) return set(chain.from_iterable(items))
python
def all_options(self): """Returns the set of all options used in all export entries""" items = chain.from_iterable(hosts.values() for hosts in self.data.values()) return set(chain.from_iterable(items))
[ "def", "all_options", "(", "self", ")", ":", "items", "=", "chain", ".", "from_iterable", "(", "hosts", ".", "values", "(", ")", "for", "hosts", "in", "self", ".", "data", ".", "values", "(", ")", ")", "return", "set", "(", "chain", ".", "from_iterab...
Returns the set of all options used in all export entries
[ "Returns", "the", "set", "of", "all", "options", "used", "in", "all", "export", "entries" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/parsers/nfs_exports.py#L133-L136
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection._init_session
def _init_session(self): """ Set up the session, auth is handled here """ session = requests.Session() session.headers = {'User-Agent': self.user_agent, 'Accept': 'application/json'} if self.systemid is not None: session.headers.upda...
python
def _init_session(self): """ Set up the session, auth is handled here """ session = requests.Session() session.headers = {'User-Agent': self.user_agent, 'Accept': 'application/json'} if self.systemid is not None: session.headers.upda...
[ "def", "_init_session", "(", "self", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "session", ".", "headers", "=", "{", "'User-Agent'", ":", "self", ".", "user_agent", ",", "'Accept'", ":", "'application/json'", "}", "if", "self", ".", ...
Set up the session, auth is handled here
[ "Set", "up", "the", "session", "auth", "is", "handled", "here" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L129-L169
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.handle_fail_rcs
def handle_fail_rcs(self, req): """ Bail out if we get a 401 and leave a message """ try: logger.debug("HTTP Status Code: %s", req.status_code) logger.debug("HTTP Response Text: %s", req.text) logger.debug("HTTP Response Reason: %s", req.reason) ...
python
def handle_fail_rcs(self, req): """ Bail out if we get a 401 and leave a message """ try: logger.debug("HTTP Status Code: %s", req.status_code) logger.debug("HTTP Response Text: %s", req.text) logger.debug("HTTP Response Reason: %s", req.reason) ...
[ "def", "handle_fail_rcs", "(", "self", ",", "req", ")", ":", "try", ":", "logger", ".", "debug", "(", "\"HTTP Status Code: %s\"", ",", "req", ".", "status_code", ")", "logger", ".", "debug", "(", "\"HTTP Response Text: %s\"", ",", "req", ".", "text", ")", ...
Bail out if we get a 401 and leave a message
[ "Bail", "out", "if", "we", "get", "a", "401", "and", "leave", "a", "message" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L352-L411
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.get_satellite5_info
def get_satellite5_info(self, branch_info): """ Get remote_leaf for Satellite 5 Managed box """ logger.debug( "Remote branch not -1 but remote leaf is -1, must be Satellite 5") if os.path.isfile('/etc/sysconfig/rhn/systemid'): logger.debug("Found systemid ...
python
def get_satellite5_info(self, branch_info): """ Get remote_leaf for Satellite 5 Managed box """ logger.debug( "Remote branch not -1 but remote leaf is -1, must be Satellite 5") if os.path.isfile('/etc/sysconfig/rhn/systemid'): logger.debug("Found systemid ...
[ "def", "get_satellite5_info", "(", "self", ",", "branch_info", ")", ":", "logger", ".", "debug", "(", "\"Remote branch not -1 but remote leaf is -1, must be Satellite 5\"", ")", "if", "os", ".", "path", ".", "isfile", "(", "'/etc/sysconfig/rhn/systemid'", ")", ":", "l...
Get remote_leaf for Satellite 5 Managed box
[ "Get", "remote_leaf", "for", "Satellite", "5", "Managed", "box" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L413-L432
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.get_branch_info
def get_branch_info(self): """ Retrieve branch_info from Satellite Server """ branch_info = None if os.path.exists(constants.cached_branch_info): # use cached branch info file if less than 10 minutes old # (failsafe, should be deleted at end of client run...
python
def get_branch_info(self): """ Retrieve branch_info from Satellite Server """ branch_info = None if os.path.exists(constants.cached_branch_info): # use cached branch info file if less than 10 minutes old # (failsafe, should be deleted at end of client run...
[ "def", "get_branch_info", "(", "self", ")", ":", "branch_info", "=", "None", "if", "os", ".", "path", ".", "exists", "(", "constants", ".", "cached_branch_info", ")", ":", "# use cached branch info file if less than 10 minutes old", "# (failsafe, should be deleted at end...
Retrieve branch_info from Satellite Server
[ "Retrieve", "branch_info", "from", "Satellite", "Server" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L434-L478
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.create_system
def create_system(self, new_machine_id=False): """ Create the machine via the API """ client_hostname = determine_hostname() machine_id = generate_machine_id(new_machine_id) branch_info = self.branch_info if not branch_info: return False remo...
python
def create_system(self, new_machine_id=False): """ Create the machine via the API """ client_hostname = determine_hostname() machine_id = generate_machine_id(new_machine_id) branch_info = self.branch_info if not branch_info: return False remo...
[ "def", "create_system", "(", "self", ",", "new_machine_id", "=", "False", ")", ":", "client_hostname", "=", "determine_hostname", "(", ")", "machine_id", "=", "generate_machine_id", "(", "new_machine_id", ")", "branch_info", "=", "self", ".", "branch_info", "if", ...
Create the machine via the API
[ "Create", "the", "machine", "via", "the", "API" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L481-L508
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.group_systems
def group_systems(self, group_name, systems): """ Adds an array of systems to specified group Args: group_name: Display name of group systems: Array of {'machine_id': machine_id} """ api_group_id = None headers = {'Content-Type': 'application/json...
python
def group_systems(self, group_name, systems): """ Adds an array of systems to specified group Args: group_name: Display name of group systems: Array of {'machine_id': machine_id} """ api_group_id = None headers = {'Content-Type': 'application/json...
[ "def", "group_systems", "(", "self", ",", "group_name", ",", "systems", ")", ":", "api_group_id", "=", "None", "headers", "=", "{", "'Content-Type'", ":", "'application/json'", "}", "group_path", "=", "self", ".", "api_url", "+", "'/v1/groups'", "group_get_path"...
Adds an array of systems to specified group Args: group_name: Display name of group systems: Array of {'machine_id': machine_id}
[ "Adds", "an", "array", "of", "systems", "to", "specified", "group" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L511-L552
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.do_group
def do_group(self): """ Do grouping on register """ group_id = self.config.group systems = {'machine_id': generate_machine_id()} self.group_systems(group_id, systems)
python
def do_group(self): """ Do grouping on register """ group_id = self.config.group systems = {'machine_id': generate_machine_id()} self.group_systems(group_id, systems)
[ "def", "do_group", "(", "self", ")", ":", "group_id", "=", "self", ".", "config", ".", "group", "systems", "=", "{", "'machine_id'", ":", "generate_machine_id", "(", ")", "}", "self", ".", "group_systems", "(", "group_id", ",", "systems", ")" ]
Do grouping on register
[ "Do", "grouping", "on", "register" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L556-L562
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection._legacy_api_registration_check
def _legacy_api_registration_check(self): ''' Check registration status through API ''' logger.debug('Checking registration status...') machine_id = generate_machine_id() try: url = self.api_url + '/v1/systems/' + machine_id net_logger.info("GET %s...
python
def _legacy_api_registration_check(self): ''' Check registration status through API ''' logger.debug('Checking registration status...') machine_id = generate_machine_id() try: url = self.api_url + '/v1/systems/' + machine_id net_logger.info("GET %s...
[ "def", "_legacy_api_registration_check", "(", "self", ")", ":", "logger", ".", "debug", "(", "'Checking registration status...'", ")", "machine_id", "=", "generate_machine_id", "(", ")", "try", ":", "url", "=", "self", ".", "api_url", "+", "'/v1/systems/'", "+", ...
Check registration status through API
[ "Check", "registration", "status", "through", "API" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L565-L602
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection._fetch_system_by_machine_id
def _fetch_system_by_machine_id(self): ''' Get a system by machine ID Returns dict system exists in inventory False system does not exist in inventory None error connection or parsing response ''' machine_id = generate_machine_id() ...
python
def _fetch_system_by_machine_id(self): ''' Get a system by machine ID Returns dict system exists in inventory False system does not exist in inventory None error connection or parsing response ''' machine_id = generate_machine_id() ...
[ "def", "_fetch_system_by_machine_id", "(", "self", ")", ":", "machine_id", "=", "generate_machine_id", "(", ")", "try", ":", "url", "=", "self", ".", "api_url", "+", "'/inventory/v1/hosts?insights_id='", "+", "machine_id", "net_logger", ".", "info", "(", "\"GET %s...
Get a system by machine ID Returns dict system exists in inventory False system does not exist in inventory None error connection or parsing response
[ "Get", "a", "system", "by", "machine", "ID", "Returns", "dict", "system", "exists", "in", "inventory", "False", "system", "does", "not", "exist", "in", "inventory", "None", "error", "connection", "or", "parsing", "response" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L604-L632
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.api_registration_check
def api_registration_check(self): ''' Reach out to the inventory API to check whether a machine exists. Returns True system exists in inventory False system does not exist in inventory None error connection or parsing r...
python
def api_registration_check(self): ''' Reach out to the inventory API to check whether a machine exists. Returns True system exists in inventory False system does not exist in inventory None error connection or parsing r...
[ "def", "api_registration_check", "(", "self", ")", ":", "if", "self", ".", "config", ".", "legacy_upload", ":", "return", "self", ".", "_legacy_api_registration_check", "(", ")", "logger", ".", "debug", "(", "'Checking registration status...'", ")", "results", "="...
Reach out to the inventory API to check whether a machine exists. Returns True system exists in inventory False system does not exist in inventory None error connection or parsing response
[ "Reach", "out", "to", "the", "inventory", "API", "to", "check", "whether", "a", "machine", "exists", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L634-L655
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.unregister
def unregister(self): """ Unregister this system from the insights service """ machine_id = generate_machine_id() try: logger.debug("Unregistering %s", machine_id) url = self.api_url + "/v1/systems/" + machine_id net_logger.info("DELETE %s", ur...
python
def unregister(self): """ Unregister this system from the insights service """ machine_id = generate_machine_id() try: logger.debug("Unregistering %s", machine_id) url = self.api_url + "/v1/systems/" + machine_id net_logger.info("DELETE %s", ur...
[ "def", "unregister", "(", "self", ")", ":", "machine_id", "=", "generate_machine_id", "(", ")", "try", ":", "logger", ".", "debug", "(", "\"Unregistering %s\"", ",", "machine_id", ")", "url", "=", "self", ".", "api_url", "+", "\"/v1/systems/\"", "+", "machin...
Unregister this system from the insights service
[ "Unregister", "this", "system", "from", "the", "insights", "service" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L658-L674
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.register
def register(self): """ Register this machine """ client_hostname = determine_hostname() # This will undo a blacklist logger.debug("API: Create system") system = self.create_system(new_machine_id=False) if system is False: return ('Could not re...
python
def register(self): """ Register this machine """ client_hostname = determine_hostname() # This will undo a blacklist logger.debug("API: Create system") system = self.create_system(new_machine_id=False) if system is False: return ('Could not re...
[ "def", "register", "(", "self", ")", ":", "client_hostname", "=", "determine_hostname", "(", ")", "# This will undo a blacklist", "logger", ".", "debug", "(", "\"API: Create system\"", ")", "system", "=", "self", ".", "create_system", "(", "new_machine_id", "=", "...
Register this machine
[ "Register", "this", "machine" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L677-L719
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection._legacy_upload_archive
def _legacy_upload_archive(self, data_collected, duration): ''' Do an HTTPS upload of the archive ''' file_name = os.path.basename(data_collected) try: from insights.contrib import magic m = magic.open(magic.MAGIC_MIME) m.load() mim...
python
def _legacy_upload_archive(self, data_collected, duration): ''' Do an HTTPS upload of the archive ''' file_name = os.path.basename(data_collected) try: from insights.contrib import magic m = magic.open(magic.MAGIC_MIME) m.load() mim...
[ "def", "_legacy_upload_archive", "(", "self", ",", "data_collected", ",", "duration", ")", ":", "file_name", "=", "os", ".", "path", ".", "basename", "(", "data_collected", ")", "try", ":", "from", "insights", ".", "contrib", "import", "magic", "m", "=", "...
Do an HTTPS upload of the archive
[ "Do", "an", "HTTPS", "upload", "of", "the", "archive" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L722-L766
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.upload_archive
def upload_archive(self, data_collected, content_type, duration): """ Do an HTTPS Upload of the archive """ if self.config.legacy_upload: return self._legacy_upload_archive(data_collected, duration) file_name = os.path.basename(data_collected) upload_url = sel...
python
def upload_archive(self, data_collected, content_type, duration): """ Do an HTTPS Upload of the archive """ if self.config.legacy_upload: return self._legacy_upload_archive(data_collected, duration) file_name = os.path.basename(data_collected) upload_url = sel...
[ "def", "upload_archive", "(", "self", ",", "data_collected", ",", "content_type", ",", "duration", ")", ":", "if", "self", ".", "config", ".", "legacy_upload", ":", "return", "self", ".", "_legacy_upload_archive", "(", "data_collected", ",", "duration", ")", "...
Do an HTTPS Upload of the archive
[ "Do", "an", "HTTPS", "Upload", "of", "the", "archive" ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L768-L811
train
RedHatInsights/insights-core
insights/client/connection.py
InsightsConnection.set_display_name
def set_display_name(self, display_name): ''' Set display name of a system independently of upload. ''' if self.config.legacy_upload: return self._legacy_set_display_name(display_name) system = self._fetch_system_by_machine_id() if not system: ret...
python
def set_display_name(self, display_name): ''' Set display name of a system independently of upload. ''' if self.config.legacy_upload: return self._legacy_set_display_name(display_name) system = self._fetch_system_by_machine_id() if not system: ret...
[ "def", "set_display_name", "(", "self", ",", "display_name", ")", ":", "if", "self", ".", "config", ".", "legacy_upload", ":", "return", "self", ".", "_legacy_set_display_name", "(", "display_name", ")", "system", "=", "self", ".", "_fetch_system_by_machine_id", ...
Set display name of a system independently of upload.
[ "Set", "display", "name", "of", "a", "system", "independently", "of", "upload", "." ]
b57cbf8ed7c089672426ede0441e0a4f789ef4a1
https://github.com/RedHatInsights/insights-core/blob/b57cbf8ed7c089672426ede0441e0a4f789ef4a1/insights/client/connection.py#L851-L874
train