Filesystem parameters

class versuchung.files.File(default_filename='', binary=False)[source]

Can be used as: input parameter and output parameter

The File type represents the content of a single file. Its contents can be read and written most easily with the value property.

Alternatively, the method write() appends new content if the parameter append is set to True.

NB: The content of the file is flushed only after the experiment finishes. Use flush() to force writing the buffered data to disk before the experiment finishes.

copy_contents(filename)[source]

Read the given file and replace the current .value with the files content.

Flushes automatically afterwards.

flush()[source]

Flush the cached content of the file to disk

make_executable()[source]

makes a file exectuable (chmod +x $file)

path
Returns:string – path to the file/directory
value

This attribute can be read and written and represent the content of the specified file

write(content, append=False)[source]

Similar to the value property. If the parameter append is False, then the property value is reset (i.e., overwritten), otherwise the content is appendend

class versuchung.files.Executable(default_filename)[source]

Can be used as: input parameter

An executable is a versuchung.files.File that only references an executable. It checksums the executable and puts the checksum into the metadata. The executable is never changed.

execute(cmdline, *args)[source]

Does start the executable with meth:versuchung.execute.shell and args, which is of type list, as arguments.

path
Returns:string – path to the file/directory
class versuchung.files.Directory(default_filename='', filename_filter='*')[source]

Can be used as: input parameter and output parameter

Represents the contents of directory. The filename_filter is a glob/fnmatch expression to filter the directories content and to ensure that no file is generated that does not fit this pattern. An useful example of this is an output Directory that matches only *.log files and is directly located in the result directory:

outputs = {
“logs”: Directory(“.”, filename_filter=”*.log”)

}

It can also be used with the with-keyword to change the current working directory temporarily to this directory:

with directory as dir:
   # Do something with adjusted current working directory
   print os.curdir
mirror_directory(path, include_closure=None)[source]

Copies the contents of the given directory to this directory.

The include closure is a function, which checks for every (absolute) path in the origin directory, if it is mirrored. If it is None, all files are included.

new_directory(name)[source]

Generate a new Directory in the directory. The directory <name> must not be present before

new_file(name, compressed=False)[source]

Generate a new File in the directory. It will be flushed automatically if the experiment is over.

path
Returns:string – path to the file/directory
value
Returns:list – directories and files in given directory