Skip to content

Commit

Permalink
Merge pull request #9 from sarnold/more-doc-bits
Browse files Browse the repository at this point in the history
More docstring cleanup and fixes
  • Loading branch information
sarnold authored Oct 13, 2024
2 parents 4659e21 + 6008c14 commit ea1b04c
Show file tree
Hide file tree
Showing 13 changed files with 268 additions and 85 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/debs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Debian packages

on:
workflow_dispatch:
#push:
#branches: [ main ]
pull_request:

jobs:
get_version:
name: Get version info
runs-on: ubuntu-22.04
defaults:
run:
shell: bash
outputs:
version: ${{ steps.git_ver.outputs.version }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get package version
id: git_ver
run: |
version=$(git describe --tags | sed -e "s|-g|+g|")
echo "Version from git: ${version}"
echo "version=${version}" >> $GITHUB_OUTPUT
build_debs:
name: ${{ matrix.name }}
runs-on: ubuntu-22.04
needs: [get_version]

strategy:
fail-fast: false
matrix:
name: [
x64_bookworm,
x64_trixie,
x64_sid,
]

include:
- name: x64_bookworm
dist: bookworm

- name: x64_trixie
dist: trixie

- name: x64_sid
dist: sid

steps:
- name: Check github variables
env:
VERSION: ${{ needs.get_version.outputs.version }}
run: |
echo "Package version from git: ${VERSION}"
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Fetch debian files
run: |
wget https://launchpad.net/~nerdboy/+archive/ubuntu/embedded/+sourcefiles/timew-addons/0.1.1-1ubuntu1.22.04.1/timew-addons_0.1.1-1ubuntu1.22.04.1.debian.tar.xz
tar xf timew-addons_0.1.1-1ubuntu1.22.04.1.debian.tar.xz && rm *debian.tar.xz
ls
- name: Install deps and update debian changelog
run: |
sudo apt-get update
sudo apt-get install devscripts
debchange -v ${{ needs.get_version.outputs.version }}-${{ matrix.dist }} -b -M --distribution ${{ matrix.dist }} "ci build"
- name: Build deb packages
uses: jtdor/build-deb-action@v1
env:
DEB_BUILD_OPTIONS: noautodbgsym
with:
docker-image: "debian:${{ matrix.dist }}-slim"
buildpackage-opts: --build=binary --no-sign
extra-build-deps: git

- name: Upload deb files
uses: actions/upload-artifact@v4
with:
name: "timew-addons_${{ needs.get_version.outputs.version }}-${{ matrix.dist }}"
path: ./debian/artifacts/*.deb
2 changes: 1 addition & 1 deletion .pep8speaks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ exclude =
build,
dist

max-line-length = 99
max-line-length = 100

ignore =
# too many leading '#' for block comment
Expand Down
26 changes: 16 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ repos:
- id: check-useless-excludes
- id: check-hooks-apply
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.6.0
hooks:
- id: check-added-large-files
- id: check-case-conflict
Expand All @@ -28,31 +28,37 @@ repos:
- id: check-toml

- repo: https://github.com/ambv/black
rev: 23.3.0
rev: 24.8.0
hooks:
- id: black
name: "Format code"
language_version: python3

- repo: https://github.com/pycqa/isort
rev: 5.12.0
rev: 5.13.2
hooks:
- id: isort
args: [--settings-path=pyproject.toml]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.5.0
rev: v1.11.2
hooks:
- id: mypy
args:
- --follow-imports=normal
- --install-types
- --non-interactive
- --ignore-missing-imports
#files: src/
- --implicit-reexport
additional_dependencies:
- "PyYAML"
- "munch"
- "munch-stubs"
- "PyGObject"
- "PyGObject-stubs"
files: src/

- repo: "https://github.com/asottile/blacken-docs"
rev: "1.15.0"
rev: "1.18.0"
hooks:
- id: "blacken-docs"
name: "Format docs (blacken-docs)"
Expand All @@ -76,7 +82,7 @@ repos:
- id: rst-inline-touching-normal

- repo: https://github.com/myint/autoflake
rev: v2.2.0
rev: v2.3.1
hooks:
- id: autoflake
#files: src/
Expand All @@ -87,14 +93,14 @@ repos:
- --remove-unused-variables

- repo: https://github.com/PyCQA/flake8
rev: 6.1.0
rev: 7.1.1
hooks:
- id: flake8
#files: src/
additional_dependencies: ["flake8-bugbear"]

- repo: https://github.com/PyCQA/bandit
rev: 1.7.5
rev: 1.7.9
hooks:
- id: bandit
args: ["-ll", "-q"]
Expand Down
79 changes: 45 additions & 34 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -133,36 +133,42 @@ generated python byte-code. In the latter case, the list of installed
files can be obtained with the following command::

$ python -m pip show -f timew-addons
Name: timew-addons
Version: 0.1.2.dev3+gda11428.d20240825
Summary: A collection of timewarrior extensions and experiments
Home-page: https://github.com/sarnold/timew-addons
Author: Stephen L Arnold
Author-email:
License:
Location: /home/user/src/timew-addons/.tox/check/lib/python3.11/site-packages
Requires: munch, pycairo, PyGObject, timew-report
Required-by:
Files:
../../../bin/timew-status-indicator
../../../share/applications/timew-status-indicator.desktop
../../../share/icons/hicolor/48x48/apps/timew.png
../../../share/icons/hicolor/scalable/apps/timew.svg
../../../share/icons/hicolor/scalable/status/timew_error.svg
../../../share/icons/hicolor/scalable/status/timew_inactive.svg
../../../share/icons/hicolor/scalable/status/timew_info.svg
../../../share/icons/hicolor/scalable/status/timew_warning.svg
../../../share/timew-addons/extensions/csv_rpt.py
../../../share/timew-addons/extensions/onelineday.py
../../../share/timew-addons/extensions/totals.py
timew_addons-0.1.2.dev3+gda11428.d20240825.dist-info/INSTALLER
timew_addons-0.1.2.dev3+gda11428.d20240825.dist-info/METADATA
timew_addons-0.1.2.dev3+gda11428.d20240825.dist-info/RECORD
timew_addons-0.1.2.dev3+gda11428.d20240825.dist-info/REQUESTED
timew_addons-0.1.2.dev3+gda11428.d20240825.dist-info/WHEEL
timew_addons-0.1.2.dev3+gda11428.d20240825.dist-info/top_level.txt
timew_status/__init__.py
timew_status/utils.py
Name: timew-addons
Version: 0.2.2.dev0+g4659e21.d20240901
Summary: A collection of timewarrior extensions and experiments
Home-page: https://github.com/sarnold/timew-addons
Author: Stephen L Arnold
Author-email: nerdboy@gentoo.org
License: GPLv3+
Location: /home/nerdboy/src/timew-addons/.tox/py/lib/python3.11/site-packages
Requires: munch, pycairo, PyGObject, timew-report
Required-by:
Files:
../../../bin/timew-status-indicator
../../../share/applications/timew-status-indicator.desktop
../../../share/icons/hicolor/48x48/apps/timew.png
../../../share/icons/hicolor/scalable/apps/timew.svg
../../../share/icons/hicolor/scalable/status/timew_error.svg
../../../share/icons/hicolor/scalable/status/timew_inactive.svg
../../../share/icons/hicolor/scalable/status/timew_info.svg
../../../share/icons/hicolor/scalable/status/timew_warning.svg
../../../share/timew-addons/extensions/__pycache__/csv_rpt.cpython-311.pyc
../../../share/timew-addons/extensions/__pycache__/onelineday.cpython-311.pyc
../../../share/timew-addons/extensions/__pycache__/totals.cpython-311.pyc
../../../share/timew-addons/extensions/csv_rpt.py
../../../share/timew-addons/extensions/onelineday.py
../../../share/timew-addons/extensions/totals.py
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/INSTALLER
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/METADATA
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/RECORD
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/REQUESTED
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/WHEEL
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/direct_url.json
timew_addons-0.2.2.dev0+g4659e21.d20240901.dist-info/top_level.txt
timew_status/__init__.py
timew_status/__pycache__/__init__.cpython-311.pyc
timew_status/__pycache__/utils.cpython-311.pyc
timew_status/utils.py

Generated files
---------------
Expand Down Expand Up @@ -199,18 +205,23 @@ Uninstalling

Depending on how it was installed, use on or more of the following:

* delete the cloned directory, eg, ``rm -rf src/timew-addons``
* delete the cloned directory, eg, ``rm -rf path/to/timew-addons``
* delete the virtual environment, eg, ``rm -rf ``.venv``
* remove the OS package, eg, on Ubuntu:

If you installed into a local env via ``pip`` then run::

$ pip uninstall timew-addons

* or, remove the OS package, eg, on Ubuntu:

::

$ sudo apt remove timew-addons
$ sudo apt autoremove

Finally, delete the above configuration file::
Finally, delete the configuration file::

$ rm ~/.config/timew_status_indicator/config.yaml
$ rm $HOME/.config/timew_status_indicator/config.yaml


Reporting examples
Expand Down
2 changes: 1 addition & 1 deletion data/timew-status-indicator.desktop
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[Desktop Entry]
Name=Timew Status Tool
Name=Timew Status Indicator
Comment=Control and status tool for timew
Exec=timew-status-indicator
Icon=timew
Expand Down
1 change: 0 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,3 @@ Indices and tables

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
19 changes: 7 additions & 12 deletions scripts/timew-status-indicator
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,14 @@ from threading import Thread
from typing import cast

import gi
from munch import Munch

gi.require_version("Gtk", "3.0")
gi.require_version('Notify', '0.7')
gi.require_version('AyatanaAppIndicator3', '0.1')

try:
gi.require_version('AyatanaAppIndicator3', '0.1')
from gi.repository import AyatanaAppIndicator3 as appindicator
except ValueError:
gi.require_version('AppIndicator3', '0.1')
from gi.repository import AppIndicator3 as appindicator

from gi.repository import AyatanaAppIndicator3 as appindicator
from gi.repository import Gdk, Gtk, Notify
from munch import Munch

from timew_status import (
CFG,
Expand Down Expand Up @@ -123,7 +118,7 @@ class Indicator:
new_state = 'INACTIVE'
print(f'{new_state} state msg: {result.stdout.decode().strip()}')
else:
proc, _ = run_cmd()
proc, _ = run_cmd(CFG)
msg, new_state = get_state_str(proc, current_tick_count, CFG)
print(f'{new_state} state msg: {msg.strip()}')
# if there is a change in state, update the icon
Expand Down Expand Up @@ -238,18 +233,18 @@ class Indicator:

def startd(self, source):
my_tag = TAG["text"]
_, svc_msg = run_cmd(action='start', tag=my_tag)
_, svc_msg = run_cmd(CFG, action='start', tag=my_tag)
self.indicator.set_icon_full(get_state_icon('ACTIVE', CFG), 'ACTIVE')
Notify.Notification.new("Timew status", svc_msg, None).show()

def statusd(self, source):
_, svc_msg = run_cmd()
_, svc_msg = run_cmd(CFG)
seat_minutes = round(Decimal(COUNT["SeatTick"] / 60), 1)
svc_msg = f'INFO: current seat time is {seat_minutes} mins \n' + svc_msg
Notify.Notification.new("Timew status", svc_msg, None).show()

def stopd(self, source):
_, svc_msg = run_cmd(action='stop')
_, svc_msg = run_cmd(CFG, action='stop')
if svc_msg:
self.last_tag = svc_msg
if CFG['use_last_tag']:
Expand Down
8 changes: 6 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ version = attr: setuptools_scm.get_version
description = A collection of timewarrior extensions and experiments
url = https://github.com/sarnold/timew-addons
author = Stephen L Arnold
email = nerdboy@gentoo.org
author_email = nerdboy@gentoo.org
long_description = file: README.rst
long_description_content_type = text/rst; charset=UTF-8
license = GPLv3+
license_expression = GPL-3.0-or-later
license_files = ["LICEN[CS]E*",]
classifiers =
Expand All @@ -24,6 +25,9 @@ classifiers =

keywords =
appindicator
extensions
timewarrior
timew-report
timew

[options]
Expand Down Expand Up @@ -107,7 +111,7 @@ exclude =
docs,
tests

max-line-length = 99
max-line-length = 100
max-complexity = 10
addons = file,open,basestring,xrange,unicode,long,cmp
ignore =
Expand Down
1 change: 1 addition & 0 deletions src/timew_status/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Monitoring and reporting tools for Timew tracking intervals with optional
appindicator alerts for keyboard time and daily hours.
"""

import sys

from .utils import (
Expand Down
Loading

0 comments on commit ea1b04c

Please sign in to comment.