Philipp Hörist pushed to branch master at gajim / gajim
Commits: 3baa6b33 by Philipp Hörist at 2023-05-27T17:28:13+02:00 refactor: Simplify launch.py
- - - - - 4d3f632d by Philipp Hörist at 2023-05-27T17:31:59+02:00 cq: Use capitalized env var name
- - - - - c5898f94 by Philipp Hörist at 2023-05-27T17:33:06+02:00 cq: Remove unnecessary list comprehension
- - - - - 1de4921a by Philipp Hörist at 2023-05-27T23:03:47+02:00 cq: Ignore false positive ruff error
- - - - - ffe5bdd0 by Philipp Hörist at 2023-05-27T23:03:47+02:00 refactor: JingleRTP: Don’t call external process for pipeline debug
- - - - - b230d06a by Philipp Hörist at 2023-05-27T23:03:47+02:00 cq: Update ruff version
- - - - -
8 changed files:
- .pre-commit-config.yaml - gajim/common/configpaths.py - gajim/common/helpers.py - gajim/common/jingle_rtp.py - gajim/common/modules/contacts.py - gajim/gtk/preview_audio_visualizer.py - launch.py - pyproject.toml
Changes:
===================================== .pre-commit-config.yaml ===================================== @@ -1,6 +1,6 @@ repos: - repo: https://github.com/charliermarsh/ruff-pre-commit - rev: v0.0.259 + rev: v0.0.270 hooks: - id: ruff exclude: ".githooks/"
===================================== gajim/common/configpaths.py ===================================== @@ -113,7 +113,7 @@ def __init__(self) -> None: else: # Documents and Settings[User Name]\Application Data\Gajim self.config_root = self.cache_root = self.data_root = \ - Path(os.environ['appdata']) / 'Gajim' + Path(os.environ['APPDATA']) / 'Gajim' else: self.config_root = Path(GLib.get_user_config_dir()) / 'gajim' self.cache_root = Path(GLib.get_user_cache_dir()) / 'gajim'
===================================== gajim/common/helpers.py ===================================== @@ -1109,7 +1109,7 @@ def open_file_uri(uri: str) -> None: if sys.platform != 'win32': Gio.AppInfo.launch_default_for_uri(uri) else: - os.startfile(uri) + os.startfile(uri) # noqa: S606 except Exception as err: log.info("Couldn't open file URI %s: %s", uri, err)
===================================== gajim/common/jingle_rtp.py ===================================== @@ -24,7 +24,6 @@ from typing import Optional
import logging -import os import socket from collections import deque from datetime import datetime @@ -40,6 +39,7 @@ pass
from gajim.common import app +from gajim.common import configpaths from gajim.common.i18n import _ from gajim.common.jingle_content import contents from gajim.common.jingle_content import JingleContent @@ -571,20 +571,11 @@ def do_setup(self, self.pipeline.set_state(Gst.State.PLAYING)
if log.getEffectiveLevel() == logging.DEBUG: - # Use 'export GST_DEBUG_DUMP_DOT_DIR=/tmp/' before starting Gajim timestamp = datetime.now().strftime('%m-%d-%Y-%H-%M-%S') name = f'video-graph-{timestamp}' - debug_dir = os.environ.get('GST_DEBUG_DUMP_DOT_DIR') - name_dot = f'{debug_dir}/{name}.dot' - name_png = f'{debug_dir}/{name}.png' + filename = configpaths.get('DEBUG') / f'{name}.dot' Gst.debug_bin_to_dot_file( - self.pipeline, Gst.DebugGraphDetails.ALL, name) - if debug_dir: - try: - os.system(f'dot -Tpng {name_dot} > {name_png}') - except Exception: - log.debug('Could not save pipeline graph. Make sure ' - 'graphviz is installed.') + self.pipeline, Gst.DebugGraphDetails.ALL, str(filename))
@staticmethod def get_fallback_src() -> Optional[Gst.Bin]:
===================================== gajim/common/modules/contacts.py ===================================== @@ -421,8 +421,8 @@ def iter_resources(self) -> Iterator[ResourceContact]: @property def is_available(self) -> bool: # pylint: disable=R1729 - return any([contact.is_available for contact - in self._resources.values()]) + return any(contact.is_available for contact + in self._resources.values())
@property def show(self):
===================================== gajim/gtk/preview_audio_visualizer.py ===================================== @@ -126,8 +126,8 @@ def _process_samples(self) -> None: samples = self._samples
# Normalize both channels using the same scale - max_elem = max(max(samples)) - min_elem = min(min(samples)) + max_elem = max(max(samples)) # noqa: PLW3301 + min_elem = min(min(samples)) # noqa: PLW3301 delta = max_elem - min_elem if delta > 0: self._samples = [
===================================== launch.py ===================================== @@ -2,16 +2,14 @@
import subprocess
-from gajim import gajim +import gajim +from gajim.gajim import main
try: - p = subprocess.Popen('git rev-parse --short=12 HEAD', shell=True, - stdout=subprocess.PIPE, stderr=subprocess.DEVNULL) - node = p.communicate()[0] - if node: - import gajim as g - g.__version__ += '+' + node.decode('utf-8').strip() + res = subprocess.check_output( + ['git', 'rev-parse', '--short=12', 'HEAD']) # noqa: S603, S607 + gajim.__version__ += f'+{res.decode().strip()}' except Exception: pass
-gajim.main() +main()
===================================== pyproject.toml ===================================== @@ -201,6 +201,7 @@ ignore = [ "N806", # Variable should be lower case "N817", # CamelCase imported as acronym "N818", # Exception name should be named with an Error suffix + "PGH003", # Use specific rule codes when ignoring type issues "PLC1901",# Expression can be simplified to x as an empty string is falsey "PLR0911",# Too many return statements "PLR0912",# Too many branches @@ -267,6 +268,10 @@ target-version = "py310" "test/*" = ["E402"] "test/common/test_styling.py" = ["RUF001", "E501"] "test/common/test_regex.py" = ["RUF001"] +"pep517build/*" = ["S603", "S607"] +"mac/*" = ["S603", "S607"] +"win/*" = ["S603", "S607"] +"scripts/*" = ["S603", "S607"]
[tool.ruff.mccabe] max-complexity = 15
View it on GitLab: https://dev.gajim.org/gajim/gajim/-/compare/17b9e7acc63fc5bb8d43131a9ebc4b57...