Index
Overview
os provides a platform-independent interface to operating system functionality.
Functions
def chdir
chdir(dir)
changes the current working directory to the named directory.
Arguments
name | type | description |
---|---|---|
dir | string | target dir |
def command
command(command, shell=False, dir="", combined=False, env=[])
runs the command and returns its standard output. If the exit code it different to zero, an error is triggered.
Arguments
name | type | description |
---|---|---|
shell | bool | if True execute the command inside of a shell. |
dir | string | working directory of the command. |
combined | bool | if True returns combined standard output and standard error. |
env | list | specifies the environment of the process, each value of the listshould follow the pattern “key=value”. |
def getenv
getenv(key) dir
retrieves the value of the environment variable named by the key.
Arguments
name | type | description |
---|---|---|
key | string | name of the environment variable |
def getwd
getwd() dir
returns a rooted path name corresponding to the current directory.
def mkdir
mkdir(name, perms=0o777)
creates a new directory with the specified name and permission bits (before umask).
Arguments
name | type | description |
---|---|---|
name | string | name of the folder to be created |
perms | int | optional, permission of the folder |
def mkdir_all
mkdir_all(name, perms=0o777)
creates a new directory with the specified name and permission bits (before umask).
Arguments
name | type | description |
---|---|---|
name | string | name of the folder to be created |
perms | int | optional, permission of the folder |
def read_file
read_file(filename) string
reads the file named by filename and returns the contents.
Arguments
name | type | description |
---|---|---|
filename | string | name of the file to be written |
data | string | content to be witten to the file |
perms | int | optional, permission of the file |
def remove
remove(name)
removes the named file or (empty) directory.
Arguments
name | type | description |
---|---|---|
name | string | name of the file or directory to be deleted |
def remove_all
remove_all(path)
removes path and any children it contains. It removes everything it can but returns the first error it encounters.
Arguments
name | type | description |
---|---|---|
name | string | path to be deleted |
def rename
rename(oldpath, newpath)
renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. OS-specific restrictions may apply when oldpath and newpath are in different directories.
Arguments
name | type | description |
---|---|---|
oldpath | string | old path |
newpath | string | new path |
def setenv
setenv(key, value) dir
sets the value of the environment variable named by the key.
Arguments
name | type | description |
---|---|---|
key | string | name of the environment variable |
value | string | value of the environment variable |
def temp_dir
temp_dir()
returns the default directory to use for temporary files.
def write_file
write_file(filename, data, perms=0o644)
retrieves the value of the environment variable named by the key.
Arguments
name | type | description |
---|---|---|
filename | string | name of the file to be written |
data | string | content to be witten to the file |
perms | int | optional, permission of the file |