cloudmesh-common.cloudmesh.common.sudo

Module Contents

Classes

Sudo

class cloudmesh-common.cloudmesh.common.sudo.Sudo
static password(msg='sudo password: ')

Asks for the Sudo password

static expire()

Expires the password

static execute(command, decode='True', debug=False)

Executes the command

Parameters

command (list or str) – The command to run

Returns

Return type

static readfile(filename, split=False, trim=False, decode=True)

Reads the content of the file as sudo and returns the result

param filename

the filename

type filename

str

param split

uf true returns a list of lines

type split

bool

param trim

trim trailing whitespace. This is useful to prevent empty string entries when splitting by ‘

type trim

bool

return

the content

rtype

str or list

static writefile(filename, content, append=False)

Writes the content in the the given file.

Parameters
  • filename (str) – the filename

  • content (str) – the content

  • append (bool) – if true it append it at the end, otherwise the file will be overwritten

Returns

the output created by the write process

Return type

int