From ab05a426422fce4104a88dc2d7d5cacf25533808 Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 14:48:23 +0200 Subject: [PATCH 1/7] Initial readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5704dc7..ceb8897 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -Themes: https://user-images.githubusercontent.com/46163555/71361827-2a01b880-2562-11ea-9af8-2c264c02c3e8.jpg +# keyhint \ No newline at end of file From a3bafc6630f832ba2b68a551af66d054d278456d Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 14:53:33 +0200 Subject: [PATCH 2/7] Adjust workflows, fix 3.7 error --- .github/workflows/coveralls.yml | 25 +++++++------------------ .github/workflows/test.yml | 6 +++--- keyhint/data_model.py | 2 +- 3 files changed, 11 insertions(+), 22 deletions(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 5803c58..953bdc7 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -7,36 +7,25 @@ jobs: name: Test runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@master # PREPARE - name: Install Python 3.7 # Because GitHub Actions' python isn't build against tkinter! run: sudo apt-get update && sudo apt-get install python3.7 python3.7-dev python3.7-tk python3-setuptools - - name: Symlink apt-pkg lib - # to make pipenv working with different python versions - run: cd /usr/lib/python3/dist-packages/ && sudo ln -s apt_pkg.cpython-36m-x86_64-linux-gnu.so apt_pkg.so - - name: Install normcap dependencies - run: sudo apt-get install tesseract-ocr tesseract-ocr-deu libtesseract-dev libleptonica-dev pkg-config xclip - - name: Install wheel - run: python3.7 -m pip install --user wheel - - name: Install pipenv - run: python3.7 -m pip install --user pipenv - - name: Create virtual env - run: $HOME/.local/bin/pipenv install --dev - env: - CI: true + + - name: Install dependencies + run: python3 -m pip install -r requirements-dev.txt - name: Install coveralls - run: $HOME/.local/bin/pipenv run pip install coveralls + run: python3 -m pip install coveralls # TEST - name: Test with pytest - # xvfb-run with bpp 32 has to be used to make the mss screenshot grab work - run: $HOME/.local/bin/pipenv run xvfb-run --server-args="-screen 0 1024x768x24+32" python3.7 -m pytest + run: xvfb-run --server-args="-screen 0 1024x768x24+32" python3 -m pytest # PUBLISH - name: Publish - run: $HOME/.local/bin/pipenv run coveralls + run: python3 -m coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eb735af..b619ab0 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,11 +22,11 @@ jobs: # LINT - name: Lint with pylama - run: pylama + run: python3 -m pylama # TEST - name: Test with pytest - run: xvfb-run --server-args="-screen 0 1024x768x24+32" pytest + run: xvfb-run --server-args="-screen 0 1024x768x24+32" python3 -m pytest # test_macos: # name: Test on MacOS @@ -64,7 +64,7 @@ jobs: # LINT - name: Lint with flake8 - run: pylama + run: python -m pylama # TEST - name: Test with pytest diff --git a/keyhint/data_model.py b/keyhint/data_model.py index 4acdf2f..bd798c0 100644 --- a/keyhint/data_model.py +++ b/keyhint/data_model.py @@ -48,7 +48,7 @@ def __repr__(self): # Convert other attributes to strings if attr in ["config", "hints"]: text += f"{attr}:\n" - text += pprint.pformat(getattr(self, attr), width=100, sort_dicts=False) + text += pprint.pformat(getattr(self, attr), width=100) text += "\n" else: From 502dfd16e324ebea173ac0456d8367faa1a49cea Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 14:58:20 +0200 Subject: [PATCH 3/7] Fix byte/str conversion --- keyhint/helpers.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/keyhint/helpers.py b/keyhint/helpers.py index fc5998f..a947a2c 100644 --- a/keyhint/helpers.py +++ b/keyhint/helpers.py @@ -95,7 +95,9 @@ def get_active_window_info_win() -> Tuple[str, str]: # pylint: disable=R0914 h_process, h_module.value, str_buf, sizeof(uc_buf) ) windll.kernel32.CloseHandle(h_process) - app_process = "".join(str_buf) + app_process = "".join( + [b.decode("utf-8") for b in str_buf if b.decode("utf-8") != "\x00"] + ) return app_process, app_title From 095fa292afc431b537c0dafcd4cae97ea36463d4 Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 14:59:55 +0200 Subject: [PATCH 4/7] Make sure to use python 3.7 --- .github/workflows/test.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b619ab0..9528595 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -18,15 +18,19 @@ jobs: run: sudo apt-get update && sudo apt-get install python3.7 python3.7-dev python3.7-tk python3-setuptools - name: Install dependencies - run: python3 -m pip install -r requirements-dev.txt + run: python3.7 -m pip install -r requirements-dev.txt + + # Version + - name: Print version + run: python3.7 --version && python3 --version # LINT - name: Lint with pylama - run: python3 -m pylama + run: python3.7 -m pylama # TEST - name: Test with pytest - run: xvfb-run --server-args="-screen 0 1024x768x24+32" python3 -m pytest + run: xvfb-run --server-args="-screen 0 1024x768x24+32" python3.7 -m pytest # test_macos: # name: Test on MacOS From 88e1b60b7a531ada8355e850b04563e1b810a5a1 Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 15:10:44 +0200 Subject: [PATCH 5/7] Adjust active window helpers for github actions --- cov.xml | 388 +++++++++++++++++++++--------------------- tests/test_helpers.py | 6 - 2 files changed, 194 insertions(+), 200 deletions(-) diff --git a/cov.xml b/cov.xml index 12a6d90..0d873c6 100644 --- a/cov.xml +++ b/cov.xml @@ -1,12 +1,12 @@ - + /home/holger/coding/keyhint/keyhint - + @@ -24,7 +24,7 @@ - + @@ -41,22 +41,22 @@ - - + + - - - - - - - - - - - - - + + + + + + + + + + + + + @@ -66,12 +66,12 @@ - + - + @@ -88,23 +88,23 @@ - - - - - - - - - - - + + + + + + + + + + + - + - + @@ -115,19 +115,19 @@ - - - - - + + + + + - - - - + + + + - + @@ -149,56 +149,56 @@ - - - - - - + + + + + - - - - - - - - - - - - + + + + + + + + + + + + - - - - + + + - - - - - - - + + + + + + + - - + + - + + + - + - + @@ -212,18 +212,18 @@ - + - - + + - - + + - + @@ -231,14 +231,14 @@ - - - - + + + + - + @@ -255,43 +255,43 @@ - - - - + + + + - - - - - - + + + + + + - - - - + + + + - + - - - + + + - + - - + + - + @@ -300,14 +300,14 @@ - - - - + + + + - + @@ -318,104 +318,104 @@ - - - - - - - + + + + + + + - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + - - - + + + - - - - - - + + + + + + - - - - - - + + + + + + - - - + + + - - - - - + + + + + - - - - - - + + + + + + - - - - + + + + - - - - + + + + - - - - - + + + + + - - - + + + - - - - - - - + + + + + + + - - + + - + - + diff --git a/tests/test_helpers.py b/tests/test_helpers.py index 9c1b447..ae10db6 100644 --- a/tests/test_helpers.py +++ b/tests/test_helpers.py @@ -26,8 +26,6 @@ def test_get_active_window_info(): app_process, app_title = helpers.get_active_window_info(platform.system()) assert isinstance(app_process, str) assert isinstance(app_title, str) - assert len(app_process) > 0 - assert len(app_title) > 0 def test_get_active_window_info_win(): @@ -35,8 +33,6 @@ def test_get_active_window_info_win(): app_process, app_title = helpers.get_active_window_info_win() assert isinstance(app_process, str) assert isinstance(app_title, str) - assert len(app_process) > 0 - assert len(app_title) > 0 else: assert True @@ -46,8 +42,6 @@ def test_get_active_window_info_x(): app_process, app_title = helpers.get_active_window_info_x() assert isinstance(app_process, str) assert isinstance(app_title, str) - assert len(app_process) > 0 - assert len(app_title) > 0 else: assert True From abb515479355f4a57b6192fec1752f3cb3f23d26 Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 15:14:13 +0200 Subject: [PATCH 6/7] Add coveralls --- .github/workflows/coveralls.yml | 8 ++++---- .github/workflows/test.yml | 4 ---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 953bdc7..99478ca 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -15,17 +15,17 @@ jobs: run: sudo apt-get update && sudo apt-get install python3.7 python3.7-dev python3.7-tk python3-setuptools - name: Install dependencies - run: python3 -m pip install -r requirements-dev.txt + run: python3.7 -m pip install -r requirements-dev.txt - name: Install coveralls - run: python3 -m pip install coveralls + run: python3.7 -m pip install coveralls # TEST - name: Test with pytest - run: xvfb-run --server-args="-screen 0 1024x768x24+32" python3 -m pytest + run: xvfb-run --server-args="-screen 0 1024x768x24+32" python3.7 -m pytest # PUBLISH - name: Publish - run: python3 -m coveralls + run: python3-7 -m coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9528595..42d546f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -20,10 +20,6 @@ jobs: - name: Install dependencies run: python3.7 -m pip install -r requirements-dev.txt - # Version - - name: Print version - run: python3.7 --version && python3 --version - # LINT - name: Lint with pylama run: python3.7 -m pylama From 856cb62dcf83301afa2f610c745745ba3fab686d Mon Sep 17 00:00:00 2001 From: dynobo Date: Fri, 15 May 2020 15:18:27 +0200 Subject: [PATCH 7/7] Fiy typo --- .github/workflows/coveralls.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coveralls.yml b/.github/workflows/coveralls.yml index 99478ca..11bb327 100644 --- a/.github/workflows/coveralls.yml +++ b/.github/workflows/coveralls.yml @@ -26,6 +26,6 @@ jobs: # PUBLISH - name: Publish - run: python3-7 -m coveralls + run: python3.7 -m coveralls env: COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_TOKEN }}