butterfly.runmanager module

Runmanager for butterfly.

Run manager is only useful for running OpenFOAM for Windows which runs in a docker container. For linux systems simply use .bash files or libraries such as pyFOAM.

class butterfly.runmanager.RunManager(project_name)[source]

Bases: object

RunManager to write and run OpenFOAM commands through batch files.

Run manager is currently only useful for running OpenFOAM for Windows which runs in a docker container. For linux systems simply use .bash files or libraries such as pyFOAM.

ToString()[source]

Overwrite .NET ToString method.

check_file_contents(files, mute=False)[source]

Check files for content and print them out if any.

Parameters:files – A list of ASCII files.
Returns:(hasContent, content) hasContent: A boolean that shows if there is any contents. content: Files content if any
command(cmd, args=None, decomposeParDict=None, include_header=True)[source]

Get command line for an OpenFOAM command in parallel or serial.

Parameters:
  • cmd – An OpenFOAM command.
  • args – List of optional arguments for command. e.g. (‘c’, ‘latestTime’)
  • decomposeParDict – decomposeParDict for parallel runs (default: None).
  • include_header – Include header lines to set up the environment (default: True).
  • tee – Include tee in command line.
Returns:

(cmd, logfiles, errorfiles)

container_id

Container ID.

duplicate()[source]

Return a copy of this object.

ensure_user_is_admin()[source]

Ensure user is logged in as admin.

If user is not admin raise UserNotAdminError.

get_container_id()[source]

Get OpenFOAM’s container id.

get_pid(command, timeout=5)[source]

Get pid of a command.

get_shellinit()[source]

Get shellinit for setting up initial environment for docker.

header()[source]

Get header for batch files.

is_user_admin

Return True if user is admin.

pid

Return PID for the latest command.

run(command, args=None, decomposeParDict=None, wait=True)[source]

Run OpenFOAM command.

shellinit = None
start_openfoam()[source]

Start OpenFOAM for Windows image from batch file.

terminate(pid=None, force=False)[source]

Kill the command using the pid.

exception butterfly.runmanager.UserNotAdminError[source]

Bases: exceptions.Exception

Exception for non-admin users.