Philipp Hörist pushed to branch master at gajim / gajim
Commits:
4a49825f by Philipp Hörist at 2022-12-29T23:29:13+01:00
refactor: Remove unused code
- - - - -
3 changed files:
- gajim/common/app.py
- gajim/common/helpers.py
- gajim/gui_interface.py
Changes:
=====================================
gajim/common/app.py
=====================================
@@ -67,8 +67,6 @@
interface = cast(types.InterfaceT, None)
-# Interface to run a thread and then a callback
-thread_interface = None
config = c_config.Config()
settings = cast(types.SettingsT, None)
version = gajim.__version__
=====================================
gajim/common/helpers.py
=====================================
@@ -36,9 +36,7 @@
import sys
import re
import os
-import subprocess
import hashlib
-import shlex
import socket
import logging
import json
@@ -311,30 +309,6 @@ def chatstate_to_string(chatstate: Optional[Chatstate]) ->
str:
raise ValueError('unknown value: %s' % chatstate)
-def exec_command(command: str,
- use_shell: bool = False,
- posix: bool = True
- ) -> None:
- '''
- execute a command. if use_shell is True, we run the command as is it was
- typed in a console. So it may be dangerous if you are not sure about what
- is executed.
- '''
- if use_shell:
- subprocess.Popen(f'{command} &', shell=True).wait()
- else:
- args = shlex.split(command, posix=posix)
- process = subprocess.Popen(args)
- app.thread_interface(process.wait)
-
-
-def build_command(executable: str, parameter: str) -> str:
- # we add to the parameter (can hold path with spaces)
- # "" so we have good parsing from shell
- parameter = parameter.replace('"', '\\"') # but first escape "
- return f'{executable} "{parameter}"'
-
-
def sanitize_filename(filename: str) -> str:
'''
Sanitize filename of elements not allowed on Windows
=====================================
gajim/gui_interface.py
=====================================
@@ -65,7 +65,6 @@
class Interface:
def __init__(self):
app.interface = self
- app.thread_interface = ThreadInterface
app.idlequeue = idlequeue.get_idlequeue()
# resolve and keep current record of resolved hosts
@@ -226,20 +225,3 @@ def run(self, _application: Gtk.Application) -> None:
GLib.timeout_add_seconds(timeout, self.process_connections)
else:
GLib.timeout_add(timeout, self.process_connections)
-
-
-class ThreadInterface:
- def __init__(self, func, func_args=(), callback=None, callback_args=()):
- '''
- Call a function in a thread
- '''
- def thread_function(func, func_args, callback, callback_args):
- output = func(*func_args)
- if callback:
- GLib.idle_add(callback, output, *callback_args)
-
- Thread(target=thread_function,
- args=(func,
- func_args,
- callback,
- callback_args)).start()
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/4a49825fca93e9ce0b2e67aef7c55caa2257e013
--
View it on GitLab:
https://dev.gajim.org/gajim/gajim/-/commit/4a49825fca93e9ce0b2e67aef7c55caa2257e013
You're receiving this email because of your account on dev.gajim.org.
_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits