timew_status package

Submodules

Module contents

Monitoring and reporting tools for Timew tracking intervals with optional appindicator alerts for keyboard time and daily hours.

timew_status.do_install(cfg: Dict) List[str][source]

Install report extensions to timew extensions directory. The default src paths are preconfigured and should probably not be changed unless you know what you are doing, since they are created during install or setup. You should, however, adjust the destination path in extensions_dir if needed for your platform. Returns the destination path string for each installed extension script.

Parameters:

cfg – runtime CFG dict

Return files:

list of strings

timew_status.get_config(file_encoding: str = 'utf-8') Tuple[Munch, Path][source]

Load configuration file and munchify the data. If local file is not found in config directory, the default will be loaded and saved to XDG config directory. Return a Munch cfg obj and corresponding Path obj.

Parameters:

file_encoding (str) – file encoding of config file

Returns:

tuple of Munch and Path objs

timew_status.get_delta_limits(ucfg: Dict) Tuple[timedelta, timedelta, timedelta, timedelta][source]

Return config max/snooze limits as timedeltas. Everything comes from static config values and gets padded with seconds.

Parameters:

ucfg – runtime CFG dict

Returns:

tuple of 4 timedeltas

timew_status.get_state_icon(state: str, cfg: Dict) str[source]

Look up the state msg and return the icon name. Use builtin symbolic icons as fallback.

Parameters:
  • state (str) – name of state key

  • cfg – runtime CFG (dict)

Returns:

matching icon name (str)

timew_status.get_state_str(cmproc: CompletedProcess[bytes], count: TimeDelta, cfg: Dict) Tuple[str, str][source]

Return timew state message and tracking state, ie, the key for dict with icons.

Parameters:
  • cmproc (CompletedProcess) – completed timew process obj

  • count (timedelta) – seat time counter value

  • cfg (Dict) – runtime CFG

Returns:

tuple of state msg and state string

timew_status.get_status() CompletedProcess[bytes][source]

Return timew tracking status (output of timew with no arguments).

Parameters:

None

Returns:

timew output str or None

Raises:

RuntimeError – for timew not found error

timew_status.run_cmd(cfg: Dict, action: str = 'status', tag: str | None = None) Tuple[CompletedProcess[bytes], str][source]

Run timew command subject to the given action.

Parameters:

action – one of <start|stop|status>

Returns:

completed proc obj and result msg

Raises:

RuntimeError – for timew action error

timew_status.to_td(hms: str) timedelta[source]

Convert a time string in HH:MM:SS format to a timedelta object.

Parameters:

hms – time string

Returns:

timedelta