Updater

class olaf.UpdaterState(value)[source]

The integer value Updater’s update() will return

UPDATE_SUCCESSFUL = 0

The last update was successfully installed. Default State.

PRE_UPDATE_FAILED = 1

The last update failed during the inital non critical section. Either the was an error using the file cache, when opening tarfile, or reading the instructions file.

UPDATE_FAILED = 2

The update failed during the critical section. The updater fail while following the instructions.

UPDATING = 255

Updater is updating

class olaf.Updater(work_dir: str, cache_dir: str)[source]

The OreSat Linux updater. Allows OreSat Linux boards to be update thru update archives.

While this could be replaced with a couple of functions. Having a object with properties, allow for easy to get status info while updating.

Parameters:
  • work_dir (str) – Directory to use a the working dir. Should be a abslute path.

  • cache_dir (str) – Directory to store update archives in. Should be a abslute path.

add_update_archive(file_path: str) bool[source]

Copies update archive into the update archive cache.

Parameters:

file_path (str) – The absolute path to update archive for the updater to copy.

Returns:

True if a file was added or False on failure.

Return type:

bool

update()[source]

Run a update.

If there are file aleady in the working directory, it will try to find and resume the update, otherwise it will get the oldest archive from the update archive cache and run it.

If the update fails, the cache will be cleared, as it is asume all newer updates require the failed updated to be run successfully first.

Raises:

UpdaterError – A error occurred when updating.

make_status_archive() str[source]

Make status tar file with a copy of the dpkg status file, a file with the out put of pip freeze (the list of python packages), and a file with the list ofupdates in cache.

Returns:

Path to new status file or empty string on failure.

Return type:

str

clear_cache()[source]

Clear the update cache.

property has_dpkg: bool

system has dpkg or not

Type:

bool

property status: UpdaterState

The current state.

Type:

UpdaterState

property updates_cached: list

The list of update archives in cache.

Type:

list

property list_updates: str

Get a JSON list of file_name in cache.

Type:

str

property update_archive: str

Current update archive while updating.

Type:

str

property total_instructions: int

The total number of instructions in the update running.

Type:

int

property instruction_index: int

The index of the instruction currently running.

Type:

int

property instruction_percent: int

The percentage of the instructions completed.

Type:

int

property instruction_command: str

The current bash command being running.

Type:

str