configfile — PyCI Base Configuration File Module

class ConfigFile(filepath)

Base class for all ConfigFile* objects containing many useful methods.

cleanup(filepath)
Deletes any leftover backup files and removes the emergency init script
made_changes()
Writes a ‘1’ to ‘/tmp/pyci_changes’ to indicate that changes have been made that require a reboot
make_backup(filepath)
Makes a backup file in case we need to undo
make_init(script=None)
Generates and installs an init script that will undo changes in case of a power failure or crash. Plugin authors can optionally supply their own script (as a string).
raw()
Returns the raw text in the config file
save()
Your ConfigFile object will need to override this in it’s own save method
save_delimited(fields_list, filepath, delimiter)

Saves ‘fields_list’ (list of lists or tuples) as a delimited file using the given delimiter.

For example, to save /etc/passwd using this method you could:
self.save_delimited(passwd_list, ‘/etc/passwd’, ‘:’)
save_raw(text)
Saves the raw (plaintext) version of the config file using ‘text’
undo_from_backup(filepath)
Undoes any changes to ‘filepath’ by moving the backup back to the original location

Previous topic

brctl — PyCI Bridge Module

Next topic

group — PyCI /etc/group Module

This Page

Quick search