id int32 0 252k | repo stringlengths 7 55 | path stringlengths 4 127 | func_name stringlengths 1 88 | original_string stringlengths 75 19.8k | language stringclasses 1
value | code stringlengths 75 19.8k | code_tokens list | docstring stringlengths 3 17.3k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 87 242 |
|---|---|---|---|---|---|---|---|---|---|---|---|
10,200 | riptano/ccm | ccmlib/common.py | is_modern_windows_install | def is_modern_windows_install(version):
"""
The 2.1 release line was when Cassandra received beta windows support.
Many features are gated based on that added compatibility.
Handles floats, strings, and LooseVersions by first converting all three types to a string, then to a LooseVersion.
"""
v... | python | def is_modern_windows_install(version):
"""
The 2.1 release line was when Cassandra received beta windows support.
Many features are gated based on that added compatibility.
Handles floats, strings, and LooseVersions by first converting all three types to a string, then to a LooseVersion.
"""
v... | [
"def",
"is_modern_windows_install",
"(",
"version",
")",
":",
"version",
"=",
"LooseVersion",
"(",
"str",
"(",
"version",
")",
")",
"if",
"is_win",
"(",
")",
"and",
"version",
">=",
"LooseVersion",
"(",
"'2.1'",
")",
":",
"return",
"True",
"else",
":",
"... | The 2.1 release line was when Cassandra received beta windows support.
Many features are gated based on that added compatibility.
Handles floats, strings, and LooseVersions by first converting all three types to a string, then to a LooseVersion. | [
"The",
"2",
".",
"1",
"release",
"line",
"was",
"when",
"Cassandra",
"received",
"beta",
"windows",
"support",
".",
"Many",
"features",
"are",
"gated",
"based",
"on",
"that",
"added",
"compatibility",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/common.py#L354-L365 |
10,201 | riptano/ccm | ccmlib/common.py | get_jdk_version | def get_jdk_version():
"""
Retrieve the Java version as reported in the quoted string returned
by invoking 'java -version'.
Works for Java 1.8, Java 9 and should also be fine for Java 10.
"""
try:
version = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)
exce... | python | def get_jdk_version():
"""
Retrieve the Java version as reported in the quoted string returned
by invoking 'java -version'.
Works for Java 1.8, Java 9 and should also be fine for Java 10.
"""
try:
version = subprocess.check_output(['java', '-version'], stderr=subprocess.STDOUT)
exce... | [
"def",
"get_jdk_version",
"(",
")",
":",
"try",
":",
"version",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"'java'",
",",
"'-version'",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"except",
"OSError",
":",
"print_",
"(",
"\"ERROR: Cou... | Retrieve the Java version as reported in the quoted string returned
by invoking 'java -version'.
Works for Java 1.8, Java 9 and should also be fine for Java 10. | [
"Retrieve",
"the",
"Java",
"version",
"as",
"reported",
"in",
"the",
"quoted",
"string",
"returned",
"by",
"invoking",
"java",
"-",
"version",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/common.py#L706-L719 |
10,202 | riptano/ccm | ccmlib/common.py | wait_for_any_log | def wait_for_any_log(nodes, pattern, timeout, filename='system.log', marks=None):
"""
Look for a pattern in the system.log of any in a given list
of nodes.
@param nodes The list of nodes whose logs to scan
@param pattern The target pattern
@param timeout How long to wait for the pattern. Note th... | python | def wait_for_any_log(nodes, pattern, timeout, filename='system.log', marks=None):
"""
Look for a pattern in the system.log of any in a given list
of nodes.
@param nodes The list of nodes whose logs to scan
@param pattern The target pattern
@param timeout How long to wait for the pattern. Note th... | [
"def",
"wait_for_any_log",
"(",
"nodes",
",",
"pattern",
",",
"timeout",
",",
"filename",
"=",
"'system.log'",
",",
"marks",
"=",
"None",
")",
":",
"if",
"marks",
"is",
"None",
":",
"marks",
"=",
"{",
"}",
"for",
"_",
"in",
"range",
"(",
"timeout",
"... | Look for a pattern in the system.log of any in a given list
of nodes.
@param nodes The list of nodes whose logs to scan
@param pattern The target pattern
@param timeout How long to wait for the pattern. Note that
strictly speaking, timeout is not really a timeout,
... | [
"Look",
"for",
"a",
"pattern",
"in",
"the",
"system",
".",
"log",
"of",
"any",
"in",
"a",
"given",
"list",
"of",
"nodes",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/common.py#L769-L793 |
10,203 | riptano/ccm | ccmlib/repository.py | download_version | def download_version(version, url=None, verbose=False, binary=False):
"""Download, extract, and build Cassandra tarball.
if binary == True, download precompiled tarball, otherwise build from source tarball.
"""
assert_jdk_valid_for_cassandra_version(version)
archive_url = ARCHIVE
if CCM_CONFIG... | python | def download_version(version, url=None, verbose=False, binary=False):
"""Download, extract, and build Cassandra tarball.
if binary == True, download precompiled tarball, otherwise build from source tarball.
"""
assert_jdk_valid_for_cassandra_version(version)
archive_url = ARCHIVE
if CCM_CONFIG... | [
"def",
"download_version",
"(",
"version",
",",
"url",
"=",
"None",
",",
"verbose",
"=",
"False",
",",
"binary",
"=",
"False",
")",
":",
"assert_jdk_valid_for_cassandra_version",
"(",
"version",
")",
"archive_url",
"=",
"ARCHIVE",
"if",
"CCM_CONFIG",
".",
"has... | Download, extract, and build Cassandra tarball.
if binary == True, download precompiled tarball, otherwise build from source tarball. | [
"Download",
"extract",
"and",
"build",
"Cassandra",
"tarball",
"."
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/repository.py#L331-L381 |
10,204 | riptano/ccm | ccmlib/repository.py | get_tagged_version_numbers | def get_tagged_version_numbers(series='stable'):
"""Retrieve git tags and find version numbers for a release series
series - 'stable', 'oldstable', or 'testing'"""
releases = []
if series == 'testing':
# Testing releases always have a hyphen after the version number:
tag_regex = re.comp... | python | def get_tagged_version_numbers(series='stable'):
"""Retrieve git tags and find version numbers for a release series
series - 'stable', 'oldstable', or 'testing'"""
releases = []
if series == 'testing':
# Testing releases always have a hyphen after the version number:
tag_regex = re.comp... | [
"def",
"get_tagged_version_numbers",
"(",
"series",
"=",
"'stable'",
")",
":",
"releases",
"=",
"[",
"]",
"if",
"series",
"==",
"'testing'",
":",
"# Testing releases always have a hyphen after the version number:",
"tag_regex",
"=",
"re",
".",
"compile",
"(",
"'^refs/... | Retrieve git tags and find version numbers for a release series
series - 'stable', 'oldstable', or 'testing | [
"Retrieve",
"git",
"tags",
"and",
"find",
"version",
"numbers",
"for",
"a",
"release",
"series"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/repository.py#L477-L511 |
10,205 | riptano/ccm | ccmlib/remote.py | SSHClient.__connect | def __connect(host, port, username, password, private_key):
"""
Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credential... | python | def __connect(host, port, username, password, private_key):
"""
Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credential... | [
"def",
"__connect",
"(",
"host",
",",
"port",
",",
"username",
",",
"password",
",",
"private_key",
")",
":",
"# Initialize the SSH connection",
"ssh",
"=",
"paramiko",
".",
"SSHClient",
"(",
")",
"ssh",
".",
"set_missing_host_key_policy",
"(",
"paramiko",
".",
... | Establish remote connection
:param host: Hostname or IP address to connect to
:param port: Port number to use for SSH
:param username: Username credentials for SSH access
:param password: Password credentials for SSH access (or private key passphrase)
:param private_key: Private... | [
"Establish",
"remote",
"connection"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L142-L169 |
10,206 | riptano/ccm | ccmlib/remote.py | SSHClient.execute_ccm_command | def execute_ccm_command(self, ccm_args, is_displayed=True):
"""
Execute a CCM command on the remote server
:param ccm_args: CCM arguments to execute remotely
:param is_displayed: True if information should be display; false to return output
(default: true)
... | python | def execute_ccm_command(self, ccm_args, is_displayed=True):
"""
Execute a CCM command on the remote server
:param ccm_args: CCM arguments to execute remotely
:param is_displayed: True if information should be display; false to return output
(default: true)
... | [
"def",
"execute_ccm_command",
"(",
"self",
",",
"ccm_args",
",",
"is_displayed",
"=",
"True",
")",
":",
"return",
"self",
".",
"execute",
"(",
"[",
"\"ccm\"",
"]",
"+",
"ccm_args",
",",
"profile",
"=",
"self",
".",
"profile",
")"
] | Execute a CCM command on the remote server
:param ccm_args: CCM arguments to execute remotely
:param is_displayed: True if information should be display; false to return output
(default: true)
:return: A tuple defining the execution of the command
... | [
"Execute",
"a",
"CCM",
"command",
"on",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L244-L255 |
10,207 | riptano/ccm | ccmlib/remote.py | SSHClient.execute_python_script | def execute_python_script(self, script):
"""
Execute a python script of the remote server
:param script: Inline script to convert to a file and execute remotely
:return: The output of the script execution
"""
# Create the local file to copy to remote
file_handle,... | python | def execute_python_script(self, script):
"""
Execute a python script of the remote server
:param script: Inline script to convert to a file and execute remotely
:return: The output of the script execution
"""
# Create the local file to copy to remote
file_handle,... | [
"def",
"execute_python_script",
"(",
"self",
",",
"script",
")",
":",
"# Create the local file to copy to remote",
"file_handle",
",",
"filename",
"=",
"tempfile",
".",
"mkstemp",
"(",
")",
"temp_file",
"=",
"os",
".",
"fdopen",
"(",
"file_handle",
",",
"\"wt\"",
... | Execute a python script of the remote server
:param script: Inline script to convert to a file and execute remotely
:return: The output of the script execution | [
"Execute",
"a",
"python",
"script",
"of",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L257-L278 |
10,208 | riptano/ccm | ccmlib/remote.py | SSHClient.__put_dir | def __put_dir(self, ftp, local_path, remote_path=None):
"""
Helper function to perform copy operation to remote server
:param ftp: SFTP handle to perform copy operation(s)
:param local_path: Local path to copy to; can be file or directory
:param remote_path: Remote path to copy ... | python | def __put_dir(self, ftp, local_path, remote_path=None):
"""
Helper function to perform copy operation to remote server
:param ftp: SFTP handle to perform copy operation(s)
:param local_path: Local path to copy to; can be file or directory
:param remote_path: Remote path to copy ... | [
"def",
"__put_dir",
"(",
"self",
",",
"ftp",
",",
"local_path",
",",
"remote_path",
"=",
"None",
")",
":",
"# Determine if local_path should be put into remote user directory",
"if",
"remote_path",
"is",
"None",
":",
"remote_path",
"=",
"os",
".",
"path",
".",
"ba... | Helper function to perform copy operation to remote server
:param ftp: SFTP handle to perform copy operation(s)
:param local_path: Local path to copy to; can be file or directory
:param remote_path: Remote path to copy to (default: None - Copies file or directory to
... | [
"Helper",
"function",
"to",
"perform",
"copy",
"operation",
"to",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L299-L326 |
10,209 | riptano/ccm | ccmlib/remote.py | SSHClient.remove | def remove(self, remote_path):
"""
Delete a file or directory recursively on the remote server
:param remote_path: Remote path to remove
"""
# Based on the remote file stats; remove a file or directory recursively
ftp = self.ssh.open_sftp()
if stat.S_ISDIR(ftp.st... | python | def remove(self, remote_path):
"""
Delete a file or directory recursively on the remote server
:param remote_path: Remote path to remove
"""
# Based on the remote file stats; remove a file or directory recursively
ftp = self.ssh.open_sftp()
if stat.S_ISDIR(ftp.st... | [
"def",
"remove",
"(",
"self",
",",
"remote_path",
")",
":",
"# Based on the remote file stats; remove a file or directory recursively",
"ftp",
"=",
"self",
".",
"ssh",
".",
"open_sftp",
"(",
")",
"if",
"stat",
".",
"S_ISDIR",
"(",
"ftp",
".",
"stat",
"(",
"remot... | Delete a file or directory recursively on the remote server
:param remote_path: Remote path to remove | [
"Delete",
"a",
"file",
"or",
"directory",
"recursively",
"on",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L328-L340 |
10,210 | riptano/ccm | ccmlib/remote.py | SSHClient.__remove_dir | def __remove_dir(self, ftp, remote_path):
"""
Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove
"""
# Iterate over the remote path and perform remove operation... | python | def __remove_dir(self, ftp, remote_path):
"""
Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove
"""
# Iterate over the remote path and perform remove operation... | [
"def",
"__remove_dir",
"(",
"self",
",",
"ftp",
",",
"remote_path",
")",
":",
"# Iterate over the remote path and perform remove operations",
"files",
"=",
"ftp",
".",
"listdir",
"(",
"remote_path",
")",
"for",
"filename",
"in",
"files",
":",
"# Attempt to remove the ... | Helper function to perform delete operation on the remote server
:param ftp: SFTP handle to perform delete operation(s)
:param remote_path: Remote path to remove | [
"Helper",
"function",
"to",
"perform",
"delete",
"operation",
"on",
"the",
"remote",
"server"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L342-L360 |
10,211 | riptano/ccm | ccmlib/remote.py | RemoteOptionsParser.usage | def usage(self):
"""
Get the usage for the remote exectuion options
:return Usage for the remote execution options
"""
# Retrieve the text for just the arguments
usage = self.parser.format_help().split("optional arguments:")[1]
# Remove any blank lines and retur... | python | def usage(self):
"""
Get the usage for the remote exectuion options
:return Usage for the remote execution options
"""
# Retrieve the text for just the arguments
usage = self.parser.format_help().split("optional arguments:")[1]
# Remove any blank lines and retur... | [
"def",
"usage",
"(",
"self",
")",
":",
"# Retrieve the text for just the arguments",
"usage",
"=",
"self",
".",
"parser",
".",
"format_help",
"(",
")",
".",
"split",
"(",
"\"optional arguments:\"",
")",
"[",
"1",
"]",
"# Remove any blank lines and return",
"return",... | Get the usage for the remote exectuion options
:return Usage for the remote execution options | [
"Get",
"the",
"usage",
"for",
"the",
"remote",
"exectuion",
"options"
] | 275699f79d102b5039b79cc17fa6305dccf18412 | https://github.com/riptano/ccm/blob/275699f79d102b5039b79cc17fa6305dccf18412/ccmlib/remote.py#L490-L501 |
10,212 | mattupstate/flask-jwt | flask_jwt/__init__.py | jwt_required | def jwt_required(realm=None):
"""View decorator that requires a valid JWT token to be present in the request
:param realm: an optional realm
"""
def wrapper(fn):
@wraps(fn)
def decorator(*args, **kwargs):
_jwt_required(realm or current_app.config['JWT_DEFAULT_REALM'])
... | python | def jwt_required(realm=None):
"""View decorator that requires a valid JWT token to be present in the request
:param realm: an optional realm
"""
def wrapper(fn):
@wraps(fn)
def decorator(*args, **kwargs):
_jwt_required(realm or current_app.config['JWT_DEFAULT_REALM'])
... | [
"def",
"jwt_required",
"(",
"realm",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"decorator",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_jwt_required",
"(",
"realm",
"or",
"current_... | View decorator that requires a valid JWT token to be present in the request
:param realm: an optional realm | [
"View",
"decorator",
"that",
"requires",
"a",
"valid",
"JWT",
"token",
"to",
"be",
"present",
"in",
"the",
"request"
] | c27084114e258863b82753fc574a362cd6c62fcd | https://github.com/mattupstate/flask-jwt/blob/c27084114e258863b82753fc574a362cd6c62fcd/flask_jwt/__init__.py#L168-L179 |
10,213 | mattupstate/flask-jwt | flask_jwt/__init__.py | JWT.auth_request_handler | def auth_request_handler(self, callback):
"""Specifies the authentication response handler function.
:param callable callback: the auth request handler function
.. deprecated
"""
warnings.warn("This handler is deprecated. The recommended approach to have control over "
... | python | def auth_request_handler(self, callback):
"""Specifies the authentication response handler function.
:param callable callback: the auth request handler function
.. deprecated
"""
warnings.warn("This handler is deprecated. The recommended approach to have control over "
... | [
"def",
"auth_request_handler",
"(",
"self",
",",
"callback",
")",
":",
"warnings",
".",
"warn",
"(",
"\"This handler is deprecated. The recommended approach to have control over \"",
"\"the authentication resource is to disable the built-in resource by \"",
"\"setting JWT_AUTH_URL_RULE=... | Specifies the authentication response handler function.
:param callable callback: the auth request handler function
.. deprecated | [
"Specifies",
"the",
"authentication",
"response",
"handler",
"function",
"."
] | c27084114e258863b82753fc574a362cd6c62fcd | https://github.com/mattupstate/flask-jwt/blob/c27084114e258863b82753fc574a362cd6c62fcd/flask_jwt/__init__.py#L294-L306 |
10,214 | jwass/mplleaflet | mplleaflet/leaflet_renderer.py | LeafletRenderer._svg_path | def _svg_path(self, pathcodes, data):
"""
Return the SVG path's 'd' element.
"""
def gen_path_elements(pathcodes, data):
counts = {'M': 1, 'L': 1, 'C': 3, 'Z': 0}
it = iter(data)
for code in pathcodes:
yield code
for _ ... | python | def _svg_path(self, pathcodes, data):
"""
Return the SVG path's 'd' element.
"""
def gen_path_elements(pathcodes, data):
counts = {'M': 1, 'L': 1, 'C': 3, 'Z': 0}
it = iter(data)
for code in pathcodes:
yield code
for _ ... | [
"def",
"_svg_path",
"(",
"self",
",",
"pathcodes",
",",
"data",
")",
":",
"def",
"gen_path_elements",
"(",
"pathcodes",
",",
"data",
")",
":",
"counts",
"=",
"{",
"'M'",
":",
"1",
",",
"'L'",
":",
"1",
",",
"'C'",
":",
"3",
",",
"'Z'",
":",
"0",
... | Return the SVG path's 'd' element. | [
"Return",
"the",
"SVG",
"path",
"s",
"d",
"element",
"."
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/leaflet_renderer.py#L69-L84 |
10,215 | jwass/mplleaflet | mplleaflet/_display.py | fig_to_html | def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
epsg=None, embed_links=False, float_precision=6):
"""
Convert a Matplotlib Figure to a Leaflet map
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
template : string, def... | python | def fig_to_html(fig=None, template='base.html', tiles=None, crs=None,
epsg=None, embed_links=False, float_precision=6):
"""
Convert a Matplotlib Figure to a Leaflet map
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
template : string, def... | [
"def",
"fig_to_html",
"(",
"fig",
"=",
"None",
",",
"template",
"=",
"'base.html'",
",",
"tiles",
"=",
"None",
",",
"crs",
"=",
"None",
",",
"epsg",
"=",
"None",
",",
"embed_links",
"=",
"False",
",",
"float_precision",
"=",
"6",
")",
":",
"if",
"til... | Convert a Matplotlib Figure to a Leaflet map
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
template : string, default 'base.html'
The Jinja2 template to use
tiles : string or tuple
The tiles argument is used to control the map tile source in... | [
"Convert",
"a",
"Matplotlib",
"Figure",
"to",
"a",
"Leaflet",
"map"
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L27-L107 |
10,216 | jwass/mplleaflet | mplleaflet/_display.py | fig_to_geojson | def fig_to_geojson(fig=None, **kwargs):
"""
Returns a figure's GeoJSON representation as a dictionary
All arguments passed to fig_to_html()
Returns
-------
GeoJSON dictionary
"""
if fig is None:
fig = plt.gcf()
renderer = LeafletRenderer(**kwargs)
exporter = Exporter(r... | python | def fig_to_geojson(fig=None, **kwargs):
"""
Returns a figure's GeoJSON representation as a dictionary
All arguments passed to fig_to_html()
Returns
-------
GeoJSON dictionary
"""
if fig is None:
fig = plt.gcf()
renderer = LeafletRenderer(**kwargs)
exporter = Exporter(r... | [
"def",
"fig_to_geojson",
"(",
"fig",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"fig",
"is",
"None",
":",
"fig",
"=",
"plt",
".",
"gcf",
"(",
")",
"renderer",
"=",
"LeafletRenderer",
"(",
"*",
"*",
"kwargs",
")",
"exporter",
"=",
"Export... | Returns a figure's GeoJSON representation as a dictionary
All arguments passed to fig_to_html()
Returns
-------
GeoJSON dictionary | [
"Returns",
"a",
"figure",
"s",
"GeoJSON",
"representation",
"as",
"a",
"dictionary"
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L110-L127 |
10,217 | jwass/mplleaflet | mplleaflet/_display.py | display | def display(fig=None, closefig=True, **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Embed in IPython notebook.
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
closefig : boolean, default True
Close the current Figure
"""
from... | python | def display(fig=None, closefig=True, **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Embed in IPython notebook.
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
closefig : boolean, default True
Close the current Figure
"""
from... | [
"def",
"display",
"(",
"fig",
"=",
"None",
",",
"closefig",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"from",
"IPython",
".",
"display",
"import",
"HTML",
"if",
"fig",
"is",
"None",
":",
"fig",
"=",
"plt",
".",
"gcf",
"(",
")",
"if",
"close... | Convert a Matplotlib Figure to a Leaflet map. Embed in IPython notebook.
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
closefig : boolean, default True
Close the current Figure | [
"Convert",
"a",
"Matplotlib",
"Figure",
"to",
"a",
"Leaflet",
"map",
".",
"Embed",
"in",
"IPython",
"notebook",
"."
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L140-L165 |
10,218 | jwass/mplleaflet | mplleaflet/_display.py | show | def show(fig=None, path='_map.html', **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Open in a browser
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
path : string, default '_map.html'
Filename where output html will be saved
Se... | python | def show(fig=None, path='_map.html', **kwargs):
"""
Convert a Matplotlib Figure to a Leaflet map. Open in a browser
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
path : string, default '_map.html'
Filename where output html will be saved
Se... | [
"def",
"show",
"(",
"fig",
"=",
"None",
",",
"path",
"=",
"'_map.html'",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"webbrowser",
"fullpath",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"path",
")",
"with",
"open",
"(",
"fullpath",
",",
"'w'",
"... | Convert a Matplotlib Figure to a Leaflet map. Open in a browser
Parameters
----------
fig : figure, default gcf()
Figure used to convert to map
path : string, default '_map.html'
Filename where output html will be saved
See fig_to_html() for description of keyword args. | [
"Convert",
"a",
"Matplotlib",
"Figure",
"to",
"a",
"Leaflet",
"map",
".",
"Open",
"in",
"a",
"browser"
] | a83d7b69c56d5507dd7c17f5be377d23a31e84ab | https://github.com/jwass/mplleaflet/blob/a83d7b69c56d5507dd7c17f5be377d23a31e84ab/mplleaflet/_display.py#L167-L185 |
10,219 | dmsimard/python-cachetclient | contrib/sensu-cachet.py | create_incident | def create_incident(**kwargs):
"""
Creates an incident
"""
incidents = cachet.Incidents(endpoint=ENDPOINT, api_token=API_TOKEN)
if 'component_id' in kwargs:
return incidents.post(name=kwargs['name'],
message=kwargs['message'],
statu... | python | def create_incident(**kwargs):
"""
Creates an incident
"""
incidents = cachet.Incidents(endpoint=ENDPOINT, api_token=API_TOKEN)
if 'component_id' in kwargs:
return incidents.post(name=kwargs['name'],
message=kwargs['message'],
statu... | [
"def",
"create_incident",
"(",
"*",
"*",
"kwargs",
")",
":",
"incidents",
"=",
"cachet",
".",
"Incidents",
"(",
"endpoint",
"=",
"ENDPOINT",
",",
"api_token",
"=",
"API_TOKEN",
")",
"if",
"'component_id'",
"in",
"kwargs",
":",
"return",
"incidents",
".",
"... | Creates an incident | [
"Creates",
"an",
"incident"
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/contrib/sensu-cachet.py#L110-L124 |
10,220 | dmsimard/python-cachetclient | contrib/sensu-cachet.py | incident_exists | def incident_exists(name, message, status):
"""
Check if an incident with these attributes already exists
"""
incidents = cachet.Incidents(endpoint=ENDPOINT)
all_incidents = json.loads(incidents.get())
for incident in all_incidents['data']:
if name == incident['name'] and \
st... | python | def incident_exists(name, message, status):
"""
Check if an incident with these attributes already exists
"""
incidents = cachet.Incidents(endpoint=ENDPOINT)
all_incidents = json.loads(incidents.get())
for incident in all_incidents['data']:
if name == incident['name'] and \
st... | [
"def",
"incident_exists",
"(",
"name",
",",
"message",
",",
"status",
")",
":",
"incidents",
"=",
"cachet",
".",
"Incidents",
"(",
"endpoint",
"=",
"ENDPOINT",
")",
"all_incidents",
"=",
"json",
".",
"loads",
"(",
"incidents",
".",
"get",
"(",
")",
")",
... | Check if an incident with these attributes already exists | [
"Check",
"if",
"an",
"incident",
"with",
"these",
"attributes",
"already",
"exists"
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/contrib/sensu-cachet.py#L127-L138 |
10,221 | dmsimard/python-cachetclient | contrib/sensu-cachet.py | get_component | def get_component(id):
"""
Gets a Cachet component by id
"""
components = cachet.Components(endpoint=ENDPOINT)
component = json.loads(components.get(id=id))
return component['data'] | python | def get_component(id):
"""
Gets a Cachet component by id
"""
components = cachet.Components(endpoint=ENDPOINT)
component = json.loads(components.get(id=id))
return component['data'] | [
"def",
"get_component",
"(",
"id",
")",
":",
"components",
"=",
"cachet",
".",
"Components",
"(",
"endpoint",
"=",
"ENDPOINT",
")",
"component",
"=",
"json",
".",
"loads",
"(",
"components",
".",
"get",
"(",
"id",
"=",
"id",
")",
")",
"return",
"compon... | Gets a Cachet component by id | [
"Gets",
"a",
"Cachet",
"component",
"by",
"id"
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/contrib/sensu-cachet.py#L141-L147 |
10,222 | dmsimard/python-cachetclient | cachetclient/cachet.py | api_token_required | def api_token_required(f, *args, **kwargs):
"""
Decorator helper function to ensure some methods aren't needlessly called
without an api_token configured.
"""
try:
if args[0].api_token is None:
raise AttributeError('Parameter api_token is required.')
except AttributeError:
... | python | def api_token_required(f, *args, **kwargs):
"""
Decorator helper function to ensure some methods aren't needlessly called
without an api_token configured.
"""
try:
if args[0].api_token is None:
raise AttributeError('Parameter api_token is required.')
except AttributeError:
... | [
"def",
"api_token_required",
"(",
"f",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"if",
"args",
"[",
"0",
"]",
".",
"api_token",
"is",
"None",
":",
"raise",
"AttributeError",
"(",
"'Parameter api_token is required.'",
")",
"except",
... | Decorator helper function to ensure some methods aren't needlessly called
without an api_token configured. | [
"Decorator",
"helper",
"function",
"to",
"ensure",
"some",
"methods",
"aren",
"t",
"needlessly",
"called",
"without",
"an",
"api_token",
"configured",
"."
] | 31bbc6d17ba5de088846e1ffae259b6755e672a0 | https://github.com/dmsimard/python-cachetclient/blob/31bbc6d17ba5de088846e1ffae259b6755e672a0/cachetclient/cachet.py#L23-L34 |
10,223 | robdmc/behold | behold/logger.py | Behold.is_true | def is_true(self, item=None):
"""
If you are filtering on object values, you need to pass that object here.
"""
if item:
values = [item]
else:
values = []
self._get_item_and_att_names(*values)
return self._passes_all | python | def is_true(self, item=None):
"""
If you are filtering on object values, you need to pass that object here.
"""
if item:
values = [item]
else:
values = []
self._get_item_and_att_names(*values)
return self._passes_all | [
"def",
"is_true",
"(",
"self",
",",
"item",
"=",
"None",
")",
":",
"if",
"item",
":",
"values",
"=",
"[",
"item",
"]",
"else",
":",
"values",
"=",
"[",
"]",
"self",
".",
"_get_item_and_att_names",
"(",
"*",
"values",
")",
"return",
"self",
".",
"_p... | If you are filtering on object values, you need to pass that object here. | [
"If",
"you",
"are",
"filtering",
"on",
"object",
"values",
"you",
"need",
"to",
"pass",
"that",
"object",
"here",
"."
] | ac1b7707e2d7472a50d837dda78be1e23af8fce5 | https://github.com/robdmc/behold/blob/ac1b7707e2d7472a50d837dda78be1e23af8fce5/behold/logger.py#L519-L528 |
10,224 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | WebPage.new_from_url | def new_from_url(cls, url, verify=True):
"""
Constructs a new WebPage object for the URL,
using the `requests` module to fetch the HTML.
Parameters
----------
url : str
verify: bool
"""
response = requests.get(url, verify=verify, timeout=2.5)
... | python | def new_from_url(cls, url, verify=True):
"""
Constructs a new WebPage object for the URL,
using the `requests` module to fetch the HTML.
Parameters
----------
url : str
verify: bool
"""
response = requests.get(url, verify=verify, timeout=2.5)
... | [
"def",
"new_from_url",
"(",
"cls",
",",
"url",
",",
"verify",
"=",
"True",
")",
":",
"response",
"=",
"requests",
".",
"get",
"(",
"url",
",",
"verify",
"=",
"verify",
",",
"timeout",
"=",
"2.5",
")",
"return",
"cls",
".",
"new_from_response",
"(",
"... | Constructs a new WebPage object for the URL,
using the `requests` module to fetch the HTML.
Parameters
----------
url : str
verify: bool | [
"Constructs",
"a",
"new",
"WebPage",
"object",
"for",
"the",
"URL",
"using",
"the",
"requests",
"module",
"to",
"fetch",
"the",
"HTML",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L66-L78 |
10,225 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | WebPage.new_from_response | def new_from_response(cls, response):
"""
Constructs a new WebPage object for the response,
using the `BeautifulSoup` module to parse the HTML.
Parameters
----------
response : requests.Response object
"""
return cls(response.url, html=response.text, hea... | python | def new_from_response(cls, response):
"""
Constructs a new WebPage object for the response,
using the `BeautifulSoup` module to parse the HTML.
Parameters
----------
response : requests.Response object
"""
return cls(response.url, html=response.text, hea... | [
"def",
"new_from_response",
"(",
"cls",
",",
"response",
")",
":",
"return",
"cls",
"(",
"response",
".",
"url",
",",
"html",
"=",
"response",
".",
"text",
",",
"headers",
"=",
"response",
".",
"headers",
")"
] | Constructs a new WebPage object for the response,
using the `BeautifulSoup` module to parse the HTML.
Parameters
----------
response : requests.Response object | [
"Constructs",
"a",
"new",
"WebPage",
"object",
"for",
"the",
"response",
"using",
"the",
"BeautifulSoup",
"module",
"to",
"parse",
"the",
"HTML",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L81-L91 |
10,226 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer._prepare_app | def _prepare_app(self, app):
"""
Normalize app data, preparing it for the detection phase.
"""
# Ensure these keys' values are lists
for key in ['url', 'html', 'script', 'implies']:
try:
value = app[key]
except KeyError:
ap... | python | def _prepare_app(self, app):
"""
Normalize app data, preparing it for the detection phase.
"""
# Ensure these keys' values are lists
for key in ['url', 'html', 'script', 'implies']:
try:
value = app[key]
except KeyError:
ap... | [
"def",
"_prepare_app",
"(",
"self",
",",
"app",
")",
":",
"# Ensure these keys' values are lists",
"for",
"key",
"in",
"[",
"'url'",
",",
"'html'",
",",
"'script'",
",",
"'implies'",
"]",
":",
"try",
":",
"value",
"=",
"app",
"[",
"key",
"]",
"except",
"... | Normalize app data, preparing it for the detection phase. | [
"Normalize",
"app",
"data",
"preparing",
"it",
"for",
"the",
"detection",
"phase",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L131-L170 |
10,227 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer._has_app | def _has_app(self, app, webpage):
"""
Determine whether the web page matches the app signature.
"""
# Search the easiest things first and save the full-text search of the
# HTML for last
for regex in app['url']:
if regex.search(webpage.url):
r... | python | def _has_app(self, app, webpage):
"""
Determine whether the web page matches the app signature.
"""
# Search the easiest things first and save the full-text search of the
# HTML for last
for regex in app['url']:
if regex.search(webpage.url):
r... | [
"def",
"_has_app",
"(",
"self",
",",
"app",
",",
"webpage",
")",
":",
"# Search the easiest things first and save the full-text search of the",
"# HTML for last",
"for",
"regex",
"in",
"app",
"[",
"'url'",
"]",
":",
"if",
"regex",
".",
"search",
"(",
"webpage",
".... | Determine whether the web page matches the app signature. | [
"Determine",
"whether",
"the",
"web",
"page",
"matches",
"the",
"app",
"signature",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L189-L219 |
10,228 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer._get_implied_apps | def _get_implied_apps(self, detected_apps):
"""
Get the set of apps implied by `detected_apps`.
"""
def __get_implied_apps(apps):
_implied_apps = set()
for app in apps:
try:
_implied_apps.update(set(self.apps[app]['implies']))
... | python | def _get_implied_apps(self, detected_apps):
"""
Get the set of apps implied by `detected_apps`.
"""
def __get_implied_apps(apps):
_implied_apps = set()
for app in apps:
try:
_implied_apps.update(set(self.apps[app]['implies']))
... | [
"def",
"_get_implied_apps",
"(",
"self",
",",
"detected_apps",
")",
":",
"def",
"__get_implied_apps",
"(",
"apps",
")",
":",
"_implied_apps",
"=",
"set",
"(",
")",
"for",
"app",
"in",
"apps",
":",
"try",
":",
"_implied_apps",
".",
"update",
"(",
"set",
"... | Get the set of apps implied by `detected_apps`. | [
"Get",
"the",
"set",
"of",
"apps",
"implied",
"by",
"detected_apps",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L221-L242 |
10,229 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer.get_categories | def get_categories(self, app_name):
"""
Returns a list of the categories for an app name.
"""
cat_nums = self.apps.get(app_name, {}).get("cats", [])
cat_names = [self.categories.get("%s" % cat_num, "")
for cat_num in cat_nums]
return cat_names | python | def get_categories(self, app_name):
"""
Returns a list of the categories for an app name.
"""
cat_nums = self.apps.get(app_name, {}).get("cats", [])
cat_names = [self.categories.get("%s" % cat_num, "")
for cat_num in cat_nums]
return cat_names | [
"def",
"get_categories",
"(",
"self",
",",
"app_name",
")",
":",
"cat_nums",
"=",
"self",
".",
"apps",
".",
"get",
"(",
"app_name",
",",
"{",
"}",
")",
".",
"get",
"(",
"\"cats\"",
",",
"[",
"]",
")",
"cat_names",
"=",
"[",
"self",
".",
"categories... | Returns a list of the categories for an app name. | [
"Returns",
"a",
"list",
"of",
"the",
"categories",
"for",
"an",
"app",
"name",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L244-L252 |
10,230 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer.analyze | def analyze(self, webpage):
"""
Return a list of applications that can be detected on the web page.
"""
detected_apps = set()
for app_name, app in self.apps.items():
if self._has_app(app, webpage):
detected_apps.add(app_name)
detected_apps |=... | python | def analyze(self, webpage):
"""
Return a list of applications that can be detected on the web page.
"""
detected_apps = set()
for app_name, app in self.apps.items():
if self._has_app(app, webpage):
detected_apps.add(app_name)
detected_apps |=... | [
"def",
"analyze",
"(",
"self",
",",
"webpage",
")",
":",
"detected_apps",
"=",
"set",
"(",
")",
"for",
"app_name",
",",
"app",
"in",
"self",
".",
"apps",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"_has_app",
"(",
"app",
",",
"webpage",
")",
... | Return a list of applications that can be detected on the web page. | [
"Return",
"a",
"list",
"of",
"applications",
"that",
"can",
"be",
"detected",
"on",
"the",
"web",
"page",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L254-L266 |
10,231 | chorsley/python-Wappalyzer | Wappalyzer/Wappalyzer.py | Wappalyzer.analyze_with_categories | def analyze_with_categories(self, webpage):
"""
Return a list of applications and categories that can be detected on the web page.
"""
detected_apps = self.analyze(webpage)
categorised_apps = {}
for app_name in detected_apps:
cat_names = self.get_categories(a... | python | def analyze_with_categories(self, webpage):
"""
Return a list of applications and categories that can be detected on the web page.
"""
detected_apps = self.analyze(webpage)
categorised_apps = {}
for app_name in detected_apps:
cat_names = self.get_categories(a... | [
"def",
"analyze_with_categories",
"(",
"self",
",",
"webpage",
")",
":",
"detected_apps",
"=",
"self",
".",
"analyze",
"(",
"webpage",
")",
"categorised_apps",
"=",
"{",
"}",
"for",
"app_name",
"in",
"detected_apps",
":",
"cat_names",
"=",
"self",
".",
"get_... | Return a list of applications and categories that can be detected on the web page. | [
"Return",
"a",
"list",
"of",
"applications",
"and",
"categories",
"that",
"can",
"be",
"detected",
"on",
"the",
"web",
"page",
"."
] | b785e29f12c8032c54279cfa9ce01ead702a386c | https://github.com/chorsley/python-Wappalyzer/blob/b785e29f12c8032c54279cfa9ce01ead702a386c/Wappalyzer/Wappalyzer.py#L268-L279 |
10,232 | user-cont/conu | conu/utils/filesystem.py | Directory.clean | def clean(self):
"""
remove the directory we operated on
:return: None
"""
if self._initialized:
logger.info("brace yourselves, removing %r", self.path)
shutil.rmtree(self.path) | python | def clean(self):
"""
remove the directory we operated on
:return: None
"""
if self._initialized:
logger.info("brace yourselves, removing %r", self.path)
shutil.rmtree(self.path) | [
"def",
"clean",
"(",
"self",
")",
":",
"if",
"self",
".",
"_initialized",
":",
"logger",
".",
"info",
"(",
"\"brace yourselves, removing %r\"",
",",
"self",
".",
"path",
")",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"path",
")"
] | remove the directory we operated on
:return: None | [
"remove",
"the",
"directory",
"we",
"operated",
"on"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L121-L129 |
10,233 | user-cont/conu | conu/utils/filesystem.py | Directory.initialize | def initialize(self):
"""
create the directory if needed and configure it
:return: None
"""
if not self._initialized:
logger.info("initializing %r", self)
if not os.path.exists(self.path):
if self.mode is not None:
os.m... | python | def initialize(self):
"""
create the directory if needed and configure it
:return: None
"""
if not self._initialized:
logger.info("initializing %r", self)
if not os.path.exists(self.path):
if self.mode is not None:
os.m... | [
"def",
"initialize",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_initialized",
":",
"logger",
".",
"info",
"(",
"\"initializing %r\"",
",",
"self",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"path",
")",
":",
"if",
... | create the directory if needed and configure it
:return: None | [
"create",
"the",
"directory",
"if",
"needed",
"and",
"configure",
"it"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L131-L151 |
10,234 | user-cont/conu | conu/utils/filesystem.py | Directory._set_selinux_context | def _set_selinux_context(self):
"""
Set SELinux context or fields using chcon program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
chcon_command_exists()
# FIXME: do this using python API if possible
... | python | def _set_selinux_context(self):
"""
Set SELinux context or fields using chcon program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
chcon_command_exists()
# FIXME: do this using python API if possible
... | [
"def",
"_set_selinux_context",
"(",
"self",
")",
":",
"chcon_command_exists",
"(",
")",
"# FIXME: do this using python API if possible",
"if",
"self",
".",
"selinux_context",
":",
"logger",
".",
"debug",
"(",
"\"setting SELinux context of %s to %s\"",
",",
"self",
".",
... | Set SELinux context or fields using chcon program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None | [
"Set",
"SELinux",
"context",
"or",
"fields",
"using",
"chcon",
"program",
".",
"Raises",
"CommandDoesNotExistException",
"if",
"the",
"command",
"is",
"not",
"present",
"on",
"the",
"system",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L153-L175 |
10,235 | user-cont/conu | conu/utils/filesystem.py | Directory._set_mode | def _set_mode(self):
"""
set permission bits if needed using python API os.chmod
:return: None
"""
if self.mode is not None:
logger.debug("changing permission bits of %s to %s", self.path, oct(self.mode))
os.chmod(self.path, self.mode) | python | def _set_mode(self):
"""
set permission bits if needed using python API os.chmod
:return: None
"""
if self.mode is not None:
logger.debug("changing permission bits of %s to %s", self.path, oct(self.mode))
os.chmod(self.path, self.mode) | [
"def",
"_set_mode",
"(",
"self",
")",
":",
"if",
"self",
".",
"mode",
"is",
"not",
"None",
":",
"logger",
".",
"debug",
"(",
"\"changing permission bits of %s to %s\"",
",",
"self",
".",
"path",
",",
"oct",
"(",
"self",
".",
"mode",
")",
")",
"os",
"."... | set permission bits if needed using python API os.chmod
:return: None | [
"set",
"permission",
"bits",
"if",
"needed",
"using",
"python",
"API",
"os",
".",
"chmod"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L192-L200 |
10,236 | user-cont/conu | conu/utils/filesystem.py | Directory._add_facl_rules | def _add_facl_rules(self):
"""
Apply ACL rules on the directory using setfacl program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
setfacl_command_exists()
# we are not using pylibacl b/c it's only for python... | python | def _add_facl_rules(self):
"""
Apply ACL rules on the directory using setfacl program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None
"""
setfacl_command_exists()
# we are not using pylibacl b/c it's only for python... | [
"def",
"_add_facl_rules",
"(",
"self",
")",
":",
"setfacl_command_exists",
"(",
")",
"# we are not using pylibacl b/c it's only for python 2",
"if",
"self",
".",
"facl_rules",
":",
"logger",
".",
"debug",
"(",
"\"adding ACLs %s to %s\"",
",",
"self",
".",
"facl_rules",
... | Apply ACL rules on the directory using setfacl program. Raises CommandDoesNotExistException
if the command is not present on the system.
:return: None | [
"Apply",
"ACL",
"rules",
"on",
"the",
"directory",
"using",
"setfacl",
"program",
".",
"Raises",
"CommandDoesNotExistException",
"if",
"the",
"command",
"is",
"not",
"present",
"on",
"the",
"system",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/filesystem.py#L202-L214 |
10,237 | user-cont/conu | conu/backend/podman/image.py | PodmanImage.get_volume_options | def get_volume_options(volumes):
"""
Generates volume options to run methods.
:param volumes: tuple or list of tuples in form target x source,target x source,target,mode.
:return: list of the form ["-v", "/source:/target", "-v", "/other/source:/destination:z", ...]
"""
i... | python | def get_volume_options(volumes):
"""
Generates volume options to run methods.
:param volumes: tuple or list of tuples in form target x source,target x source,target,mode.
:return: list of the form ["-v", "/source:/target", "-v", "/other/source:/destination:z", ...]
"""
i... | [
"def",
"get_volume_options",
"(",
"volumes",
")",
":",
"if",
"not",
"isinstance",
"(",
"volumes",
",",
"list",
")",
":",
"volumes",
"=",
"[",
"volumes",
"]",
"volumes",
"=",
"[",
"Volume",
".",
"create_from_tuple",
"(",
"v",
")",
"for",
"v",
"in",
"vol... | Generates volume options to run methods.
:param volumes: tuple or list of tuples in form target x source,target x source,target,mode.
:return: list of the form ["-v", "/source:/target", "-v", "/other/source:/destination:z", ...] | [
"Generates",
"volume",
"options",
"to",
"run",
"methods",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/image.py#L367-L380 |
10,238 | user-cont/conu | conu/backend/podman/image.py | PodmanImage.layers | def layers(self, rev=True):
"""
Get list of PodmanImage for every layer in image
:param rev: get layers rev
:return: list of :class:`conu.PodmanImage`
"""
image_layers = [
PodmanImage(None, identifier=x, pull_policy=PodmanImagePullPolicy.NEVER)
fo... | python | def layers(self, rev=True):
"""
Get list of PodmanImage for every layer in image
:param rev: get layers rev
:return: list of :class:`conu.PodmanImage`
"""
image_layers = [
PodmanImage(None, identifier=x, pull_policy=PodmanImagePullPolicy.NEVER)
fo... | [
"def",
"layers",
"(",
"self",
",",
"rev",
"=",
"True",
")",
":",
"image_layers",
"=",
"[",
"PodmanImage",
"(",
"None",
",",
"identifier",
"=",
"x",
",",
"pull_policy",
"=",
"PodmanImagePullPolicy",
".",
"NEVER",
")",
"for",
"x",
"in",
"self",
".",
"get... | Get list of PodmanImage for every layer in image
:param rev: get layers rev
:return: list of :class:`conu.PodmanImage` | [
"Get",
"list",
"of",
"PodmanImage",
"for",
"every",
"layer",
"in",
"image"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/image.py#L395-L408 |
10,239 | user-cont/conu | conu/backend/podman/image.py | PodmanImage.get_metadata | def get_metadata(self):
"""
Provide metadata about this image.
:return: ImageMetadata, Image metadata instance
"""
if self._metadata is None:
self._metadata = ImageMetadata()
inspect_to_metadata(self._metadata, self.inspect(refresh=True))
return self.... | python | def get_metadata(self):
"""
Provide metadata about this image.
:return: ImageMetadata, Image metadata instance
"""
if self._metadata is None:
self._metadata = ImageMetadata()
inspect_to_metadata(self._metadata, self.inspect(refresh=True))
return self.... | [
"def",
"get_metadata",
"(",
"self",
")",
":",
"if",
"self",
".",
"_metadata",
"is",
"None",
":",
"self",
".",
"_metadata",
"=",
"ImageMetadata",
"(",
")",
"inspect_to_metadata",
"(",
"self",
".",
"_metadata",
",",
"self",
".",
"inspect",
"(",
"refresh",
... | Provide metadata about this image.
:return: ImageMetadata, Image metadata instance | [
"Provide",
"metadata",
"about",
"this",
"image",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/image.py#L416-L425 |
10,240 | user-cont/conu | conu/backend/podman/container.py | PodmanContainer.is_running | def is_running(self):
"""
returns True if the container is running
:return: bool
"""
try:
return graceful_get(self.inspect(refresh=True), "State", "Running")
except subprocess.CalledProcessError:
return False | python | def is_running(self):
"""
returns True if the container is running
:return: bool
"""
try:
return graceful_get(self.inspect(refresh=True), "State", "Running")
except subprocess.CalledProcessError:
return False | [
"def",
"is_running",
"(",
"self",
")",
":",
"try",
":",
"return",
"graceful_get",
"(",
"self",
".",
"inspect",
"(",
"refresh",
"=",
"True",
")",
",",
"\"State\"",
",",
"\"Running\"",
")",
"except",
"subprocess",
".",
"CalledProcessError",
":",
"return",
"F... | returns True if the container is running
:return: bool | [
"returns",
"True",
"if",
"the",
"container",
"is",
"running"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L125-L134 |
10,241 | user-cont/conu | conu/backend/podman/container.py | PodmanContainer.is_port_open | def is_port_open(self, port, timeout=2):
"""
check if given port is open and receiving connections on container ip_address
:param port: int, container port
:param timeout: int, how many seconds to wait for connection; defaults to 2
:return: True if the connection has been establ... | python | def is_port_open(self, port, timeout=2):
"""
check if given port is open and receiving connections on container ip_address
:param port: int, container port
:param timeout: int, how many seconds to wait for connection; defaults to 2
:return: True if the connection has been establ... | [
"def",
"is_port_open",
"(",
"self",
",",
"port",
",",
"timeout",
"=",
"2",
")",
":",
"addresses",
"=",
"self",
".",
"get_IPv4s",
"(",
")",
"if",
"not",
"addresses",
":",
"return",
"False",
"return",
"check_port",
"(",
"port",
",",
"host",
"=",
"address... | check if given port is open and receiving connections on container ip_address
:param port: int, container port
:param timeout: int, how many seconds to wait for connection; defaults to 2
:return: True if the connection has been established inside timeout, False otherwise | [
"check",
"if",
"given",
"port",
"is",
"open",
"and",
"receiving",
"connections",
"on",
"container",
"ip_address"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L173-L184 |
10,242 | user-cont/conu | conu/backend/podman/container.py | PodmanContainer.wait_for_port | def wait_for_port(self, port, timeout=10, **probe_kwargs):
"""
block until specified port starts accepting connections, raises an exc ProbeTimeout
if timeout is reached
:param port: int, port number
:param timeout: int or float (seconds), time to wait for establishing the connec... | python | def wait_for_port(self, port, timeout=10, **probe_kwargs):
"""
block until specified port starts accepting connections, raises an exc ProbeTimeout
if timeout is reached
:param port: int, port number
:param timeout: int or float (seconds), time to wait for establishing the connec... | [
"def",
"wait_for_port",
"(",
"self",
",",
"port",
",",
"timeout",
"=",
"10",
",",
"*",
"*",
"probe_kwargs",
")",
":",
"Probe",
"(",
"timeout",
"=",
"timeout",
",",
"fnc",
"=",
"functools",
".",
"partial",
"(",
"self",
".",
"is_port_open",
",",
"port",
... | block until specified port starts accepting connections, raises an exc ProbeTimeout
if timeout is reached
:param port: int, port number
:param timeout: int or float (seconds), time to wait for establishing the connection
:param probe_kwargs: arguments passed to Probe constructor
... | [
"block",
"until",
"specified",
"port",
"starts",
"accepting",
"connections",
"raises",
"an",
"exc",
"ProbeTimeout",
"if",
"timeout",
"is",
"reached"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L221-L231 |
10,243 | user-cont/conu | conu/backend/podman/container.py | PodmanContainer.mount | def mount(self, mount_point=None):
"""
mount container filesystem
:return: str, the location of the mounted file system
"""
cmd = ["podman", "mount", self._id or self.get_id()]
output = run_cmd(cmd, return_output=True).rstrip("\n\r")
return output | python | def mount(self, mount_point=None):
"""
mount container filesystem
:return: str, the location of the mounted file system
"""
cmd = ["podman", "mount", self._id or self.get_id()]
output = run_cmd(cmd, return_output=True).rstrip("\n\r")
return output | [
"def",
"mount",
"(",
"self",
",",
"mount_point",
"=",
"None",
")",
":",
"cmd",
"=",
"[",
"\"podman\"",
",",
"\"mount\"",
",",
"self",
".",
"_id",
"or",
"self",
".",
"get_id",
"(",
")",
"]",
"output",
"=",
"run_cmd",
"(",
"cmd",
",",
"return_output",
... | mount container filesystem
:return: str, the location of the mounted file system | [
"mount",
"container",
"filesystem"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L244-L252 |
10,244 | user-cont/conu | conu/backend/podman/container.py | PodmanContainer.wait | def wait(self, timeout=None):
"""
Block until the container stops, then return its exit code. Similar to
the ``podman wait`` command.
:param timeout: int, microseconds to wait before polling for completion
:return: int, exit code
"""
timeout = ["--interval=%s" % ... | python | def wait(self, timeout=None):
"""
Block until the container stops, then return its exit code. Similar to
the ``podman wait`` command.
:param timeout: int, microseconds to wait before polling for completion
:return: int, exit code
"""
timeout = ["--interval=%s" % ... | [
"def",
"wait",
"(",
"self",
",",
"timeout",
"=",
"None",
")",
":",
"timeout",
"=",
"[",
"\"--interval=%s\"",
"%",
"timeout",
"]",
"if",
"timeout",
"else",
"[",
"]",
"cmdline",
"=",
"[",
"\"podman\"",
",",
"\"wait\"",
"]",
"+",
"timeout",
"+",
"[",
"s... | Block until the container stops, then return its exit code. Similar to
the ``podman wait`` command.
:param timeout: int, microseconds to wait before polling for completion
:return: int, exit code | [
"Block",
"until",
"the",
"container",
"stops",
"then",
"return",
"its",
"exit",
"code",
".",
"Similar",
"to",
"the",
"podman",
"wait",
"command",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/container.py#L306-L316 |
10,245 | user-cont/conu | conu/apidefs/filesystem.py | Filesystem.read_file | def read_file(self, file_path):
"""
read file specified via 'file_path' and return its content - raises an ConuException if
there is an issue accessing the file
:param file_path: str, path to the file to read
:return: str (not bytes), content of the file
"""
try:... | python | def read_file(self, file_path):
"""
read file specified via 'file_path' and return its content - raises an ConuException if
there is an issue accessing the file
:param file_path: str, path to the file to read
:return: str (not bytes), content of the file
"""
try:... | [
"def",
"read_file",
"(",
"self",
",",
"file_path",
")",
":",
"try",
":",
"with",
"open",
"(",
"self",
".",
"p",
"(",
"file_path",
")",
")",
"as",
"fd",
":",
"return",
"fd",
".",
"read",
"(",
")",
"except",
"IOError",
"as",
"ex",
":",
"logger",
".... | read file specified via 'file_path' and return its content - raises an ConuException if
there is an issue accessing the file
:param file_path: str, path to the file to read
:return: str (not bytes), content of the file | [
"read",
"file",
"specified",
"via",
"file_path",
"and",
"return",
"its",
"content",
"-",
"raises",
"an",
"ConuException",
"if",
"there",
"is",
"an",
"issue",
"accessing",
"the",
"file"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L106-L119 |
10,246 | user-cont/conu | conu/apidefs/filesystem.py | Filesystem.get_file | def get_file(self, file_path, mode="r"):
"""
provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance
"""
return open(self.p(file_path), mode=mode) | python | def get_file(self, file_path, mode="r"):
"""
provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance
"""
return open(self.p(file_path), mode=mode) | [
"def",
"get_file",
"(",
"self",
",",
"file_path",
",",
"mode",
"=",
"\"r\"",
")",
":",
"return",
"open",
"(",
"self",
".",
"p",
"(",
"file_path",
")",
",",
"mode",
"=",
"mode",
")"
] | provide File object specified via 'file_path'
:param file_path: str, path to the file
:param mode: str, mode used when opening the file
:return: File instance | [
"provide",
"File",
"object",
"specified",
"via",
"file_path"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L121-L129 |
10,247 | user-cont/conu | conu/apidefs/filesystem.py | Filesystem.file_is_present | def file_is_present(self, file_path):
"""
check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist
"""
p = self.p(file_path)
if not o... | python | def file_is_present(self, file_path):
"""
check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist
"""
p = self.p(file_path)
if not o... | [
"def",
"file_is_present",
"(",
"self",
",",
"file_path",
")",
":",
"p",
"=",
"self",
".",
"p",
"(",
"file_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"p",
")",
":",
"return",
"False",
"if",
"not",
"os",
".",
"path",
".",
"isfi... | check if file 'file_path' is present, raises IOError if file_path
is not a file
:param file_path: str, path to the file
:return: True if file exists, False if file does not exist | [
"check",
"if",
"file",
"file_path",
"is",
"present",
"raises",
"IOError",
"if",
"file_path",
"is",
"not",
"a",
"file"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L131-L144 |
10,248 | user-cont/conu | conu/apidefs/filesystem.py | Filesystem.directory_is_present | def directory_is_present(self, directory_path):
"""
check if directory 'directory_path' is present, raise IOError if it's not a directory
:param directory_path: str, directory to check
:return: True if directory exists, False if directory does not exist
"""
p = self.p(di... | python | def directory_is_present(self, directory_path):
"""
check if directory 'directory_path' is present, raise IOError if it's not a directory
:param directory_path: str, directory to check
:return: True if directory exists, False if directory does not exist
"""
p = self.p(di... | [
"def",
"directory_is_present",
"(",
"self",
",",
"directory_path",
")",
":",
"p",
"=",
"self",
".",
"p",
"(",
"directory_path",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"p",
")",
":",
"return",
"False",
"if",
"not",
"os",
".",
"path",... | check if directory 'directory_path' is present, raise IOError if it's not a directory
:param directory_path: str, directory to check
:return: True if directory exists, False if directory does not exist | [
"check",
"if",
"directory",
"directory_path",
"is",
"present",
"raise",
"IOError",
"if",
"it",
"s",
"not",
"a",
"directory"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L146-L158 |
10,249 | user-cont/conu | conu/apidefs/filesystem.py | Filesystem.get_selinux_context | def get_selinux_context(self, file_path):
"""
Get SELinux file context of the selected file.
:param file_path: str, path to the file
:return: str, name of the SELinux file context
"""
# what if SELinux is not enabled?
p = self.p(file_path)
if not HAS_XATT... | python | def get_selinux_context(self, file_path):
"""
Get SELinux file context of the selected file.
:param file_path: str, path to the file
:return: str, name of the SELinux file context
"""
# what if SELinux is not enabled?
p = self.p(file_path)
if not HAS_XATT... | [
"def",
"get_selinux_context",
"(",
"self",
",",
"file_path",
")",
":",
"# what if SELinux is not enabled?",
"p",
"=",
"self",
".",
"p",
"(",
"file_path",
")",
"if",
"not",
"HAS_XATTR",
":",
"raise",
"RuntimeError",
"(",
"\"'xattr' python module is not available, hence... | Get SELinux file context of the selected file.
:param file_path: str, path to the file
:return: str, name of the SELinux file context | [
"Get",
"SELinux",
"file",
"context",
"of",
"the",
"selected",
"file",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/filesystem.py#L160-L174 |
10,250 | user-cont/conu | conu/utils/probes.py | Probe._wrapper | def _wrapper(self, q, start):
"""
_wrapper checks return status of Probe.fnc and provides the result for process managing
:param q: Queue for function results
:param start: Time of function run (used for logging)
:return: Return value or Exception
"""
tr... | python | def _wrapper(self, q, start):
"""
_wrapper checks return status of Probe.fnc and provides the result for process managing
:param q: Queue for function results
:param start: Time of function run (used for logging)
:return: Return value or Exception
"""
tr... | [
"def",
"_wrapper",
"(",
"self",
",",
"q",
",",
"start",
")",
":",
"try",
":",
"func_name",
"=",
"self",
".",
"fnc",
".",
"__name__",
"except",
"AttributeError",
":",
"func_name",
"=",
"str",
"(",
"self",
".",
"fnc",
")",
"logger",
".",
"debug",
"(",
... | _wrapper checks return status of Probe.fnc and provides the result for process managing
:param q: Queue for function results
:param start: Time of function run (used for logging)
:return: Return value or Exception | [
"_wrapper",
"checks",
"return",
"status",
"of",
"Probe",
".",
"fnc",
"and",
"provides",
"the",
"result",
"for",
"process",
"managing"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/probes.py#L92-L116 |
10,251 | user-cont/conu | conu/backend/docker/skopeo.py | transport_param | def transport_param(image):
""" Parse DockerImage info into skopeo parameter
:param image: DockerImage
:return: string. skopeo parameter specifying image
"""
transports = {SkopeoTransport.CONTAINERS_STORAGE: "containers-storage:",
SkopeoTransport.DIRECTORY: "dir:",
... | python | def transport_param(image):
""" Parse DockerImage info into skopeo parameter
:param image: DockerImage
:return: string. skopeo parameter specifying image
"""
transports = {SkopeoTransport.CONTAINERS_STORAGE: "containers-storage:",
SkopeoTransport.DIRECTORY: "dir:",
... | [
"def",
"transport_param",
"(",
"image",
")",
":",
"transports",
"=",
"{",
"SkopeoTransport",
".",
"CONTAINERS_STORAGE",
":",
"\"containers-storage:\"",
",",
"SkopeoTransport",
".",
"DIRECTORY",
":",
"\"dir:\"",
",",
"SkopeoTransport",
".",
"DOCKER",
":",
"\"docker:/... | Parse DockerImage info into skopeo parameter
:param image: DockerImage
:return: string. skopeo parameter specifying image | [
"Parse",
"DockerImage",
"info",
"into",
"skopeo",
"parameter"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/skopeo.py#L23-L65 |
10,252 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer.is_running | def is_running(self):
"""
return True when container is running, otherwise return False
:return: bool
"""
cmd = ["machinectl", "--no-pager", "status", self.name]
try:
subprocess.check_call(cmd)
return True
except subprocess.CalledProcessEr... | python | def is_running(self):
"""
return True when container is running, otherwise return False
:return: bool
"""
cmd = ["machinectl", "--no-pager", "status", self.name]
try:
subprocess.check_call(cmd)
return True
except subprocess.CalledProcessEr... | [
"def",
"is_running",
"(",
"self",
")",
":",
"cmd",
"=",
"[",
"\"machinectl\"",
",",
"\"--no-pager\"",
",",
"\"status\"",
",",
"self",
".",
"name",
"]",
"try",
":",
"subprocess",
".",
"check_call",
"(",
"cmd",
")",
"return",
"True",
"except",
"subprocess",
... | return True when container is running, otherwise return False
:return: bool | [
"return",
"True",
"when",
"container",
"is",
"running",
"otherwise",
"return",
"False"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L147-L160 |
10,253 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer.copy_from | def copy_from(self, src, dest):
"""
copy a file or a directory from container or image to host system.
:param src: str, path to a file or a directory within container or image
:param dest: str, path to a file or a directory on host system
:return: None
"""
logger... | python | def copy_from(self, src, dest):
"""
copy a file or a directory from container or image to host system.
:param src: str, path to a file or a directory within container or image
:param dest: str, path to a file or a directory on host system
:return: None
"""
logger... | [
"def",
"copy_from",
"(",
"self",
",",
"src",
",",
"dest",
")",
":",
"logger",
".",
"debug",
"(",
"\"copying %s from host to container at %s\"",
",",
"src",
",",
"dest",
")",
"cmd",
"=",
"[",
"\"machinectl\"",
",",
"\"--no-pager\"",
",",
"\"copy-from\"",
",",
... | copy a file or a directory from container or image to host system.
:param src: str, path to a file or a directory within container or image
:param dest: str, path to a file or a directory on host system
:return: None | [
"copy",
"a",
"file",
"or",
"a",
"directory",
"from",
"container",
"or",
"image",
"to",
"host",
"system",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L174-L184 |
10,254 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer.delete | def delete(self, force=False, volumes=False):
"""
delete underlying image
:param force: bool - force delete, do not care about errors
:param volumes: not used anyhow
:return: None
"""
try:
self.image.rmi()
except ConuException as ime:
... | python | def delete(self, force=False, volumes=False):
"""
delete underlying image
:param force: bool - force delete, do not care about errors
:param volumes: not used anyhow
:return: None
"""
try:
self.image.rmi()
except ConuException as ime:
... | [
"def",
"delete",
"(",
"self",
",",
"force",
"=",
"False",
",",
"volumes",
"=",
"False",
")",
":",
"try",
":",
"self",
".",
"image",
".",
"rmi",
"(",
")",
"except",
"ConuException",
"as",
"ime",
":",
"if",
"not",
"force",
":",
"raise",
"ime",
"else"... | delete underlying image
:param force: bool - force delete, do not care about errors
:param volumes: not used anyhow
:return: None | [
"delete",
"underlying",
"image"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L220-L234 |
10,255 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer.cleanup | def cleanup(self, force=False, delete=False):
"""
Stop container and delete image if given param delete
:param force: bool, force stop and delete, no errors raised
:param delete: delete images
:return: None
"""
# TODO: this method could be part of API, like:
... | python | def cleanup(self, force=False, delete=False):
"""
Stop container and delete image if given param delete
:param force: bool, force stop and delete, no errors raised
:param delete: delete images
:return: None
"""
# TODO: this method could be part of API, like:
... | [
"def",
"cleanup",
"(",
"self",
",",
"force",
"=",
"False",
",",
"delete",
"=",
"False",
")",
":",
"# TODO: this method could be part of API, like:",
"try",
":",
"self",
".",
"stop",
"(",
")",
"except",
"subprocess",
".",
"CalledProcessError",
"as",
"stop",
":"... | Stop container and delete image if given param delete
:param force: bool, force stop and delete, no errors raised
:param delete: delete images
:return: None | [
"Stop",
"container",
"and",
"delete",
"image",
"if",
"given",
"param",
"delete"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L236-L257 |
10,256 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer.run_systemdrun | def run_systemdrun(
self, command, internal_background=False, return_full_dict=False,
**kwargs):
"""
execute command via systemd-run inside container
:param command: list of command params
:param internal_background: not used now
:param kwargs: pass param... | python | def run_systemdrun(
self, command, internal_background=False, return_full_dict=False,
**kwargs):
"""
execute command via systemd-run inside container
:param command: list of command params
:param internal_background: not used now
:param kwargs: pass param... | [
"def",
"run_systemdrun",
"(",
"self",
",",
"command",
",",
"internal_background",
"=",
"False",
",",
"return_full_dict",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"internalkw",
"=",
"deepcopy",
"(",
"kwargs",
")",
"or",
"{",
"}",
"original_ignore_st",... | execute command via systemd-run inside container
:param command: list of command params
:param internal_background: not used now
:param kwargs: pass params to subprocess
:return: dict with result | [
"execute",
"command",
"via",
"systemd",
"-",
"run",
"inside",
"container"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L306-L374 |
10,257 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer._wait_for_machine_booted | def _wait_for_machine_booted(name, suffictinet_texts=None):
"""
Internal method
wait until machine is ready, in common case means there is running systemd-logind
:param name: str with machine name
:param suffictinet_texts: alternative text to check in output
:return: Tru... | python | def _wait_for_machine_booted(name, suffictinet_texts=None):
"""
Internal method
wait until machine is ready, in common case means there is running systemd-logind
:param name: str with machine name
:param suffictinet_texts: alternative text to check in output
:return: Tru... | [
"def",
"_wait_for_machine_booted",
"(",
"name",
",",
"suffictinet_texts",
"=",
"None",
")",
":",
"# TODO: rewrite it using probes module in utils",
"suffictinet_texts",
"=",
"suffictinet_texts",
"or",
"[",
"\"systemd-logind\"",
"]",
"# optionally use: \"Unit: machine\"",
"for",... | Internal method
wait until machine is ready, in common case means there is running systemd-logind
:param name: str with machine name
:param suffictinet_texts: alternative text to check in output
:return: True or exception | [
"Internal",
"method",
"wait",
"until",
"machine",
"is",
"ready",
"in",
"common",
"case",
"means",
"there",
"is",
"running",
"systemd",
"-",
"logind"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L408-L431 |
10,258 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer._internal_reschedule | def _internal_reschedule(callback, retry=3, sleep_time=constants.DEFAULT_SLEEP):
"""
workaround method for internal_run_container method
It sometimes fails because of Dbus or whatever, so try to start it moretimes
:param callback: callback method list
:param retry: how many time... | python | def _internal_reschedule(callback, retry=3, sleep_time=constants.DEFAULT_SLEEP):
"""
workaround method for internal_run_container method
It sometimes fails because of Dbus or whatever, so try to start it moretimes
:param callback: callback method list
:param retry: how many time... | [
"def",
"_internal_reschedule",
"(",
"callback",
",",
"retry",
"=",
"3",
",",
"sleep_time",
"=",
"constants",
".",
"DEFAULT_SLEEP",
")",
":",
"for",
"foo",
"in",
"range",
"(",
"retry",
")",
":",
"container_process",
"=",
"callback",
"[",
"0",
"]",
"(",
"c... | workaround method for internal_run_container method
It sometimes fails because of Dbus or whatever, so try to start it moretimes
:param callback: callback method list
:param retry: how many times try to invoke command
:param sleep_time: how long wait before subprocess.poll() to find if ... | [
"workaround",
"method",
"for",
"internal_run_container",
"method",
"It",
"sometimes",
"fails",
"because",
"of",
"Dbus",
"or",
"whatever",
"so",
"try",
"to",
"start",
"it",
"moretimes"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L434-L451 |
10,259 | user-cont/conu | conu/backend/nspawn/container.py | NspawnContainer.internal_run_container | def internal_run_container(name, callback_method, foreground=False):
"""
Internal method what runs container process
:param name: str - name of container
:param callback_method: list - how to invoke container
:param foreground: bool run in background by default
:return: ... | python | def internal_run_container(name, callback_method, foreground=False):
"""
Internal method what runs container process
:param name: str - name of container
:param callback_method: list - how to invoke container
:param foreground: bool run in background by default
:return: ... | [
"def",
"internal_run_container",
"(",
"name",
",",
"callback_method",
",",
"foreground",
"=",
"False",
")",
":",
"if",
"not",
"foreground",
":",
"logger",
".",
"info",
"(",
"\"Stating machine (boot nspawn container) {}\"",
".",
"format",
"(",
"name",
")",
")",
"... | Internal method what runs container process
:param name: str - name of container
:param callback_method: list - how to invoke container
:param foreground: bool run in background by default
:return: suprocess instance | [
"Internal",
"method",
"what",
"runs",
"container",
"process"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/container.py#L455-L474 |
10,260 | user-cont/conu | conu/helpers/docker_backend.py | get_container_output | def get_container_output(backend, image_name, command, image_tag="latest",
additional_opts=None):
"""
Create a throw-away container based on provided image and tag, run the supplied command in it
and return output. The container is stopped and removed after it exits.
:param bac... | python | def get_container_output(backend, image_name, command, image_tag="latest",
additional_opts=None):
"""
Create a throw-away container based on provided image and tag, run the supplied command in it
and return output. The container is stopped and removed after it exits.
:param bac... | [
"def",
"get_container_output",
"(",
"backend",
",",
"image_name",
",",
"command",
",",
"image_tag",
"=",
"\"latest\"",
",",
"additional_opts",
"=",
"None",
")",
":",
"image",
"=",
"backend",
".",
"ImageClass",
"(",
"image_name",
",",
"tag",
"=",
"image_tag",
... | Create a throw-away container based on provided image and tag, run the supplied command in it
and return output. The container is stopped and removed after it exits.
:param backend: instance of DockerBackend
:param image_name: str, name of the container image
:param command: list of str, command to run... | [
"Create",
"a",
"throw",
"-",
"away",
"container",
"based",
"on",
"provided",
"image",
"and",
"tag",
"run",
"the",
"supplied",
"command",
"in",
"it",
"and",
"return",
"output",
".",
"The",
"container",
"is",
"stopped",
"and",
"removed",
"after",
"it",
"exit... | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/helpers/docker_backend.py#L4-L28 |
10,261 | user-cont/conu | conu/backend/docker/image.py | DockerImage.pull | def pull(self):
"""
Pull this image from registry. Raises an exception if the image is not found in
the registry.
:return: None
"""
for json_e in self.d.pull(repository=self.name, tag=self.tag, stream=True, decode=True):
logger.debug(json_e)
statu... | python | def pull(self):
"""
Pull this image from registry. Raises an exception if the image is not found in
the registry.
:return: None
"""
for json_e in self.d.pull(repository=self.name, tag=self.tag, stream=True, decode=True):
logger.debug(json_e)
statu... | [
"def",
"pull",
"(",
"self",
")",
":",
"for",
"json_e",
"in",
"self",
".",
"d",
".",
"pull",
"(",
"repository",
"=",
"self",
".",
"name",
",",
"tag",
"=",
"self",
".",
"tag",
",",
"stream",
"=",
"True",
",",
"decode",
"=",
"True",
")",
":",
"log... | Pull this image from registry. Raises an exception if the image is not found in
the registry.
:return: None | [
"Pull",
"this",
"image",
"from",
"registry",
".",
"Raises",
"an",
"exception",
"if",
"the",
"image",
"is",
"not",
"found",
"in",
"the",
"registry",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L185-L202 |
10,262 | user-cont/conu | conu/backend/docker/image.py | DockerImage.using_transport | def using_transport(self, transport=None, path=None, logs=True):
""" change used transport
:param transport: from where will be this image copied
:param path in filesystem
:param logs enable/disable
:return: self
"""
if not transport:
return self
... | python | def using_transport(self, transport=None, path=None, logs=True):
""" change used transport
:param transport: from where will be this image copied
:param path in filesystem
:param logs enable/disable
:return: self
"""
if not transport:
return self
... | [
"def",
"using_transport",
"(",
"self",
",",
"transport",
"=",
"None",
",",
"path",
"=",
"None",
",",
"logs",
"=",
"True",
")",
":",
"if",
"not",
"transport",
":",
"return",
"self",
"if",
"self",
".",
"transport",
"==",
"transport",
"and",
"self",
".",
... | change used transport
:param transport: from where will be this image copied
:param path in filesystem
:param logs enable/disable
:return: self | [
"change",
"used",
"transport"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L230-L264 |
10,263 | user-cont/conu | conu/backend/docker/image.py | DockerImage.save_to | def save_to(self, image):
""" Save this image to another DockerImage
:param image: DockerImage
:return:
"""
if not isinstance(image, self.__class__):
raise ConuException("Invalid target image type", type(image))
self.copy(image.name, image.tag,
... | python | def save_to(self, image):
""" Save this image to another DockerImage
:param image: DockerImage
:return:
"""
if not isinstance(image, self.__class__):
raise ConuException("Invalid target image type", type(image))
self.copy(image.name, image.tag,
... | [
"def",
"save_to",
"(",
"self",
",",
"image",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"self",
".",
"__class__",
")",
":",
"raise",
"ConuException",
"(",
"\"Invalid target image type\"",
",",
"type",
"(",
"image",
")",
")",
"self",
".",
"co... | Save this image to another DockerImage
:param image: DockerImage
:return: | [
"Save",
"this",
"image",
"to",
"another",
"DockerImage"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L266-L276 |
10,264 | user-cont/conu | conu/backend/docker/image.py | DockerImage.load_from | def load_from(self, image):
""" Load from another DockerImage to this one
:param image:
:return:
"""
if not isinstance(image, self.__class__):
raise ConuException("Invalid source image type", type(image))
image.save_to(self) | python | def load_from(self, image):
""" Load from another DockerImage to this one
:param image:
:return:
"""
if not isinstance(image, self.__class__):
raise ConuException("Invalid source image type", type(image))
image.save_to(self) | [
"def",
"load_from",
"(",
"self",
",",
"image",
")",
":",
"if",
"not",
"isinstance",
"(",
"image",
",",
"self",
".",
"__class__",
")",
":",
"raise",
"ConuException",
"(",
"\"Invalid source image type\"",
",",
"type",
"(",
"image",
")",
")",
"image",
".",
... | Load from another DockerImage to this one
:param image:
:return: | [
"Load",
"from",
"another",
"DockerImage",
"to",
"this",
"one"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L278-L286 |
10,265 | user-cont/conu | conu/backend/docker/image.py | DockerImage.skopeo_pull | def skopeo_pull(self):
""" Pull image from Docker to local Docker daemon using skopeo
:return: pulled image
"""
return self.copy(self.name, self.tag,
SkopeoTransport.DOCKER, SkopeoTransport.DOCKER_DAEMON)\
.using_transport(SkopeoTransport.DOCKER_DAEM... | python | def skopeo_pull(self):
""" Pull image from Docker to local Docker daemon using skopeo
:return: pulled image
"""
return self.copy(self.name, self.tag,
SkopeoTransport.DOCKER, SkopeoTransport.DOCKER_DAEMON)\
.using_transport(SkopeoTransport.DOCKER_DAEM... | [
"def",
"skopeo_pull",
"(",
"self",
")",
":",
"return",
"self",
".",
"copy",
"(",
"self",
".",
"name",
",",
"self",
".",
"tag",
",",
"SkopeoTransport",
".",
"DOCKER",
",",
"SkopeoTransport",
".",
"DOCKER_DAEMON",
")",
".",
"using_transport",
"(",
"SkopeoTra... | Pull image from Docker to local Docker daemon using skopeo
:return: pulled image | [
"Pull",
"image",
"from",
"Docker",
"to",
"local",
"Docker",
"daemon",
"using",
"skopeo"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L288-L295 |
10,266 | user-cont/conu | conu/backend/docker/image.py | DockerImage.skopeo_push | def skopeo_push(self, repository=None, tag=None):
""" Push image from Docker daemon to Docker using skopeo
:param repository: repository to be pushed to
:param tag: tag
:return: pushed image
"""
return self.copy(repository, tag, SkopeoTransport.DOCKER_DAEMON, SkopeoTrans... | python | def skopeo_push(self, repository=None, tag=None):
""" Push image from Docker daemon to Docker using skopeo
:param repository: repository to be pushed to
:param tag: tag
:return: pushed image
"""
return self.copy(repository, tag, SkopeoTransport.DOCKER_DAEMON, SkopeoTrans... | [
"def",
"skopeo_push",
"(",
"self",
",",
"repository",
"=",
"None",
",",
"tag",
"=",
"None",
")",
":",
"return",
"self",
".",
"copy",
"(",
"repository",
",",
"tag",
",",
"SkopeoTransport",
".",
"DOCKER_DAEMON",
",",
"SkopeoTransport",
".",
"DOCKER",
")",
... | Push image from Docker daemon to Docker using skopeo
:param repository: repository to be pushed to
:param tag: tag
:return: pushed image | [
"Push",
"image",
"from",
"Docker",
"daemon",
"to",
"Docker",
"using",
"skopeo"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L297-L305 |
10,267 | user-cont/conu | conu/backend/docker/image.py | DockerImage.copy | def copy(self, repository=None, tag=None,
source_transport=None,
target_transport=SkopeoTransport.DOCKER,
source_path=None, target_path=None,
logs=True):
""" Copy this image
:param repository to be copied to
:param tag
:param source_tr... | python | def copy(self, repository=None, tag=None,
source_transport=None,
target_transport=SkopeoTransport.DOCKER,
source_path=None, target_path=None,
logs=True):
""" Copy this image
:param repository to be copied to
:param tag
:param source_tr... | [
"def",
"copy",
"(",
"self",
",",
"repository",
"=",
"None",
",",
"tag",
"=",
"None",
",",
"source_transport",
"=",
"None",
",",
"target_transport",
"=",
"SkopeoTransport",
".",
"DOCKER",
",",
"source_path",
"=",
"None",
",",
"target_path",
"=",
"None",
","... | Copy this image
:param repository to be copied to
:param tag
:param source_transport Transport
:param target_transport Transport
:param source_path needed to specify for dir, docker-archive or oci transport
:param target_path needed to specify for dir, docker-archive or ... | [
"Copy",
"this",
"image"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L307-L340 |
10,268 | user-cont/conu | conu/backend/docker/image.py | DockerImage.tag_image | def tag_image(self, repository=None, tag=None):
"""
Apply additional tags to the image or even add a new name
:param repository: str, see constructor
:param tag: str, see constructor
:return: instance of DockerImage
"""
if not (repository or tag):
rai... | python | def tag_image(self, repository=None, tag=None):
"""
Apply additional tags to the image or even add a new name
:param repository: str, see constructor
:param tag: str, see constructor
:return: instance of DockerImage
"""
if not (repository or tag):
rai... | [
"def",
"tag_image",
"(",
"self",
",",
"repository",
"=",
"None",
",",
"tag",
"=",
"None",
")",
":",
"if",
"not",
"(",
"repository",
"or",
"tag",
")",
":",
"raise",
"ValueError",
"(",
"\"You need to specify either repository or tag.\"",
")",
"r",
"=",
"reposi... | Apply additional tags to the image or even add a new name
:param repository: str, see constructor
:param tag: str, see constructor
:return: instance of DockerImage | [
"Apply",
"additional",
"tags",
"to",
"the",
"image",
"or",
"even",
"add",
"a",
"new",
"name"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L342-L355 |
10,269 | user-cont/conu | conu/backend/docker/image.py | DockerImage.inspect | def inspect(self, refresh=True):
"""
provide metadata about the image; flip refresh=True if cached metadata are enough
:param refresh: bool, update the metadata with up to date content
:return: dict
"""
if refresh or not self._inspect_data:
identifier = self.... | python | def inspect(self, refresh=True):
"""
provide metadata about the image; flip refresh=True if cached metadata are enough
:param refresh: bool, update the metadata with up to date content
:return: dict
"""
if refresh or not self._inspect_data:
identifier = self.... | [
"def",
"inspect",
"(",
"self",
",",
"refresh",
"=",
"True",
")",
":",
"if",
"refresh",
"or",
"not",
"self",
".",
"_inspect_data",
":",
"identifier",
"=",
"self",
".",
"_id",
"or",
"self",
".",
"get_full_name",
"(",
")",
"if",
"not",
"identifier",
":",
... | provide metadata about the image; flip refresh=True if cached metadata are enough
:param refresh: bool, update the metadata with up to date content
:return: dict | [
"provide",
"metadata",
"about",
"the",
"image",
";",
"flip",
"refresh",
"=",
"True",
"if",
"cached",
"metadata",
"are",
"enough"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L357-L369 |
10,270 | user-cont/conu | conu/backend/docker/image.py | DockerImage.has_pkgs_signed_with | def has_pkgs_signed_with(self, allowed_keys):
"""
Check signature of packages installed in image.
Raises exception when
* rpm binary is not installed in image
* parsing of rpm fails
* there are packages in image that are not signed with one of allowed keys
:para... | python | def has_pkgs_signed_with(self, allowed_keys):
"""
Check signature of packages installed in image.
Raises exception when
* rpm binary is not installed in image
* parsing of rpm fails
* there are packages in image that are not signed with one of allowed keys
:para... | [
"def",
"has_pkgs_signed_with",
"(",
"self",
",",
"allowed_keys",
")",
":",
"if",
"not",
"allowed_keys",
"or",
"not",
"isinstance",
"(",
"allowed_keys",
",",
"list",
")",
":",
"raise",
"ConuException",
"(",
"\"allowed_keys must be a list\"",
")",
"command",
"=",
... | Check signature of packages installed in image.
Raises exception when
* rpm binary is not installed in image
* parsing of rpm fails
* there are packages in image that are not signed with one of allowed keys
:param allowed_keys: list of allowed keys
:return: bool | [
"Check",
"signature",
"of",
"packages",
"installed",
"in",
"image",
".",
"Raises",
"exception",
"when"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L639-L662 |
10,271 | user-cont/conu | conu/backend/docker/image.py | DockerImage.build | def build(cls, path, tag=None, dockerfile=None):
"""
Build the image from the provided dockerfile in path
:param path : str, path to the directory containing the Dockerfile
:param tag: str, A tag to add to the final image
:param dockerfile: str, path within the build context to ... | python | def build(cls, path, tag=None, dockerfile=None):
"""
Build the image from the provided dockerfile in path
:param path : str, path to the directory containing the Dockerfile
:param tag: str, A tag to add to the final image
:param dockerfile: str, path within the build context to ... | [
"def",
"build",
"(",
"cls",
",",
"path",
",",
"tag",
"=",
"None",
",",
"dockerfile",
"=",
"None",
")",
":",
"if",
"not",
"path",
":",
"raise",
"ConuException",
"(",
"'Please specify path to the directory containing the Dockerfile'",
")",
"client",
"=",
"get_clie... | Build the image from the provided dockerfile in path
:param path : str, path to the directory containing the Dockerfile
:param tag: str, A tag to add to the final image
:param dockerfile: str, path within the build context to the Dockerfile
:return: instance of DockerImage | [
"Build",
"the",
"image",
"from",
"the",
"provided",
"dockerfile",
"in",
"path"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L681-L711 |
10,272 | user-cont/conu | conu/backend/docker/image.py | DockerImage.layers | def layers(self, rev=True):
"""
Get list of DockerImage for every layer in image
:param rev: get layers rev
:return: list of DockerImages
"""
image_layers = [
DockerImage(None, identifier=x, pull_policy=DockerImagePullPolicy.NEVER)
for x in self.g... | python | def layers(self, rev=True):
"""
Get list of DockerImage for every layer in image
:param rev: get layers rev
:return: list of DockerImages
"""
image_layers = [
DockerImage(None, identifier=x, pull_policy=DockerImagePullPolicy.NEVER)
for x in self.g... | [
"def",
"layers",
"(",
"self",
",",
"rev",
"=",
"True",
")",
":",
"image_layers",
"=",
"[",
"DockerImage",
"(",
"None",
",",
"identifier",
"=",
"x",
",",
"pull_policy",
"=",
"DockerImagePullPolicy",
".",
"NEVER",
")",
"for",
"x",
"in",
"self",
".",
"get... | Get list of DockerImage for every layer in image
:param rev: get layers rev
:return: list of DockerImages | [
"Get",
"list",
"of",
"DockerImage",
"for",
"every",
"layer",
"in",
"image"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L725-L738 |
10,273 | user-cont/conu | conu/backend/docker/image.py | S2IDockerImage.extend | def extend(self, source, new_image_name, s2i_args=None):
"""
extend this s2i-enabled image using provided source, raises ConuException if
`s2i build` fails
:param source: str, source used to extend the image, can be path or url
:param new_image_name: str, name of the new, extend... | python | def extend(self, source, new_image_name, s2i_args=None):
"""
extend this s2i-enabled image using provided source, raises ConuException if
`s2i build` fails
:param source: str, source used to extend the image, can be path or url
:param new_image_name: str, name of the new, extend... | [
"def",
"extend",
"(",
"self",
",",
"source",
",",
"new_image_name",
",",
"s2i_args",
"=",
"None",
")",
":",
"s2i_args",
"=",
"s2i_args",
"or",
"[",
"]",
"c",
"=",
"self",
".",
"_s2i_command",
"(",
"[",
"\"build\"",
"]",
"+",
"s2i_args",
"+",
"[",
"so... | extend this s2i-enabled image using provided source, raises ConuException if
`s2i build` fails
:param source: str, source used to extend the image, can be path or url
:param new_image_name: str, name of the new, extended image
:param s2i_args: list of str, additional options and argumen... | [
"extend",
"this",
"s2i",
"-",
"enabled",
"image",
"using",
"provided",
"source",
"raises",
"ConuException",
"if",
"s2i",
"build",
"fails"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L775-L793 |
10,274 | user-cont/conu | conu/backend/docker/image.py | S2IDockerImage.usage | def usage(self):
"""
Provide output of `s2i usage`
:return: str
"""
c = self._s2i_command(["usage", self.get_full_name()])
with open(os.devnull, "w") as fd:
process = subprocess.Popen(c, stdout=fd, stderr=subprocess.PIPE)
_, output = process.commu... | python | def usage(self):
"""
Provide output of `s2i usage`
:return: str
"""
c = self._s2i_command(["usage", self.get_full_name()])
with open(os.devnull, "w") as fd:
process = subprocess.Popen(c, stdout=fd, stderr=subprocess.PIPE)
_, output = process.commu... | [
"def",
"usage",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"_s2i_command",
"(",
"[",
"\"usage\"",
",",
"self",
".",
"get_full_name",
"(",
")",
"]",
")",
"with",
"open",
"(",
"os",
".",
"devnull",
",",
"\"w\"",
")",
"as",
"fd",
":",
"process",
... | Provide output of `s2i usage`
:return: str | [
"Provide",
"output",
"of",
"s2i",
"usage"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/image.py#L795-L808 |
10,275 | user-cont/conu | conu/backend/origin/backend.py | OpenshiftBackend.http_request | def http_request(self, path="/", method="GET", host=None, port=None, json=False, data=None):
"""
perform a HTTP request
:param path: str, path within the request, e.g. "/api/version"
:param method: str, HTTP method
:param host: str, if None, set to 127.0.0.1
:param port:... | python | def http_request(self, path="/", method="GET", host=None, port=None, json=False, data=None):
"""
perform a HTTP request
:param path: str, path within the request, e.g. "/api/version"
:param method: str, HTTP method
:param host: str, if None, set to 127.0.0.1
:param port:... | [
"def",
"http_request",
"(",
"self",
",",
"path",
"=",
"\"/\"",
",",
"method",
"=",
"\"GET\"",
",",
"host",
"=",
"None",
",",
"port",
"=",
"None",
",",
"json",
"=",
"False",
",",
"data",
"=",
"None",
")",
":",
"host",
"=",
"host",
"or",
"'127.0.0.1'... | perform a HTTP request
:param path: str, path within the request, e.g. "/api/version"
:param method: str, HTTP method
:param host: str, if None, set to 127.0.0.1
:param port: str or int, if None, set to 8080
:param json: bool, should we expect json?
:param data: data to ... | [
"perform",
"a",
"HTTP",
"request"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/origin/backend.py#L62-L79 |
10,276 | user-cont/conu | conu/backend/nspawn/image.py | NspawnImage.system_requirements | def system_requirements():
"""
Check if all necessary packages are installed on system
:return: None or raise exception if some tooling is missing
"""
command_exists("systemd-nspawn",
["systemd-nspawn", "--version"],
"Command systemd-nspawn does not seems... | python | def system_requirements():
"""
Check if all necessary packages are installed on system
:return: None or raise exception if some tooling is missing
"""
command_exists("systemd-nspawn",
["systemd-nspawn", "--version"],
"Command systemd-nspawn does not seems... | [
"def",
"system_requirements",
"(",
")",
":",
"command_exists",
"(",
"\"systemd-nspawn\"",
",",
"[",
"\"systemd-nspawn\"",
",",
"\"--version\"",
"]",
",",
"\"Command systemd-nspawn does not seems to be present on your system\"",
"\"Do you have system with systemd\"",
")",
"command... | Check if all necessary packages are installed on system
:return: None or raise exception if some tooling is missing | [
"Check",
"if",
"all",
"necessary",
"packages",
"are",
"installed",
"on",
"system"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L156-L173 |
10,277 | user-cont/conu | conu/backend/nspawn/image.py | NspawnImage._generate_id | def _generate_id(self):
""" create new unique identifier """
name = self.name.replace(self.special_separator, "-").replace(".", "-")
loc = "\/"
if self.location:
loc = self.location
_id = "{PREFIX}{SEP}{NAME}{HASH}{SEP}".format(
PREFIX=constants.CONU_ARTIF... | python | def _generate_id(self):
""" create new unique identifier """
name = self.name.replace(self.special_separator, "-").replace(".", "-")
loc = "\/"
if self.location:
loc = self.location
_id = "{PREFIX}{SEP}{NAME}{HASH}{SEP}".format(
PREFIX=constants.CONU_ARTIF... | [
"def",
"_generate_id",
"(",
"self",
")",
":",
"name",
"=",
"self",
".",
"name",
".",
"replace",
"(",
"self",
".",
"special_separator",
",",
"\"-\"",
")",
".",
"replace",
"(",
"\".\"",
",",
"\"-\"",
")",
"loc",
"=",
"\"\\/\"",
"if",
"self",
".",
"loca... | create new unique identifier | [
"create",
"new",
"unique",
"identifier"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L209-L221 |
10,278 | user-cont/conu | conu/backend/nspawn/image.py | NspawnImage.pull | def pull(self):
"""
Pull this image from URL.
:return: None
"""
if not os.path.exists(CONU_IMAGES_STORE):
os.makedirs(CONU_IMAGES_STORE)
logger.debug(
"Try to pull: {} -> {}".format(self.location, self.local_location))
if not self._is_loc... | python | def pull(self):
"""
Pull this image from URL.
:return: None
"""
if not os.path.exists(CONU_IMAGES_STORE):
os.makedirs(CONU_IMAGES_STORE)
logger.debug(
"Try to pull: {} -> {}".format(self.location, self.local_location))
if not self._is_loc... | [
"def",
"pull",
"(",
"self",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"CONU_IMAGES_STORE",
")",
":",
"os",
".",
"makedirs",
"(",
"CONU_IMAGES_STORE",
")",
"logger",
".",
"debug",
"(",
"\"Try to pull: {} -> {}\"",
".",
"format",
"(",
"... | Pull this image from URL.
:return: None | [
"Pull",
"this",
"image",
"from",
"URL",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L232-L253 |
10,279 | user-cont/conu | conu/backend/nspawn/image.py | NspawnImage.run_via_binary | def run_via_binary(self, command=None, foreground=False, volumes=None,
additional_opts=None, default_options=None, name=None, *args, **kwargs):
"""
Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process
object
:param ... | python | def run_via_binary(self, command=None, foreground=False, volumes=None,
additional_opts=None, default_options=None, name=None, *args, **kwargs):
"""
Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process
object
:param ... | [
"def",
"run_via_binary",
"(",
"self",
",",
"command",
"=",
"None",
",",
"foreground",
"=",
"False",
",",
"volumes",
"=",
"None",
",",
"additional_opts",
"=",
"None",
",",
"default_options",
"=",
"None",
",",
"name",
"=",
"None",
",",
"*",
"args",
",",
... | Create new instance NspawnContianer in case of not running at foreground, in case foreground run, return process
object
:param command: list - command to run
:param foreground: bool - run process at foreground
:param volumes: list - put additional bind mounts
:param additional_o... | [
"Create",
"new",
"instance",
"NspawnContianer",
"in",
"case",
"of",
"not",
"running",
"at",
"foreground",
"in",
"case",
"foreground",
"run",
"return",
"process",
"object"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/image.py#L345-L403 |
10,280 | user-cont/conu | conu/utils/rpms.py | process_rpm_ql_line | def process_rpm_ql_line(line_str, allowed_keys):
"""
Checks single line of rpm-ql for correct keys
:param line_str: line to process
:param allowed_keys: list of allowed keys
:return: bool
"""
try:
name, key_str = line_str.split(' ', 1)
except ValueError:
logger.error("Fa... | python | def process_rpm_ql_line(line_str, allowed_keys):
"""
Checks single line of rpm-ql for correct keys
:param line_str: line to process
:param allowed_keys: list of allowed keys
:return: bool
"""
try:
name, key_str = line_str.split(' ', 1)
except ValueError:
logger.error("Fa... | [
"def",
"process_rpm_ql_line",
"(",
"line_str",
",",
"allowed_keys",
")",
":",
"try",
":",
"name",
",",
"key_str",
"=",
"line_str",
".",
"split",
"(",
"' '",
",",
"1",
")",
"except",
"ValueError",
":",
"logger",
".",
"error",
"(",
"\"Failed to split line '{0}... | Checks single line of rpm-ql for correct keys
:param line_str: line to process
:param allowed_keys: list of allowed keys
:return: bool | [
"Checks",
"single",
"line",
"of",
"rpm",
"-",
"ql",
"for",
"correct",
"keys"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/rpms.py#L29-L55 |
10,281 | user-cont/conu | conu/utils/rpms.py | check_signatures | def check_signatures(pkg_list, allowed_keys):
"""
Go through list of packages with signatures and check if all are properly signed
:param pkg_list: list of packages in format '%{name} %{SIGPGP:pgpsig}'
:param allowed_keys: list of allowed keys
:return: bool
"""
all_passed = True
for lin... | python | def check_signatures(pkg_list, allowed_keys):
"""
Go through list of packages with signatures and check if all are properly signed
:param pkg_list: list of packages in format '%{name} %{SIGPGP:pgpsig}'
:param allowed_keys: list of allowed keys
:return: bool
"""
all_passed = True
for lin... | [
"def",
"check_signatures",
"(",
"pkg_list",
",",
"allowed_keys",
")",
":",
"all_passed",
"=",
"True",
"for",
"line_str",
"in",
"pkg_list",
":",
"all_passed",
"&=",
"process_rpm_ql_line",
"(",
"line_str",
".",
"strip",
"(",
")",
",",
"allowed_keys",
")",
"if",
... | Go through list of packages with signatures and check if all are properly signed
:param pkg_list: list of packages in format '%{name} %{SIGPGP:pgpsig}'
:param allowed_keys: list of allowed keys
:return: bool | [
"Go",
"through",
"list",
"of",
"packages",
"with",
"signatures",
"and",
"check",
"if",
"all",
"are",
"properly",
"signed"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/rpms.py#L58-L72 |
10,282 | user-cont/conu | conu/backend/docker/container.py | DockerContainer.get_ports | def get_ports(self):
"""
get ports specified in container metadata
:return: list of str
"""
ports = []
container_ports = self.inspect(refresh=True)["NetworkSettings"]["Ports"]
if not container_ports:
return ports
for p in container_ports:
... | python | def get_ports(self):
"""
get ports specified in container metadata
:return: list of str
"""
ports = []
container_ports = self.inspect(refresh=True)["NetworkSettings"]["Ports"]
if not container_ports:
return ports
for p in container_ports:
... | [
"def",
"get_ports",
"(",
"self",
")",
":",
"ports",
"=",
"[",
"]",
"container_ports",
"=",
"self",
".",
"inspect",
"(",
"refresh",
"=",
"True",
")",
"[",
"\"NetworkSettings\"",
"]",
"[",
"\"Ports\"",
"]",
"if",
"not",
"container_ports",
":",
"return",
"p... | get ports specified in container metadata
:return: list of str | [
"get",
"ports",
"specified",
"in",
"container",
"metadata"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/container.py#L350-L363 |
10,283 | user-cont/conu | conu/apidefs/backend.py | Backend._clean_tmp_dirs | def _clean_tmp_dirs(self):
"""
Remove temporary dir associated with this backend instance.
:return: None
"""
def onerror(fnc, path, excinfo):
# we might not have rights to do this, the files could be owned by root
self.logger.info("we were not able to re... | python | def _clean_tmp_dirs(self):
"""
Remove temporary dir associated with this backend instance.
:return: None
"""
def onerror(fnc, path, excinfo):
# we might not have rights to do this, the files could be owned by root
self.logger.info("we were not able to re... | [
"def",
"_clean_tmp_dirs",
"(",
"self",
")",
":",
"def",
"onerror",
"(",
"fnc",
",",
"path",
",",
"excinfo",
")",
":",
"# we might not have rights to do this, the files could be owned by root",
"self",
".",
"logger",
".",
"info",
"(",
"\"we were not able to remove tempor... | Remove temporary dir associated with this backend instance.
:return: None | [
"Remove",
"temporary",
"dir",
"associated",
"with",
"this",
"backend",
"instance",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/backend.py#L147-L161 |
10,284 | user-cont/conu | conu/apidefs/backend.py | Backend._clean | def _clean(self):
"""
Method for cleaning according to object cleanup policy value
:return: None
"""
if CleanupPolicy.EVERYTHING in self.cleanup:
self.cleanup_containers()
self.cleanup_volumes()
self.cleanup_images()
... | python | def _clean(self):
"""
Method for cleaning according to object cleanup policy value
:return: None
"""
if CleanupPolicy.EVERYTHING in self.cleanup:
self.cleanup_containers()
self.cleanup_volumes()
self.cleanup_images()
... | [
"def",
"_clean",
"(",
"self",
")",
":",
"if",
"CleanupPolicy",
".",
"EVERYTHING",
"in",
"self",
".",
"cleanup",
":",
"self",
".",
"cleanup_containers",
"(",
")",
"self",
".",
"cleanup_volumes",
"(",
")",
"self",
".",
"cleanup_images",
"(",
")",
"self",
"... | Method for cleaning according to object cleanup policy value
:return: None | [
"Method",
"for",
"cleaning",
"according",
"to",
"object",
"cleanup",
"policy",
"value"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/apidefs/backend.py#L187-L206 |
10,285 | user-cont/conu | conu/backend/nspawn/backend.py | NspawnBackend.list_containers | def list_containers(self):
"""
list all available nspawn containers
:return: collection of instances of :class:`conu.backend.nspawn.container.NspawnContainer`
"""
data = run_cmd(["machinectl", "list", "--no-legend", "--no-pager"],
return_output=True)
... | python | def list_containers(self):
"""
list all available nspawn containers
:return: collection of instances of :class:`conu.backend.nspawn.container.NspawnContainer`
"""
data = run_cmd(["machinectl", "list", "--no-legend", "--no-pager"],
return_output=True)
... | [
"def",
"list_containers",
"(",
"self",
")",
":",
"data",
"=",
"run_cmd",
"(",
"[",
"\"machinectl\"",
",",
"\"list\"",
",",
"\"--no-legend\"",
",",
"\"--no-pager\"",
"]",
",",
"return_output",
"=",
"True",
")",
"output",
"=",
"[",
"]",
"reg",
"=",
"re",
"... | list all available nspawn containers
:return: collection of instances of :class:`conu.backend.nspawn.container.NspawnContainer` | [
"list",
"all",
"available",
"nspawn",
"containers"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/backend.py#L44-L60 |
10,286 | user-cont/conu | conu/backend/nspawn/backend.py | NspawnBackend.list_images | def list_images(self):
"""
list all available nspawn images
:return: collection of instances of :class:`conu.backend.nspawn.image.NspawnImage`
"""
# Fedora-Cloud-Base-27-1.6.x86_64 raw no 601.7M Sun 2017-11-05 08:30:10 CET \
# Sun 2017-11-05 08:30:10 CET
data... | python | def list_images(self):
"""
list all available nspawn images
:return: collection of instances of :class:`conu.backend.nspawn.image.NspawnImage`
"""
# Fedora-Cloud-Base-27-1.6.x86_64 raw no 601.7M Sun 2017-11-05 08:30:10 CET \
# Sun 2017-11-05 08:30:10 CET
data... | [
"def",
"list_images",
"(",
"self",
")",
":",
"# Fedora-Cloud-Base-27-1.6.x86_64 raw no 601.7M Sun 2017-11-05 08:30:10 CET \\",
"# Sun 2017-11-05 08:30:10 CET",
"data",
"=",
"os",
".",
"listdir",
"(",
"CONU_IMAGES_STORE",
")",
"output",
"=",
"[",
"]",
"for",
"name",
"i... | list all available nspawn images
:return: collection of instances of :class:`conu.backend.nspawn.image.NspawnImage` | [
"list",
"all",
"available",
"nspawn",
"images"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/backend.py#L62-L74 |
10,287 | user-cont/conu | conu/backend/nspawn/backend.py | NspawnBackend.cleanup_containers | def cleanup_containers(self):
"""
stop all container created by conu
:return: None
"""
for cont in self.list_containers():
if CONU_ARTIFACT_TAG in cont.name:
try:
logger.debug("removing container %s created by conu", cont)
... | python | def cleanup_containers(self):
"""
stop all container created by conu
:return: None
"""
for cont in self.list_containers():
if CONU_ARTIFACT_TAG in cont.name:
try:
logger.debug("removing container %s created by conu", cont)
... | [
"def",
"cleanup_containers",
"(",
"self",
")",
":",
"for",
"cont",
"in",
"self",
".",
"list_containers",
"(",
")",
":",
"if",
"CONU_ARTIFACT_TAG",
"in",
"cont",
".",
"name",
":",
"try",
":",
"logger",
".",
"debug",
"(",
"\"removing container %s created by conu... | stop all container created by conu
:return: None | [
"stop",
"all",
"container",
"created",
"by",
"conu"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/nspawn/backend.py#L76-L89 |
10,288 | user-cont/conu | conu/utils/__init__.py | check_port | def check_port(port, host, timeout=10):
"""
connect to port on host and return True on success
:param port: int, port to check
:param host: string, host address
:param timeout: int, number of seconds spent trying
:return: bool
"""
logger.info("trying to open connection to %s:%s", host, ... | python | def check_port(port, host, timeout=10):
"""
connect to port on host and return True on success
:param port: int, port to check
:param host: string, host address
:param timeout: int, number of seconds spent trying
:return: bool
"""
logger.info("trying to open connection to %s:%s", host, ... | [
"def",
"check_port",
"(",
"port",
",",
"host",
",",
"timeout",
"=",
"10",
")",
":",
"logger",
".",
"info",
"(",
"\"trying to open connection to %s:%s\"",
",",
"host",
",",
"port",
")",
"sock",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
... | connect to port on host and return True on success
:param port: int, port to check
:param host: string, host address
:param timeout: int, number of seconds spent trying
:return: bool | [
"connect",
"to",
"port",
"on",
"host",
"and",
"return",
"True",
"on",
"success"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L54-L76 |
10,289 | user-cont/conu | conu/utils/__init__.py | get_selinux_status | def get_selinux_status():
"""
get SELinux status of host
:return: string, one of Enforced, Permissive, Disabled
"""
getenforce_command_exists()
# alternatively, we could read directly from /sys/fs/selinux/{enforce,status}, but status is
# empty (why?) and enforce doesn't tell whether SELinu... | python | def get_selinux_status():
"""
get SELinux status of host
:return: string, one of Enforced, Permissive, Disabled
"""
getenforce_command_exists()
# alternatively, we could read directly from /sys/fs/selinux/{enforce,status}, but status is
# empty (why?) and enforce doesn't tell whether SELinu... | [
"def",
"get_selinux_status",
"(",
")",
":",
"getenforce_command_exists",
"(",
")",
"# alternatively, we could read directly from /sys/fs/selinux/{enforce,status}, but status is",
"# empty (why?) and enforce doesn't tell whether SELinux is disabled or not",
"o",
"=",
"run_cmd",
"(",
"[",
... | get SELinux status of host
:return: string, one of Enforced, Permissive, Disabled | [
"get",
"SELinux",
"status",
"of",
"host"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L79-L90 |
10,290 | user-cont/conu | conu/utils/__init__.py | random_str | def random_str(size=10):
"""
create random string of selected size
:param size: int, length of the string
:return: the string
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(size)) | python | def random_str(size=10):
"""
create random string of selected size
:param size: int, length of the string
:return: the string
"""
return ''.join(random.choice(string.ascii_lowercase) for _ in range(size)) | [
"def",
"random_str",
"(",
"size",
"=",
"10",
")",
":",
"return",
"''",
".",
"join",
"(",
"random",
".",
"choice",
"(",
"string",
".",
"ascii_lowercase",
")",
"for",
"_",
"in",
"range",
"(",
"size",
")",
")"
] | create random string of selected size
:param size: int, length of the string
:return: the string | [
"create",
"random",
"string",
"of",
"selected",
"size"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L102-L109 |
10,291 | user-cont/conu | conu/utils/__init__.py | run_cmd | def run_cmd(cmd, return_output=False, ignore_status=False, log_output=True, **kwargs):
"""
run provided command on host system using the same user as you invoked this code, raises
subprocess.CalledProcessError if it fails
:param cmd: list of str
:param return_output: bool, return output of the comm... | python | def run_cmd(cmd, return_output=False, ignore_status=False, log_output=True, **kwargs):
"""
run provided command on host system using the same user as you invoked this code, raises
subprocess.CalledProcessError if it fails
:param cmd: list of str
:param return_output: bool, return output of the comm... | [
"def",
"run_cmd",
"(",
"cmd",
",",
"return_output",
"=",
"False",
",",
"ignore_status",
"=",
"False",
",",
"log_output",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
".",
"debug",
"(",
"'command: \"%s\"'",
"%",
"' '",
".",
"join",
"(",
"cm... | run provided command on host system using the same user as you invoked this code, raises
subprocess.CalledProcessError if it fails
:param cmd: list of str
:param return_output: bool, return output of the command
:param ignore_status: bool, do not fail in case nonzero return code
:param log_output: ... | [
"run",
"provided",
"command",
"on",
"host",
"system",
"using",
"the",
"same",
"user",
"as",
"you",
"invoked",
"this",
"code",
"raises",
"subprocess",
".",
"CalledProcessError",
"if",
"it",
"fails"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L112-L141 |
10,292 | user-cont/conu | conu/utils/__init__.py | command_exists | def command_exists(command, noop_invocation, exc_msg):
"""
Verify that the provided command exists. Raise CommandDoesNotExistException in case of an
error or if the command does not exist.
:param command: str, command to check (python 3 only)
:param noop_invocation: list of str, command to check (p... | python | def command_exists(command, noop_invocation, exc_msg):
"""
Verify that the provided command exists. Raise CommandDoesNotExistException in case of an
error or if the command does not exist.
:param command: str, command to check (python 3 only)
:param noop_invocation: list of str, command to check (p... | [
"def",
"command_exists",
"(",
"command",
",",
"noop_invocation",
",",
"exc_msg",
")",
":",
"try",
":",
"found",
"=",
"bool",
"(",
"shutil",
".",
"which",
"(",
"command",
")",
")",
"# py3 only",
"except",
"AttributeError",
":",
"# py2 branch",
"try",
":",
"... | Verify that the provided command exists. Raise CommandDoesNotExistException in case of an
error or if the command does not exist.
:param command: str, command to check (python 3 only)
:param noop_invocation: list of str, command to check (python 2 only)
:param exc_msg: str, message of exception when co... | [
"Verify",
"that",
"the",
"provided",
"command",
"exists",
".",
"Raise",
"CommandDoesNotExistException",
"in",
"case",
"of",
"an",
"error",
"or",
"if",
"the",
"command",
"does",
"not",
"exist",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L173-L200 |
10,293 | user-cont/conu | conu/utils/__init__.py | check_docker_command_works | def check_docker_command_works():
"""
Verify that dockerd and docker binary works fine. This is performed by calling `docker
version`, which also checks server API version.
:return: bool, True if all is good, otherwise ConuException or CommandDoesNotExistException
is thrown
"""
tr... | python | def check_docker_command_works():
"""
Verify that dockerd and docker binary works fine. This is performed by calling `docker
version`, which also checks server API version.
:return: bool, True if all is good, otherwise ConuException or CommandDoesNotExistException
is thrown
"""
tr... | [
"def",
"check_docker_command_works",
"(",
")",
":",
"try",
":",
"out",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"\"docker\"",
",",
"\"version\"",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
",",
"universal_newlines",
"=",
"True",
")",
"exc... | Verify that dockerd and docker binary works fine. This is performed by calling `docker
version`, which also checks server API version.
:return: bool, True if all is good, otherwise ConuException or CommandDoesNotExistException
is thrown | [
"Verify",
"that",
"dockerd",
"and",
"docker",
"binary",
"works",
"fine",
".",
"This",
"is",
"performed",
"by",
"calling",
"docker",
"version",
"which",
"also",
"checks",
"server",
"API",
"version",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L250-L277 |
10,294 | user-cont/conu | conu/utils/__init__.py | export_docker_container_to_directory | def export_docker_container_to_directory(client, container, path):
"""
take selected docker container, create an archive out of it and
unpack it to a selected location
:param client: instance of docker.APIClient
:param container: instance of DockerContainer
:param path: str, path to a directory... | python | def export_docker_container_to_directory(client, container, path):
"""
take selected docker container, create an archive out of it and
unpack it to a selected location
:param client: instance of docker.APIClient
:param container: instance of DockerContainer
:param path: str, path to a directory... | [
"def",
"export_docker_container_to_directory",
"(",
"client",
",",
"container",
",",
"path",
")",
":",
"# we don't do this because of a bug in docker:",
"# https://bugzilla.redhat.com/show_bug.cgi?id=1570828",
"# stream, _ = client.get_archive(container.get_id(), \"/\")",
"check_docker_com... | take selected docker container, create an archive out of it and
unpack it to a selected location
:param client: instance of docker.APIClient
:param container: instance of DockerContainer
:param path: str, path to a directory, doesn't need to exist
:return: None | [
"take",
"selected",
"docker",
"container",
"create",
"an",
"archive",
"out",
"of",
"it",
"and",
"unpack",
"it",
"to",
"a",
"selected",
"location"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/utils/__init__.py#L335-L386 |
10,295 | user-cont/conu | conu/backend/podman/backend.py | PodmanBackend.get_version | def get_version(self):
"""
return 3-tuple of version info or None
:return: (str, str, str)
"""
raw_version = run_cmd(["podman", "version"], return_output=True)
regex = re.compile(r"Version:\s*(\d+)\.(\d+)\.(\d+)")
match = regex.findall(raw_version)
try:
... | python | def get_version(self):
"""
return 3-tuple of version info or None
:return: (str, str, str)
"""
raw_version = run_cmd(["podman", "version"], return_output=True)
regex = re.compile(r"Version:\s*(\d+)\.(\d+)\.(\d+)")
match = regex.findall(raw_version)
try:
... | [
"def",
"get_version",
"(",
"self",
")",
":",
"raw_version",
"=",
"run_cmd",
"(",
"[",
"\"podman\"",
",",
"\"version\"",
"]",
",",
"return_output",
"=",
"True",
")",
"regex",
"=",
"re",
".",
"compile",
"(",
"r\"Version:\\s*(\\d+)\\.(\\d+)\\.(\\d+)\"",
")",
"mat... | return 3-tuple of version info or None
:return: (str, str, str) | [
"return",
"3",
"-",
"tuple",
"of",
"version",
"info",
"or",
"None"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/backend.py#L92-L105 |
10,296 | user-cont/conu | conu/backend/podman/backend.py | PodmanBackend.list_containers | def list_containers(self):
"""
List all available podman containers.
:return: collection of instances of :class:`conu.PodmanContainer`
"""
containers = []
for container in self._list_podman_containers():
identifier = container["ID"]
name = contain... | python | def list_containers(self):
"""
List all available podman containers.
:return: collection of instances of :class:`conu.PodmanContainer`
"""
containers = []
for container in self._list_podman_containers():
identifier = container["ID"]
name = contain... | [
"def",
"list_containers",
"(",
"self",
")",
":",
"containers",
"=",
"[",
"]",
"for",
"container",
"in",
"self",
".",
"_list_podman_containers",
"(",
")",
":",
"identifier",
"=",
"container",
"[",
"\"ID\"",
"]",
"name",
"=",
"container",
"[",
"\"Names\"",
"... | List all available podman containers.
:return: collection of instances of :class:`conu.PodmanContainer` | [
"List",
"all",
"available",
"podman",
"containers",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/backend.py#L116-L137 |
10,297 | user-cont/conu | conu/backend/podman/backend.py | PodmanBackend.list_images | def list_images(self):
"""
List all available podman images.
:return: collection of instances of :class:`conu.PodmanImage`
"""
images = []
for image in self._list_all_podman_images():
try:
i_name, tag = parse_reference(image["names"][0])
... | python | def list_images(self):
"""
List all available podman images.
:return: collection of instances of :class:`conu.PodmanImage`
"""
images = []
for image in self._list_all_podman_images():
try:
i_name, tag = parse_reference(image["names"][0])
... | [
"def",
"list_images",
"(",
"self",
")",
":",
"images",
"=",
"[",
"]",
"for",
"image",
"in",
"self",
".",
"_list_all_podman_images",
"(",
")",
":",
"try",
":",
"i_name",
",",
"tag",
"=",
"parse_reference",
"(",
"image",
"[",
"\"names\"",
"]",
"[",
"0",
... | List all available podman images.
:return: collection of instances of :class:`conu.PodmanImage` | [
"List",
"all",
"available",
"podman",
"images",
"."
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/podman/backend.py#L139-L155 |
10,298 | user-cont/conu | conu/backend/docker/utils.py | inspect_to_metadata | def inspect_to_metadata(metadata_object, inspect_data):
"""
process data from `docker inspect` and update provided metadata object
:param metadata_object: instance of Metadata
:param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()`
:return: instance of Metadata
""... | python | def inspect_to_metadata(metadata_object, inspect_data):
"""
process data from `docker inspect` and update provided metadata object
:param metadata_object: instance of Metadata
:param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()`
:return: instance of Metadata
""... | [
"def",
"inspect_to_metadata",
"(",
"metadata_object",
",",
"inspect_data",
")",
":",
"identifier",
"=",
"graceful_get",
"(",
"inspect_data",
",",
"'Id'",
")",
"if",
"identifier",
":",
"if",
"\":\"",
"in",
"identifier",
":",
"# format of image name from docker inspect:... | process data from `docker inspect` and update provided metadata object
:param metadata_object: instance of Metadata
:param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()`
:return: instance of Metadata | [
"process",
"data",
"from",
"docker",
"inspect",
"and",
"update",
"provided",
"metadata",
"object"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/utils.py#L13-L62 |
10,299 | user-cont/conu | conu/backend/docker/utils.py | inspect_to_container_metadata | def inspect_to_container_metadata(c_metadata_object, inspect_data, image_instance):
"""
process data from `docker container inspect` and update provided container metadata object
:param c_metadata_object: instance of ContainerMetadata
:param inspect_data: dict, metadata from `docker inspect` or `docker... | python | def inspect_to_container_metadata(c_metadata_object, inspect_data, image_instance):
"""
process data from `docker container inspect` and update provided container metadata object
:param c_metadata_object: instance of ContainerMetadata
:param inspect_data: dict, metadata from `docker inspect` or `docker... | [
"def",
"inspect_to_container_metadata",
"(",
"c_metadata_object",
",",
"inspect_data",
",",
"image_instance",
")",
":",
"inspect_to_metadata",
"(",
"c_metadata_object",
",",
"inspect_data",
")",
"status",
"=",
"ContainerStatus",
".",
"get_from_docker",
"(",
"graceful_get"... | process data from `docker container inspect` and update provided container metadata object
:param c_metadata_object: instance of ContainerMetadata
:param inspect_data: dict, metadata from `docker inspect` or `dockert_client.images()`
:param image_instance: instance of DockerImage
:return: instance of C... | [
"process",
"data",
"from",
"docker",
"container",
"inspect",
"and",
"update",
"provided",
"container",
"metadata",
"object"
] | 08caae7bb6bdd265b55bb106c3da6a7946a5a352 | https://github.com/user-cont/conu/blob/08caae7bb6bdd265b55bb106c3da6a7946a5a352/conu/backend/docker/utils.py#L65-L132 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.