Utils module¶
-
class
rebasehelper.utils.
ConsoleHelper
[source]¶ Class for command line interaction with the user.
-
classmethod
cprint
(message, color=None)[source]¶ Print colored output if possible
Parameters: - color – color to be used in the output
- message – string to be printed out
-
static
get_message
(message, default_yes=True, any_input=False)[source]¶ Function for command line messages
Parameters: - message – prompt string
- default_yes – If the default value is YES
- any_input – if True, return input without checking it first
Returns: True or False, based on user’s input
-
classmethod
should_use_colors
(conf)[source]¶ Determine whether ansi colors should be used for CLI output
-
use_colors
= False¶
-
classmethod
-
exception
rebasehelper.utils.
DownloadError
[source]¶ Exception indicating that download of a file failed.
-
class
rebasehelper.utils.
DownloadHelper
[source]¶ Class for downloading sources defined in SPEC file
-
static
download_file
(url, destination_path, timeout=10, blocksize=8192)[source]¶ Method for downloading file from HTTP, HTTPS and FTP URL.
Parameters: - url – URL from which to download the file
- destination_path – path where to store downloaded file
- timeout – timeout in seconds for blocking actions like connecting, etc.
- blocksize – size in Bytes of blocks used for downloading the file and reporting progress
Returns: None
-
static
progress
(download_total, downloaded, start_time)[source]¶ The function prints download progress and remaining time of the download directly to the standard output.
Parameters: - download_total (int or float) – size of the file which is being downloaded
- downloaded (int or float) – already downloaded size of the file
- start_time (float) – time in seconds since the epoch from the point when the download started. This is used to calculate the remaining time of the download.
Returns: None
-
static
-
class
rebasehelper.utils.
GitHelper
[source]¶ Class which operates with git repositories
-
GIT_USER_EMAIL
= 'rebase-helper@localhost.local'¶
-
GIT_USER_NAME
= 'rebase-helper'¶
-
-
class
rebasehelper.utils.
KojiHelper
[source]¶ -
baseurl
= 'http://kojipkgs.fedoraproject.org/work/'¶
-
baseurl_pkg
= 'https://kojipkgs.fedoraproject.org/packages/'¶
-
ca_cert
= '/home/docs/.fedora-server-ca.cert'¶
-
cert
= '/home/docs/.fedora.cert'¶
-
classmethod
download_build
(build_id, destination)[source]¶ Downloads all x86_64 RPMs and logs of a Koji build
Parameters: - build_id – Koji build ID
- destination – target path
Returns: (list of paths to RPMs, list of paths to logs)
-
functional
= False¶
-
classmethod
get_latest_build
(package)[source]¶ Searches for the latest Koji build of a package
Parameters: package – package name Returns: (latest version, Koji build ID)
-
koji_web
= 'koji.fedoraproject.org'¶
-
scratch_url
= 'http://koji.fedoraproject.org/work/'¶
-
server
= 'https://koji.fedoraproject.org/kojihub'¶
-
-
exception
rebasehelper.utils.
LookasideCacheError
[source]¶ Exception indicating a problem accessing lookaside cache
-
class
rebasehelper.utils.
LookasideCacheHelper
[source]¶ Class for downloading files from Fedora/RHEL lookaside cache
-
rpkg_config_dir
= '/etc/rpkg'¶
-
-
class
rebasehelper.utils.
PathHelper
[source]¶ Class which finds a file or files in specific directory
-
static
find_all_files
(top_path, pattern)[source]¶ Finds a file that matches the given ‘pattern’ recursively starting in the ‘top_path’ directory. If found, returns full path to the first occurrence of the file, otherwise returns None.
-
static
find_all_files_current_dir
(top_path, pattern)[source]¶ Finds all files that matches the given ‘pattern’ in the ‘top_path’ directory. If found, returns fields of all files, otherwise returns None.
-
static
find_first_dir_with_file
(top_path, pattern)[source]¶ Finds a file that matches the given ‘pattern’ recursively starting in the ‘top_path’ directory. If found, returns full path to the directory with first occurrence of the file, otherwise returns None.
-
static
-
class
rebasehelper.utils.
ProcessHelper
[source]¶ Class for execution subprocess
-
DEV_NULL
= '/dev/null'¶
-
static
run_subprocess
(cmd, input=None, output=None)[source]¶ Runs the passed command as a subprocess.
Parameters: - cmd – command with arguments to be run
- input – file to read the input from. If None, read from STDIN
- output – file to write the output of the command. If None, write to STDOUT
Returns: exit code of the process
-
static
run_subprocess_cwd
(cmd, cwd=None, input=None, output=None, shell=False)[source]¶ Runs the passed command as a subprocess in different working directory.
Parameters: - cmd – command with arguments to be run
- cwd – the directory to change the working dir to
- input – file to read the input from. If None, read from STDIN
- output – file to write the output of the command. If None, write to STDOUT
- shell – if to run the command as shell command (default: False)
Returns: exit code of the process
-
static
run_subprocess_cwd_env
(cmd, cwd=None, env=None, input=None, output=None, shell=False)[source]¶ Runs the passed command as a subprocess in different working directory with possibly changed ENVIRONMENT VARIABLES.
Parameters: - cmd – command with arguments to be run
- cwd – the directory to change the working dir to
- env – dictionary with ENVIRONMENT VARIABLES to define
- input – file to read the input from. If None, read from STDIN
- output – file to write the output of the command. If None, write to STDOUT
- shell – if to run the command as shell command (default: False)
Returns: exit code of the process
-
static
run_subprocess_env
(cmd, env=None, input=None, output=None, shell=False)[source]¶ Runs the passed command as a subprocess with possibly changed ENVIRONMENT VARIABLES.
Parameters: - cmd – command with arguments to be run
- env – dictionary with ENVIRONMENT VARIABLES to define
- input – file to read the input from. If None, read from STDIN
- output – file to write the output of the command. If None, write to STDOUT
- shell – if to run the command as shell command (default: False)
Returns: exit code of the process
-
-
class
rebasehelper.utils.
RpmHelper
[source]¶ Helper class for doing various tasks with RPM database, packages, …
-
ARCHES
= None¶
-
static
all_packages_installed
(pkg_names=None)[source]¶ Check if all packages in passed list are installed.
Parameters: pkg_names – iterable with package named to check for Returns: True if all packages are installed, False if at least one package is not installed.
-
static
get_header_from_rpm
(rpm_name)[source]¶ Function returns a rpm header from given rpm package for later on analysis
Parameters: rpm_name – Returns:
-
static
get_info_from_rpm
(rpm_name, info)[source]¶ Method returns a name of the package from RPM file format
Parameters: pkg_name – Returns:
-
static
install_build_dependencies
(spec_path=None, assume_yes=False)[source]¶ Install all build requires for a package using PolicyKits
Parameters: spec_path – absolute path to SPEC file Returns:
-