Skip to content
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

Refactor improved threading & logging #601

Merged
merged 70 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
836052f
Chore update Python to 3.12.1
vagabondHustler Jan 18, 2024
0ac65f7
Chore update [build] -> [whl_cp312]
vagabondHustler Jan 18, 2024
2bf0c09
Chore update Python to 3.12.1 (#584)
vagabondHustler Jan 18, 2024
39d379d
Bump version 2.41.1 → 2.41.2dev1
vagabondHustler Jan 18, 2024
33f5ecf
Bump current version 2.41.1 → 2.41.2dev1
vagabondHustler Jan 18, 2024
d22090b
Bump previous version 2.41.1dev5 → 2.41.1
vagabondHustler Jan 18, 2024
6b171b8
Chore change `target-branch` to dev
vagabondHustler Jan 19, 2024
b4fcf4b
Chore change target-branch to dev
vagabondHustler Jan 19, 2024
4a3159c
Chore update CI workflow for `dev` branch
vagabondHustler Jan 19, 2024
3e45d8b
Chore update CI workflow for `dev` branch
vagabondHustler Jan 19, 2024
7c4ecea
Bump version 2.41.2dev1 → 2.41.2dev2
vagabondHustler Jan 19, 2024
e6d2288
Bump current version 2.41.2dev1 → 2.41.2dev2
vagabondHustler Jan 19, 2024
39dc6c2
Bump previous version 2.41.1 → 2.41.2dev1
vagabondHustler Jan 19, 2024
4430de7
chore update GitHub Actions workflow
vagabondHustler Jan 20, 2024
c1cdb49
Fix resolve directory cleanup issue
vagabondHustler Jan 20, 2024
6e2b8d6
Resolve directory cleanup issue (#585)
vagabondHustler Jan 20, 2024
a090669
Chore update branch index logic
vagabondHustler Jan 20, 2024
ae3c098
Fix invalid escape sequences
vagabondHustler Jan 20, 2024
2ab9736
Merge branch 'dev' into fix/invalid_escape_sequences/240120210715
vagabondHustler Jan 20, 2024
0c90df9
Fix invalid escape sequences (#586)
vagabondHustler Jan 20, 2024
1e6d84d
Bump version 2.41.2dev2 → 2.41.2dev3
vagabondHustler Jan 20, 2024
d8e4f21
Bump current version 2.41.2dev2 → 2.41.2dev3
vagabondHustler Jan 20, 2024
8ae714b
Bump previous version 2.41.2dev1 → 2.41.2dev2
vagabondHustler Jan 20, 2024
84cbe0f
Docs update Important note
vagabondHustler Jan 21, 2024
0111088
Bump selectolax from 0.3.17 to 0.3.18
dependabot[bot] Jan 22, 2024
8174317
Bump actions/dependency-review-action from 3 to 4
dependabot[bot] Jan 22, 2024
f374382
Merge branch 'dev' into dependabot/github_actions/actions/dependency-…
vagabondHustler Jan 22, 2024
f8ac005
Merge branch 'dev' into dependabot/pip/selectolax-0.3.18
vagabondHustler Jan 22, 2024
9e8eb0d
Bump selectolax from 0.3.17 to 0.3.18 (#588)
dependabot[bot] Jan 22, 2024
6e84a91
Bump actions/dependency-review-action from 3 to 4 (#589)
dependabot[bot] Jan 22, 2024
bcef50f
Bump psutil from 5.9.7 to 5.9.8
vagabondHustler Jan 22, 2024
0ceba4c
Chore update GitHub Actions workflow
vagabondHustler Jan 22, 2024
366a8f7
Fix missing timestamp in log.log (#590)
vagabondHustler Jan 22, 2024
c8ad380
Fix attributeError
vagabondHustler Jan 22, 2024
48ad1d9
Fix add missing stdout for move best match
vagabondHustler Jan 22, 2024
d137a81
Bump version 2.41.2dev3 → 2.41.2dev4
vagabondHustler Jan 22, 2024
c778193
Bump current version 2.41.2dev3 → 2.41.2dev4
vagabondHustler Jan 22, 2024
e5823b9
Bump previous version 2.41.2dev2 → 2.41.2dev3
vagabondHustler Jan 22, 2024
ea06f61
Bump whl_cp312 cx_freeze to dev22
vagabondHustler Jan 22, 2024
436f320
Merge branch 'dev' of https://github.com/vagabondHustler/subsearch in…
vagabondHustler Jan 22, 2024
4299958
Bump version 2.41.2dev4 → 2.41.2dev5
vagabondHustler Jan 22, 2024
d81737a
Bump current version 2.41.2dev4 → 2.41.2dev5
vagabondHustler Jan 22, 2024
7ffcad0
Bump previous version 2.41.2dev3 → 2.41.2dev4
vagabondHustler Jan 22, 2024
2336f3d
Bump whl_cp312 leif to 0.15.0
vagabondHustler Jan 22, 2024
ca66b89
Enhance download manager functionality (#591)
vagabondHustler Jan 23, 2024
ecb28fe
Bump version 2.41.2dev5 → 2.42.0dev1
vagabondHustler Jan 23, 2024
fe85608
Bump current version 2.41.2dev5 → 2.42.0dev1
vagabondHustler Jan 23, 2024
2b15482
Bump previous version 2.41.2dev4 → 2.41.2dev5
vagabondHustler Jan 23, 2024
68bcdb0
Docs update README.md
vagabondHustler Jan 23, 2024
0eb3859
Fix download count in log and toast (#592)
vagabondHustler Jan 23, 2024
01c82e8
Bump version 2.42.0dev1 → 2.42.0
vagabondHustler Jan 23, 2024
72db48c
Bump current version 2.42.0dev1 → 2.42.0
vagabondHustler Jan 23, 2024
aa9493d
Bump previous version 2.41.2dev5 → 2.42.0dev1
vagabondHustler Jan 23, 2024
06fe4bd
Bump last stable release 2.41.1 → 2.42.0
vagabondHustler Jan 23, 2024
f70ea3f
Merge branch 'main' into dev
vagabondHustler Jan 23, 2024
17504d5
Bump python-dotenv from 1.0.0 to 1.0.1 (#594)
dependabot[bot] Jan 24, 2024
b138eee
Merge branch 'dev' into workflow/fix_pypi_error/240124124112
vagabondHustler Jan 24, 2024
b58764d
Fix pypi upload
vagabondHustler Jan 24, 2024
da31cff
Style update pr merge subject and body
vagabondHustler Jan 24, 2024
1ff3716
Chore del file `state_manager`
vagabondHustler Jan 26, 2024
e2776a5
Chore add module `propagating_thread`
vagabondHustler Jan 26, 2024
898960a
Refactor threading in `propagating_thread`
vagabondHustler Jan 26, 2024
874a532
Refactor update logging format
vagabondHustler Jan 26, 2024
40bb6f6
Refactor update log calls
vagabondHustler Jan 26, 2024
b955ba4
Refactor remove option in in config
vagabondHustler Jan 26, 2024
88331cb
Refactor remove option in in config
vagabondHustler Jan 26, 2024
60d92ef
Refactor add `capture_call_info` decorator
vagabondHustler Jan 26, 2024
b6249e6
Refactor update io_log calls
vagabondHustler Jan 26, 2024
a6c09a2
Merge branch 'dev' into chore/refactor_threading_logging/240126180053
vagabondHustler Jan 26, 2024
dec77db
Fix `AttributeError: module` for io_log
vagabondHustler Jan 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
210 changes: 105 additions & 105 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,105 +1,105 @@
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=65.5", "wheel"]

[project]
authors = [
{email = "vagabondHustler.github@gmail.com"},
{name = "vagabondHustler"},
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Multimedia :: Video",
"Topic :: Utilities",
]
dependencies = [
"picologging==0.9.3",
"cloudscraper==1.2.71",
"num2words==0.5.13",
"packaging==23.2",
"pillow==10.2.0",
"pystray==0.19.5",
"requests==2.31.0",
"selectolax==0.3.18",
"toml==0.10.2",
]
description = "Subsearch"
dynamic = ["version"]
keywords = [
"subtitles",
"sub",
"srt",
"tool",
"tools",
"download",
"movies",
"shows",
"scrape",
"opensubtitles",
"subscene",
"subsearch",
"subtitles",
"yifysubtitles",
]
license = {text = "MIT license"}
name = "Subsearch"
readme = "README.md"
requires-python = ">=3.10"

[project.urls]
repository = "https://github.com/vagabondHustler/subsearch"

[project.scripts]
subsearch = "subsearch:main"

[tool.setuptools]
platforms = ["win32"]
zip-safe = false

[tool.setuptools.packages.find]
exclude = ["examples*", "subsearch.test*", "tools*"]
include = ["subsearch*"]
where = ["src"]

[tool.setuptools.dynamic]
version = {attr = "subsearch.data.__version__"}

[project.optional-dependencies]
build = [
"build==1.0.3",
"cx_Freeze==6.15.12",
"twine==4.0.2",
"psutil==5.9.8",
]
lint = ["black==23.12.1", "isort==5.13.2"]
tests = [
"pytest-cov==4.1.0",
"pytest==7.4.4",
"tox==4.12.1",
"python-dotenv==1.0.1",
]
tools = ["pyperclip==1.8.2"]
type = ["mypy==1.8.0"]

[tool.pytest.ini_options]
addopts = "--cov=src/subsearch"
filterwarnings = ['ignore::DeprecationWarning']
log_cli = true
log_cli_level = 'DEBUG'
testpaths = ["tests"]

[tool.black]
line-length = 120

[tool.isort]
profile = "black"

[tool.mypy]
check_untyped_defs = true
ignore_missing_imports = true
mypy_path = "src"
warn_no_return = false
[build-system]
build-backend = "setuptools.build_meta"
requires = ["setuptools>=65.5", "wheel"]
[project]
authors = [
{email = "vagabondHustler.github@gmail.com"},
{name = "vagabondHustler"},
]
classifiers = [
"Intended Audience :: Developers",
"Intended Audience :: End Users/Desktop",
"Operating System :: Microsoft :: Windows",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Topic :: Multimedia :: Video",
"Topic :: Utilities",
]
dependencies = [
"picologging==0.9.3",
"cloudscraper==1.2.71",
"num2words==0.5.13",
"packaging==23.2",
"pillow==10.2.0",
"pystray==0.19.5",
"requests==2.31.0",
"selectolax==0.3.18",
"toml==0.10.2",
]
description = "Subsearch"
dynamic = ["version"]
keywords = [
"subtitles",
"sub",
"srt",
"tool",
"tools",
"download",
"movies",
"shows",
"scrape",
"opensubtitles",
"subscene",
"subsearch",
"subtitles",
"yifysubtitles",
]
license = {text = "MIT license"}
name = "Subsearch"
readme = "README.md"
requires-python = ">=3.10"
[project.urls]
repository = "https://github.com/vagabondHustler/subsearch"
[project.scripts]
subsearch = "subsearch:main"
[tool.setuptools]
platforms = ["win32"]
zip-safe = false
[tool.setuptools.packages.find]
exclude = ["examples*", "subsearch.test*", "tools*"]
include = ["subsearch*"]
where = ["src"]
[tool.setuptools.dynamic]
version = {attr = "subsearch.data.__version__"}
[project.optional-dependencies]
build = [
"build==1.0.3",
"cx_Freeze==6.15.12",
"twine==4.0.2",
"psutil==5.9.8",
]
lint = ["black==23.12.1", "isort==5.13.2"]
tests = [
"pytest-cov==4.1.0",
"pytest==7.4.4",
"tox==4.12.1",
"python-dotenv==1.0.1",
]
tools = ["pyperclip==1.8.2"]
type = ["mypy==1.8.0"]
[tool.pytest.ini_options]
addopts = "--cov=src/subsearch"
filterwarnings = ['ignore::DeprecationWarning']
log_cli = true
log_cli_level = 'DEBUG'
testpaths = ["tests"]
[tool.black]
line-length = 120
[tool.isort]
profile = "black"
[tool.mypy]
check_untyped_defs = true
ignore_missing_imports = true
mypy_path = "src"
warn_no_return = false
42 changes: 10 additions & 32 deletions src/subsearch/__init__.py
Original file line number Diff line number Diff line change
@@ -1,44 +1,28 @@
import sys
import time
from pathlib import Path
from threading import Thread


from subsearch import core
from subsearch.globals import decorators
from subsearch.globals.constants import FILE_PATHS
from subsearch.utils import io_log, io_toml

PREF_COUNTER = time.perf_counter()
PACKAGEPATH = Path(__file__).resolve().parent.as_posix()
HOMEPATH = Path(PACKAGEPATH).parent.as_posix()
sys.path.append(HOMEPATH)
sys.path.append(PACKAGEPATH)
PACKAGE_PATH = Path(__file__).resolve().parent.as_posix()
HOME_PATH = Path(PACKAGE_PATH).parent.as_posix()
sys.path.append(HOME_PATH)
sys.path.append(PACKAGE_PATH)


class Subsearch:
def __init__(self) -> None:
self.subsearch_core = core.SubsearchCore(PREF_COUNTER)

def thread_executor(self, *args) -> None:
provider_threads = {}
for provider in args:
provider_threads[provider] = Thread(target=provider)

for thread in provider_threads.values():
thread.start()

for thread in provider_threads.values():
thread.join()

def search_for_subtitles(self) -> None:
providers = [self.subsearch_core.subscene, self.subsearch_core.opensubtitles, self.subsearch_core.yifysubtitles]

if io_toml.load_toml_value(FILE_PATHS.config, "misc.multithreading"):
self.thread_executor(*providers)

else:
for provider in providers:
provider()
self.subsearch_core.search_for_subtitles(
self.provider_opensubtitles,
self.provider_subscene,
self.provider_yifysubtitles,
)

def provider_opensubtitles(self) -> None:
self.subsearch_core.opensubtitles()
Expand Down Expand Up @@ -68,11 +52,5 @@ def main() -> None:
app.on_exit()


def custom_excepthook(exctype, value, traceback):
io_log.Logger()._debug_logger.error(value, exc_info=(exctype, value, traceback))
sys.__excepthook__(exctype, value, traceback)


if __name__ == "__main__":
sys.excepthook = custom_excepthook
main()
Loading
Loading