Code Documentation

(work in progress)

This page will explain the modules of the Flashtool which are important for the developer.

Utility

flashtool
├── Utility
│   ├── __init__.py 
...

The utility provides helper functions which used in the whole Flashtool code and which are not referable to other modules.

check_permissions

check_permissions(file)

Function which checks if access permission are provided for the user. If not the user will be informed which Groups have access writes to the file and quits the program.

create_regex_allowed

create_regex_allowed(chk)

Creates a regex to check an input matching several keywords.

get_size_block_dev

get_size_block_dev(dev_name, partition=None)

Function to determine the size of a partition or a whole block device.

get_terminal_size

get_terminal_size()

Helper to get the current size of the terminal the Flashtool was called.

os_call

os_call(command, timeout=None, allow_user_interrupt=True)

Call shell-command with timeout. Can also block user interrupts if wanted

untar

untar(tar, target)

Unpack a tarball to a target location using tarfile. The progress of the unpack procedure will be shown.

user_prompt

user_prompt(question, info, check=None)

Function to handle user input with limited input possibilities.

user_select

user_select(question, lower, upper)

Helper function to ask the user for a selection in a numeric range.

udev/mmc.py

flashtool
├── setup
│   ├── udev
│       └── mmc.py
...

This module recognizes mmc devices with the help of the pyudev module.

get_active_mmc_info

get_active_mmc_info()

Tries to get information about a plugged in mmc device. The user receives instructions to plug in the mmc device when the tool is ready for recognition.

get_mmc_device

get_mmc_device(auto=False)

Function which tries to get the device information of a mmc device. If the system recognize multiple mmc devices the user is prompted to chose a device.

_get_real_block_devices

_get_real_block_devices()

Filters entries in the list with possible block devices when they are not a block device.

get_partition_information

get_partition_information(devices)

Retrieves important information about the partitions of a block device.

Information:

path: path to /dev device of the partition
size: size of the partition
fs_type: filesystem type of a partition
fs_version: filesystem version
name: partition label
uuid: uuid of the partition

ensure_unmounted

ensure_unmounted(devs)

Unmount the partitions which are given by in parameter devs. The function will call the umount command as often as the device is listed in /proc/mounts.

MMCProfiler

Class which is able to guess the right mmc device when plugged in.

guess

guess()

Method which guesses the mmc device due to the recorded udev events.