mltk.utils.system

General system utilities

See the source code on Github: mltk/utils/system.py

Functions

get_current_os()

Return the current OS handle, windows, linux or osx

get_username()

Return the current username (which is assumed to be the directory name of the HOME directory)

has_admin()

Return if the script has admin permissions

is_linux()

Return if the script is running on Linux

is_osx()

Return if the script is running on OSX

is_windows()

Return if the script is running on Windows

make_path_executable(path)

Set the executable permissions of the given executable path

raise_signal([sig])

Raise a termination signal and kill the current script

send_signal([sig, pid])

Send a signal to the current process and all children processes

get_current_os()[source]

Return the current OS handle, windows, linux or osx

Return type:

str

is_windows()[source]

Return if the script is running on Windows

Return type:

bool

is_linux()[source]

Return if the script is running on Linux

Return type:

bool

is_osx()[source]

Return if the script is running on OSX

Return type:

bool

has_admin()[source]

Return if the script has admin permissions

Return type:

bool

get_username()[source]

Return the current username (which is assumed to be the directory name of the HOME directory)

Return type:

str

raise_signal(sig=Signals.SIGINT)[source]

Raise a termination signal and kill the current script

make_path_executable(path)[source]

Set the executable permissions of the given executable path

Parameters:

path (str) –

send_signal(sig=Signals.SIGINT, pid=None)[source]

Send a signal to the current process and all children processes

Parameters:
  • sig – The signal to send

  • pid (int) – The process id. If None then use current process. If -1, only send signal to children processes of current process If 0, only send signal to current process