-
-
Notifications
You must be signed in to change notification settings - Fork 57
Improved module detection, configuration, and added support for non-standard modules #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
ErikBjare
merged 27 commits into
ActivityWatch:master
from
xylix:dev/improved-module-detection
Jul 25, 2020
Merged
Changes from all commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
53f7dd0
added basic module autodetection
ErikBjare fbe3519
fixed bundled modules
ErikBjare ba88995
fixed crash when module couldn't be started
ErikBjare 4078647
fixed issue when location in PATH does not exist
ErikBjare 70cca98
categorized module menu by location of module
ErikBjare 6db5435
fixed typechecking and enabled on Travis
ErikBjare b7ed55a
actually check for module existence in manager
xylix a974e2c
Store available and autostart modules lists as configuration. See #47
wolferCZ 9dfea4b
rename QTSettings to AwQtSettings and add aw-server-rust
xylix 94dc1df
Add type hints to new code
xylix 7a67423
remove 1 unused import, don't treat aw-server as a special case in cr…
xylix 2a05ba1
Merge remote-tracking branch 'xylix/dev/autodetect-modules' into dev/…
xylix 4403d19
Improve mypy typing
xylix d4e33cf
Improve type safety and add some info logs / comments
xylix ea9d196
Fix lambda parameter amount to allow termination on sigint / sigkill
xylix a7c098c
Add pyqt type stubs to dev dependencies, nicer mypy output by default
xylix 8808f7c
Improve autostart() input typing
xylix b14b1be
Add pip cache for macOS, should make pyobjc etc. installation signifi…
xylix 9e4b15e
Remove unnecessary possible_modules config option
xylix 9a849ca
Recursively find submodules in subdirectories
xylix 2a6a8da
Add some informative pydoc comments
xylix 68314f0
Get PATH using python's os module instead of getting environment
xylix 0a359bd
Merge branch 'master' into dev/improved-module-detection
ErikBjare f6d26c7
fix: minor cleanup
ErikBjare 682a73f
feat: switched to using click for the CLI, fixed bugs
ErikBjare 01378f1
fix: fixed typing checks
ErikBjare 157a546
style: removed unused imports
ErikBjare File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| from configparser import ConfigParser | ||
| from typing import List | ||
|
|
||
| from aw_core.config import load_config | ||
| import json | ||
|
|
||
| # NOTE: Updating this won't update the defaults for users, this is an issue with how aw_core.config works | ||
| default_settings = { | ||
| "autostart_modules": json.dumps( | ||
| ["aw-server", "aw-watcher-afk", "aw-watcher-window",] | ||
| ), | ||
| } | ||
|
|
||
| default_config = ConfigParser() | ||
| default_config["aw-qt"] = default_settings | ||
| # Currently there's no reason to make them differ | ||
| default_config["aw-qt-testing"] = default_settings | ||
|
|
||
|
|
||
| class AwQtSettings: | ||
| def __init__(self, testing: bool): | ||
| """ | ||
| An instance of loaded settings, containing a list of modules to autostart. | ||
| Constructor takes a `testing` boolean as an argument | ||
| """ | ||
| qt_config = load_config("aw-qt", default_config) | ||
| config_section = qt_config["aw-qt" if not testing else "aw-qt-testing"] | ||
|
|
||
| self.autostart_modules: List[str] = json.loads( | ||
| config_section["autostart_modules"] | ||
| ) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,36 +1,38 @@ | ||
| import sys | ||
| import logging | ||
| import argparse | ||
| import click | ||
| from typing import Optional | ||
|
|
||
| from aw_core.log import setup_logging | ||
|
|
||
| from .manager import Manager | ||
|
|
||
| from . import trayicon | ||
| from .config import AwQtSettings | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
|
|
||
|
|
||
| def main(): | ||
| args = parse_args() | ||
| setup_logging("aw-qt", testing=args.testing, verbose=args.testing, log_file=True) | ||
|
|
||
| _manager = Manager(testing=args.testing) | ||
| _manager.autostart(args.autostart_modules) | ||
|
|
||
| error_code = trayicon.run(_manager, testing=args.testing) | ||
| @click.command("aw-qt", help="A trayicon and service manager for ActivityWatch") | ||
| @click.option( | ||
| "--testing", is_flag=True, help="Run the trayicon and services in testing mode" | ||
| ) | ||
| @click.option( | ||
| "--autostart-modules", | ||
| help="A comma-separated list of modules to autostart, or just `none` to not autostart anything.", | ||
| ) | ||
| def main(testing: bool, autostart_modules: Optional[str]) -> None: | ||
| config = AwQtSettings(testing=testing) | ||
| _autostart_modules = ( | ||
| [m.strip() for m in autostart_modules.split(",") if m and m.lower() != "none"] | ||
| if autostart_modules | ||
| else config.autostart_modules | ||
| ) | ||
| setup_logging("aw-qt", testing=testing, verbose=testing, log_file=True) | ||
|
|
||
| _manager = Manager(testing=testing) | ||
| _manager.autostart(_autostart_modules) | ||
|
|
||
| error_code = trayicon.run(_manager, testing=testing) | ||
| _manager.stop_all() | ||
|
|
||
| sys.exit(error_code) | ||
|
|
||
|
|
||
| def parse_args(): | ||
| parser = argparse.ArgumentParser(prog="aw-qt", description='A trayicon and service manager for ActivityWatch') | ||
| parser.add_argument('--testing', action='store_true', | ||
| help='Run the trayicon and services in testing mode') | ||
| parser.add_argument('--autostart-modules', dest='autostart_modules', | ||
| type=lambda s: [m for m in s.split(',') if m and m.lower() != "none"], | ||
| default=["aw-server", "aw-watcher-afk", "aw-watcher-window"], | ||
| help='A comma-separated list of modules to autostart, or just `none` to not autostart anything') | ||
|
|
||
| return parser.parse_args() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.