System utils
available_cpu()
¶
delete_temp_files(prefix)
¶
Delete temporary files with the given prefix
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prefix
|
A string with the prefix of the temporary files to delete. |
required |
Source code in magenpy/utils/system_utils.py
get_filenames(path, extension=None)
¶
Obtain valid and full path names given the provided path
or prefix and extensions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
A string with the path prefix or full path. |
required | |
extension
|
The extension for the class of files to search for. |
None
|
Returns:
Type | Description |
---|---|
A list of strings with the full paths of the files/folders. |
Source code in magenpy/utils/system_utils.py
get_memory_usage()
¶
Returns:
Type | Description |
---|---|
The current memory usage of the running process in Mega Bytes (MB) |
get_peak_memory_usage(include_children=False)
¶
Get the peak memory usage of the running process in Mega Bytes (MB).
Warning
This function is only available on Unix-based systems for now.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
include_children
|
A boolean flag to include the memory usage of the child processes. |
False
|
Returns:
Type | Description |
---|---|
The peak memory usage of the running process in Mega Bytes (MB). |
Source code in magenpy/utils/system_utils.py
glob_s3_path(path)
¶
Get the list of files/folders in the provided AWS S3 path. This works with wildcards.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
A string with the S3 path to list files/folders from. |
required |
Returns:
Type | Description |
---|---|
A list of strings with the full paths of the files/folders. |
Source code in magenpy/utils/system_utils.py
is_cmd_tool(name)
¶
Check whether name
is on PATH and marked as executable.
From: https://stackoverflow.com/a/34177358
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
A string with the name of the command-line tool. |
required |
Returns:
Type | Description |
---|---|
True if the command-line tool is available, False otherwise. |
Source code in magenpy/utils/system_utils.py
is_path_writable(path)
¶
Check whether the user has write-access to the provided path
.
This function supports checking for nested directories (i.e.,
we iterate upwards until finding a parent directory that currently
exists, and we check the write-access of that directory).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
A string with the path to check. |
required |
Returns:
Type | Description |
---|---|
True if the path is writable, False otherwise. |
Source code in magenpy/utils/system_utils.py
makedir(dirs)
¶
Create directories on the filesystem, recursively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dirs
|
A string or list of strings with the paths to create. |
required |
Source code in magenpy/utils/system_utils.py
run_shell_script(cmd)
¶
Run the shell script given the command prompt in cmd
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cmd
|
A string with the shell command to run. |
required |
Returns:
Type | Description |
---|---|
The result of the shell command. |
Source code in magenpy/utils/system_utils.py
valid_url(path)
¶
Check whether the provided path
is a valid URL.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
A string with the URL to check. |
required |
Returns:
Type | Description |
---|---|
True if the URL is valid, False otherwise. |