From 8747c0b1c0bef009b12d6b1c10a1b2d65bd49326 Mon Sep 17 00:00:00 2001 From: Phung Xuan Anh Date: Tue, 5 Oct 2021 19:21:49 +0700 Subject: [PATCH] xuananh: them config de debug va them method mapping cac path trong terminal voi project genetica-user-portal xuananh: chinh lai config mapping path xuananh: them config de chay tren local . xuananh: add command git --- .gitignore | 1 - .python-version | 1 + .vscode/launch.json | 17 +++++++++++++++++ Makefile | 35 +++++++++++++++++++++++++++++++++++ README.md | 28 ++++++++++++++++++++++++++++ guake/terminal.py | 14 +++++++++++++- requirements-dev.txt | 7 +++++-- requirements-local.txt | 6 ++++++ requirements.txt | 5 +++-- 9 files changed, 108 insertions(+), 6 deletions(-) create mode 100644 .python-version create mode 100644 .vscode/launch.json create mode 100644 README.md create mode 100644 requirements-local.txt diff --git a/.gitignore b/.gitignore index f8990dc04..671550675 100644 --- a/.gitignore +++ b/.gitignore @@ -76,7 +76,6 @@ ChangeLog .direnv .envrc .venv -.vscode/ guake/data/gschemas.compiled .pytest_cache/ diff --git a/.python-version b/.python-version new file mode 100644 index 000000000..a5c4c7633 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.9.0 diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 000000000..9307e867b --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Attach", + "type": "python", + "request": "attach", + "connect": { + "host": "localhost", + "port": 5678 + } + } + ] +} \ No newline at end of file diff --git a/Makefile b/Makefile index 38c46c0a6..54738ca33 100644 --- a/Makefile +++ b/Makefile @@ -45,6 +45,13 @@ all: clean dev style checks dists test docs dev: clean-ln-venv ensure-pip pipenv-install-dev requirements ln-venv setup-githook \ prepare-install install-dev-locale + +clean-venv: + rm -rf .venv + +dev-without-ln: clean-venv ensure-pip pipenv-install-dev requirements setup-githook \ + prepare-install install-dev-locale + dev-actions: ensure-pip-system pipenv-install-dev requirements setup-githook prepare-install ensure-pip: @@ -479,3 +486,31 @@ styles: style uninstall: uninstall-system upgrade: update wheel: wheels + +# =============================================== local ========================== + +local-run: # this command run with logging INFO + .venv/bin/python guake/main.py --no-startup-script + +local-run-logging-DEBUG: + .venv/bin/python guake/main.py --no-startup-script --verbose + +local-debug: + .venv/bin/python -m debugpy --listen 5678 guake/main.py --no-startup-script + +local-install-packages: + sudo apt install -y build-essential libdbus-glib-1-dev libgirepository1.0-dev \ + pkg-config libcairo2-dev gcc python3-dev \ + gettext + +local-requirements: + .venv/bin/pip install -r requirements-local.txt + +local-prepare-environment: local-install-packages local-requirements setup-githook prepare-install install-dev-locale + +local-git-add-remote: + git remote add upstream https://github.com/Guake/guake.git + +local-git-sync-remote: + git fetch upstream + git merge upstream/master \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 000000000..92618d03e --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +- [1. run on local](#1-run-on-local) + - [1.1. prepare environment](#11-prepare-environment) + - [1.2. debug](#12-debug) + +# 1. run on local + +## 1.1. prepare environment + +```shell +pyenv local 3.9.0 +venv-create + +make local-prepare-environment +make local-run +``` + +## 1.2. debug + +1. run guake with debugpy + +```shell +make dev-debug +``` + +2. run debug mode vscode +3. set breakpoints +4. reduce guake windows size, because when debug, guake terminal will stay in screen +5. do something in guake terminale diff --git a/guake/terminal.py b/guake/terminal.py index ffe353bc9..9e0b718e0 100644 --- a/guake/terminal.py +++ b/guake/terminal.py @@ -258,6 +258,18 @@ def get_current_directory(self): directory = cwd return directory + def mapping_file_path(self, current_path) -> Path: + cwd = self.get_current_directory() + mapping = { + "/code": cwd, + "/usr/local": cwd + "/.venv" + } + for key, value in mapping.items(): + if key in current_path: + new_path = current_path.replace(key, value) + return new_path + return current_path + def is_file_on_local_server(self, text) -> Tuple[Optional[Path], Optional[int], Optional[int]]: """Test if the provided text matches a file on local server @@ -310,7 +322,7 @@ def find_lineno(text, pt, lineno, py_func): if line.startswith(f"def {py_func}"): return i + 1 break - + text = self.mapping_file_path(text) pt = Path(text) log.debug("checking file existance: %r", pt) try: diff --git a/requirements-dev.txt b/requirements-dev.txt index f5b292d48..8980657b7 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -15,9 +15,11 @@ astroid autopep8 black==21.8b0 colorlog -dephell +dataclasses fiximports>=0.1.18 flake8 +flakehell +mock>=2.0.0 pathlib2 pep8 pew @@ -29,9 +31,10 @@ pytest pytest-cov pytest-mock reno[sphinx]>=2.8.0 -scandir ; python_version < '3.5' +scandir ; python_version > '3.5' sphinx-rtd-theme sphinxcontrib-programoutput +toml twine typed-ast yapf diff --git a/requirements-local.txt b/requirements-local.txt new file mode 100644 index 000000000..d05cf5bcc --- /dev/null +++ b/requirements-local.txt @@ -0,0 +1,6 @@ +-r requirements-dev.txt +dbus-python +vext +vext.gi +gobject +PyGObject diff --git a/requirements.txt b/requirements.txt index e0ce56468..9088bc835 100644 --- a/requirements.txt +++ b/requirements.txt @@ -10,5 +10,6 @@ # `Pipfile.lock` and then regenerate `requirements*.txt`. ################################################################################ -importlib_metadata; python_version < '3.8' -typing ; python_version < '3.5' +pbr +typing ; python_version > '3.5' +wheel