run-isolated - API reference
Top-level reexported definitions
run_isolated
Run commands in isolated environments, e.g. Docker containers.
FEATURES = {'run-isolated': VERSION}
module-attribute
The list of features supported by the run-isolated library.
VERSION = '0.1.0'
module-attribute
The run-isolated library version, semver-like.
Config
dataclass
Runtime configuration for the run-isolated library.
Source code in src/run_isolated/defs.py
log
instance-attribute
The logger to send diagnostic, informational, and error messages to.
Run commands within a Docker container
run_isolated.rdocker.Config
dataclass
Bases: Config
Runtime configuration for the run-i-docker
tool.
Source code in src/run_isolated/rdocker.py
gid
instance-attribute
The account group ID to use within the container.
uid
instance-attribute
The account user ID to use within the container.
run_isolated.rdocker.ContainerVolume
dataclass
A single directory to be mounted within the container.
Source code in src/run_isolated/rdocker.py
external
instance-attribute
The full path to the directory on the host.
internal
instance-attribute
The path within the container that the directory will be mounted on.
readonly
instance-attribute
Mount the directory read-only.
run_isolated.rdocker.Container
dataclass
A representation of a Docker container.
Source code in src/run_isolated/rdocker.py
123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 |
|
cid
instance-attribute
The ID string of the container.
run_command(cmd, ugid=None, workdir=None)
Run a command in the container, check for errors.
Source code in src/run_isolated/rdocker.py
run_command_output(cmd, ugid=None, workdir=None)
Run a command in the container, check for errors.
Source code in src/run_isolated/rdocker.py
start_container(cfg, container, *, name=None, volumes=None, workdir=None)
classmethod
Start a Docker container, stop it when done, record it in a Config
object.
Source code in src/run_isolated/rdocker.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 |
|
Docker container errors
run_isolated.rdocker.DockerError
dataclass
Bases: Exception
An error that occurred while handling the Docker container.
Source code in src/run_isolated/rdocker.py
run_isolated.rdocker.CommandError
dataclass
Bases: DockerError
An error related to running a command.
Source code in src/run_isolated/rdocker.py
cmd
instance-attribute
The command we tried to run.
cmdstr
property
Join the words of the command.
run_isolated.rdocker.CommandRunError
dataclass
Bases: CommandError
An error that occurred while trying to run a command.
Source code in src/run_isolated/rdocker.py
run_isolated.rdocker.CommandFailError
dataclass
Bases: CommandError
A command that we tried to run failed.
Source code in src/run_isolated/rdocker.py
err
instance-attribute
The error that occurred.
__str__()
Provide a human-readable error description.
run_isolated.rdocker.CommandDecodeOutputError
dataclass
Bases: CommandError
A command that we tried to run failed.
Source code in src/run_isolated/rdocker.py
err
instance-attribute
The error that occurred.
Helper utility functions
run_isolated.util.DEFAULT_LOGGER_NAME = 'run_isolated'
module-attribute
The default name for the logger created by build_logger
.
run_isolated.util.build_logger(*, name=DEFAULT_LOGGER_NAME, quiet=False, verbose=False)
cached
Build a logger that outputs to the standard output and error streams.
Messages of level WARNING
and higher go to the standard error stream.
If quiet
is false, messages of level INFO
go to the standard error stream.
If verbose
is true, messages of level DEBUG
also go to the standard error stream.