Fixes
This commit is contained in:
parent
90e379a6de
commit
cf5c5b1608
9 changed files with 148 additions and 111 deletions
|
@ -4,7 +4,7 @@ import sys
|
||||||
import traceback
|
import traceback
|
||||||
from random import shuffle
|
from random import shuffle
|
||||||
import threading
|
import threading
|
||||||
from time import sleep, time
|
from time import sleep
|
||||||
|
|
||||||
from gevent import monkey; monkey.patch_all(); del monkey # noqa
|
from gevent import monkey; monkey.patch_all(); del monkey # noqa
|
||||||
import gevent
|
import gevent
|
||||||
|
@ -75,7 +75,6 @@ from user_data.backup_service import BackupService
|
||||||
import styles.style # TODO: dynamic loading
|
import styles.style # TODO: dynamic loading
|
||||||
|
|
||||||
import wrapper_tests.support_testing as ts
|
import wrapper_tests.support_testing as ts
|
||||||
from wrapper_tests.tests_wrapper import test_bootstrap_iNmapInfo
|
|
||||||
|
|
||||||
global LOG
|
global LOG
|
||||||
import logging
|
import logging
|
||||||
|
@ -488,7 +487,7 @@ class App:
|
||||||
LOG.debug(f"_start_threads init: {te()!r}")
|
LOG.debug(f"_start_threads init: {te()!r}")
|
||||||
|
|
||||||
# starting threads for tox iterate and toxav iterate
|
# starting threads for tox iterate and toxav iterate
|
||||||
self._main_loop = threads.ToxIterateThread(self._tox, self)
|
self._main_loop = threads.ToxIterateThread(self._tox)
|
||||||
self._main_loop.start()
|
self._main_loop.start()
|
||||||
|
|
||||||
self._av_loop = threads.ToxAVIterateThread(self._tox.AV)
|
self._av_loop = threads.ToxAVIterateThread(self._tox.AV)
|
||||||
|
@ -775,8 +774,7 @@ class App:
|
||||||
# FixMe:
|
# FixMe:
|
||||||
self._log = lambda line: LOG.log(self._oArgs.loglevel,
|
self._log = lambda line: LOG.log(self._oArgs.loglevel,
|
||||||
self._ms.status(line))
|
self._ms.status(line))
|
||||||
self._ms._log = self._log # used in callbacks.py
|
# self._ms._log = self._log # was used in callbacks.py
|
||||||
self.LOG = self._log # backwards
|
|
||||||
|
|
||||||
if False:
|
if False:
|
||||||
self.status_handler = logging.Handler()
|
self.status_handler = logging.Handler()
|
||||||
|
@ -812,6 +810,7 @@ class App:
|
||||||
|
|
||||||
def _init_callbacks(self, ms=None):
|
def _init_callbacks(self, ms=None):
|
||||||
LOG.debug("_init_callbacks")
|
LOG.debug("_init_callbacks")
|
||||||
|
# this will block if you are not connected
|
||||||
callbacks.init_callbacks(self._tox, self._profile, self._settings,
|
callbacks.init_callbacks(self._tox, self._profile, self._settings,
|
||||||
self._plugin_loader, self._contacts_manager,
|
self._plugin_loader, self._contacts_manager,
|
||||||
self._calls_manager,
|
self._calls_manager,
|
||||||
|
@ -846,10 +845,10 @@ class App:
|
||||||
sleep(interval / 1000.0)
|
sleep(interval / 1000.0)
|
||||||
|
|
||||||
def _test_tox(self):
|
def _test_tox(self):
|
||||||
self.test_net(iMax=8)
|
self.test_net()
|
||||||
self._ms.log_console()
|
self._ms.log_console()
|
||||||
|
|
||||||
def test_net(self, oThread=None, iMax=6):
|
def test_net(self, lElts=None, oThread=None, iMax=4):
|
||||||
|
|
||||||
LOG.debug("test_net " +self._oArgs.network)
|
LOG.debug("test_net " +self._oArgs.network)
|
||||||
# bootstrap
|
# bootstrap
|
||||||
|
@ -905,9 +904,6 @@ class App:
|
||||||
LOG.trace(f"Connected status #{i}: {status!r}")
|
LOG.trace(f"Connected status #{i}: {status!r}")
|
||||||
self.loop(2)
|
self.loop(2)
|
||||||
|
|
||||||
global iLAST_CONN
|
|
||||||
iLAST_CONN = time()
|
|
||||||
|
|
||||||
def _test_env(self):
|
def _test_env(self):
|
||||||
_settings = self._settings
|
_settings = self._settings
|
||||||
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
if 'proxy_type' not in _settings or _settings['proxy_type'] == 0 or \
|
||||||
|
@ -961,7 +957,7 @@ class App:
|
||||||
lElts = self._settings['current_nodes_tcp']
|
lElts = self._settings['current_nodes_tcp']
|
||||||
shuffle(lElts)
|
shuffle(lElts)
|
||||||
try:
|
try:
|
||||||
test_bootstrap_iNmapInfo(lElts)
|
bootstrap_iNodeInfo(lElts)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
# json.decoder.JSONDecodeError
|
# json.decoder.JSONDecodeError
|
||||||
LOG.error(f"test_tox ' +' : {e}")
|
LOG.error(f"test_tox ' +' : {e}")
|
||||||
|
|
|
@ -93,10 +93,10 @@ class ContactsManager(ToxSave):
|
||||||
|
|
||||||
def is_contact_active(self, contact):
|
def is_contact_active(self, contact):
|
||||||
if not self._active_contact:
|
if not self._active_contact:
|
||||||
LOG.warn("No self._active_contact")
|
# LOG.debug("No self._active_contact")
|
||||||
return False
|
return False
|
||||||
if self._active_contact not in self._contacts:
|
if self._active_contact not in self._contacts:
|
||||||
LOG.debug(f"_active_contact={self._active_contact} len={len(self._contacts)}")
|
LOG.warn(f"_active_contact={self._active_contact} not in contacts len={len(self._contacts)}")
|
||||||
return False
|
return False
|
||||||
if not self._contacts[self._active_contact]:
|
if not self._contacts[self._active_contact]:
|
||||||
LOG.debug(f"{self._contacts[self._active_contact]} {contact.tox_id}")
|
LOG.debug(f"{self._contacts[self._active_contact]} {contact.tox_id}")
|
||||||
|
@ -241,7 +241,7 @@ class ContactsManager(ToxSave):
|
||||||
# AttributeError: 'NoneType' object has no attribute 'number'
|
# AttributeError: 'NoneType' object has no attribute 'number'
|
||||||
for (i, contact) in enumerate(self._contacts):
|
for (i, contact) in enumerate(self._contacts):
|
||||||
if contact is None or not hasattr(contact, 'number'):
|
if contact is None or not hasattr(contact, 'number'):
|
||||||
LOG.error("Contact {i} is None or not hasattr 'number'")
|
LOG.error(f"Contact {i} is None or not hasattr 'number'")
|
||||||
del self._contacts[i]
|
del self._contacts[i]
|
||||||
continue
|
continue
|
||||||
contacts = sorted(self._contacts, key=lambda c: c.number)
|
contacts = sorted(self._contacts, key=lambda c: c.number)
|
||||||
|
|
|
@ -35,19 +35,8 @@ with ts.ignoreStderr():
|
||||||
__maintainer__ = 'Ingvar'
|
__maintainer__ = 'Ingvar'
|
||||||
__version__ = '0.5.0+'
|
__version__ = '0.5.0+'
|
||||||
|
|
||||||
from PyQt5 import QtCore
|
import time
|
||||||
import gevent
|
sleep = time.sleep
|
||||||
if 'QtCore' in sys.modules:
|
|
||||||
def qt_sleep(fSec):
|
|
||||||
if fSec > .001:
|
|
||||||
QtCore.QThread.msleep(int(fSec*1000.0))
|
|
||||||
QtCore.QCoreApplication.processEvents()
|
|
||||||
sleep = qt_sleep
|
|
||||||
elif 'gevent' in sys.modules:
|
|
||||||
sleep = gevent.sleep
|
|
||||||
else:
|
|
||||||
import time
|
|
||||||
sleep = time.sleep
|
|
||||||
|
|
||||||
def reset():
|
def reset():
|
||||||
Settings.reset_auto_profile()
|
Settings.reset_auto_profile()
|
||||||
|
@ -230,6 +219,9 @@ def main_parser():
|
||||||
parser.add_argument('--udp_enabled',type=str,
|
parser.add_argument('--udp_enabled',type=str,
|
||||||
default='True', choices=['True','False'],
|
default='True', choices=['True','False'],
|
||||||
help='En/Disable udp')
|
help='En/Disable udp')
|
||||||
|
parser.add_argument('--trace_enabled',type=str,
|
||||||
|
default='False', choices=['True','False'],
|
||||||
|
help='Debugging from toxcore logger_trace')
|
||||||
parser.add_argument('--ipv6_enabled',type=str,
|
parser.add_argument('--ipv6_enabled',type=str,
|
||||||
default=bIpV6, choices=lIpV6Choices,
|
default=bIpV6, choices=lIpV6Choices,
|
||||||
help='En/Disable ipv6')
|
help='En/Disable ipv6')
|
||||||
|
|
|
@ -97,20 +97,19 @@ class Messenger(tox_save.ToxSave):
|
||||||
:param friend_number: number of friend
|
:param friend_number: number of friend
|
||||||
from Qt callback
|
from Qt callback
|
||||||
"""
|
"""
|
||||||
|
if not text:
|
||||||
|
return
|
||||||
if friend_number is None:
|
if friend_number is None:
|
||||||
friend_number = self._contacts_manager.get_active_number()
|
friend_number = self._contacts_manager.get_active_number()
|
||||||
if friend_number is None:
|
if friend_number is None or friend_number < 0:
|
||||||
LOG.error(f"No _contacts_manager.get_active_number")
|
LOG.error(f"No _contacts_manager.get_active_number")
|
||||||
return
|
return
|
||||||
if not text or friend_number < 0:
|
|
||||||
return
|
|
||||||
assert_main_thread()
|
assert_main_thread()
|
||||||
|
|
||||||
friend = self._get_friend_by_number(friend_number)
|
friend = self._get_friend_by_number(friend_number)
|
||||||
if not friend:
|
if not friend:
|
||||||
LOG.error(f"No self._get_friend_by_number")
|
LOG.error(f"No self._get_friend_by_number")
|
||||||
return
|
return
|
||||||
assert friend
|
|
||||||
messages = self._split_message(text.encode('utf-8'))
|
messages = self._split_message(text.encode('utf-8'))
|
||||||
t = util.get_unix_time()
|
t = util.get_unix_time()
|
||||||
for message in messages:
|
for message in messages:
|
||||||
|
@ -336,8 +335,8 @@ class Messenger(tox_save.ToxSave):
|
||||||
self._add_info_message(friend_number, text)
|
self._add_info_message(friend_number, text)
|
||||||
|
|
||||||
def _add_info_message(self, friend_number, text):
|
def _add_info_message(self, friend_number, text):
|
||||||
assert friend
|
|
||||||
friend = self._get_friend_by_number(friend_number)
|
friend = self._get_friend_by_number(friend_number)
|
||||||
|
assert friend
|
||||||
message = InfoMessage(text, util.get_unix_time())
|
message = InfoMessage(text, util.get_unix_time())
|
||||||
friend.append_message(message)
|
friend.append_message(message)
|
||||||
if self._contacts_manager.is_friend_active(friend_number):
|
if self._contacts_manager.is_friend_active(friend_number):
|
||||||
|
|
|
@ -10,18 +10,6 @@ from wrapper.toxcore_enums_and_consts import TOX_USER_STATUS, TOX_CONNECTION
|
||||||
import wrapper_tests.support_testing as ts
|
import wrapper_tests.support_testing as ts
|
||||||
from utils import util
|
from utils import util
|
||||||
|
|
||||||
if 'QtCore' in sys.modules:
|
|
||||||
def qt_sleep(fSec):
|
|
||||||
if fSec > .001:
|
|
||||||
QtCore.QThread.msleep(int(fSec*1000.0))
|
|
||||||
QtCore.QCoreApplication.processEvents()
|
|
||||||
sleep = qt_sleep
|
|
||||||
elif 'gevent' in sys.modules:
|
|
||||||
import gevent
|
|
||||||
sleep = gevent.sleep
|
|
||||||
else:
|
|
||||||
import time
|
|
||||||
sleep = time.sleep
|
|
||||||
import time
|
import time
|
||||||
sleep = time.sleep
|
sleep = time.sleep
|
||||||
|
|
||||||
|
@ -63,7 +51,7 @@ class BaseThread(threading.Thread):
|
||||||
if not self.is_alive(): break
|
if not self.is_alive(): break
|
||||||
i = i + 1
|
i = i + 1
|
||||||
else:
|
else:
|
||||||
LOG_WARN(f"BaseThread {self.name} BLOCKED")
|
LOG_WARN(f"BaseThread {self.name} BLOCKED after {ts.iTHREAD_JOINS}")
|
||||||
|
|
||||||
class BaseQThread(QtCore.QThread):
|
class BaseQThread(QtCore.QThread):
|
||||||
|
|
||||||
|
@ -101,10 +89,12 @@ class InitThread(BaseThread):
|
||||||
self._is_first_start = is_first_start
|
self._is_first_start = is_first_start
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
# DBUG+ InitThread run: ERROR name 'ts' is not defined
|
||||||
|
import wrapper_tests.support_testing as ts
|
||||||
LOG_DEBUG('InitThread run: ')
|
LOG_DEBUG('InitThread run: ')
|
||||||
try:
|
try:
|
||||||
if self._is_first_start and ts.bAreWeConnected():
|
if self._is_first_start and ts.bAreWeConnected() and \
|
||||||
if self._settings['download_nodes_list']:
|
self._settings['download_nodes_list']:
|
||||||
LOG_INFO('downloading list of nodes')
|
LOG_INFO('downloading list of nodes')
|
||||||
download_nodes_list(self._settings, oArgs=self._app._args)
|
download_nodes_list(self._settings, oArgs=self._app._args)
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ def LOG_INFO(a):
|
||||||
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20
|
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 20
|
||||||
if bVERBOSE: print('INFO> '+a)
|
if bVERBOSE: print('INFO> '+a)
|
||||||
def LOG_DEBUG(a):
|
def LOG_DEBUG(a):
|
||||||
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10-1
|
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel <= 10
|
||||||
if bVERBOSE: print('DBUG> '+a)
|
if bVERBOSE: print('DBUG> '+a)
|
||||||
def LOG_TRACE(a):
|
def LOG_TRACE(a):
|
||||||
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10
|
bVERBOSE = hasattr(__builtins__, 'app') and app.oArgs.loglevel < 10
|
||||||
|
@ -39,18 +39,21 @@ def tox_log_cb(iTox, level, file, line, func, message, *args):
|
||||||
* @param user_data The user data pointer passed to tox_new in options.
|
* @param user_data The user data pointer passed to tox_new in options.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if type(file) == bytes:
|
|
||||||
file = str(file, 'UTF-8')
|
file = str(file, 'UTF-8')
|
||||||
if file == 'network.c' and line in [944, 660]: return
|
|
||||||
# root WARNING 3network.c#944:b'send_packet'attempted to send message with network family 10 (probably IPv6) on IPv4 socket
|
# root WARNING 3network.c#944:b'send_packet'attempted to send message with network family 10 (probably IPv6) on IPv4 socket
|
||||||
if type(func) == bytes:
|
if file == 'network.c' and line in [944, 660]: return
|
||||||
func = str(func, 'UTF-8')
|
func = str(func, 'UTF-8')
|
||||||
if type(message) == bytes:
|
|
||||||
message = str(message, 'UTF-8')
|
message = str(message, 'UTF-8')
|
||||||
message = f"{file}#{line}:{func} {message}"
|
message = f"{file}#{line}:{func} {message}"
|
||||||
LOG_LOG(message)
|
LOG_LOG(message)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG_ERROR("tox_log_cb {e}")
|
LOG_ERROR(f"tox_log_cb {e}")
|
||||||
|
|
||||||
|
#tox_log_handler (context=0x24763d0,
|
||||||
|
# level=LOGGER_LEVEL_TRACE, file=0x7fffe599fb99 "TCP_common.c", line=203,
|
||||||
|
# func=0x7fffe599fc50 <__func__.2> "read_TCP_packet",
|
||||||
|
# message=0x7fffba7fabd0 "recv buffer has 0 bytes, but requested 10 bytes",
|
||||||
|
# userdata=0x0) at /var/local/src/c-toxcore/toxcore/tox.c:78
|
||||||
|
|
||||||
def tox_factory(data=None, settings=None, args=None, app=None):
|
def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
"""
|
"""
|
||||||
|
@ -98,7 +101,8 @@ def tox_factory(data=None, settings=None, args=None, app=None):
|
||||||
|
|
||||||
LOG.debug("wrapper.tox.Tox settings: " +repr(settings))
|
LOG.debug("wrapper.tox.Tox settings: " +repr(settings))
|
||||||
|
|
||||||
if tox_options._options_pointer:
|
if 'trace_enabled' in settings and settings['trace_enabled'] and \
|
||||||
|
tox_options._options_pointer:
|
||||||
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p)
|
c_callback = CFUNCTYPE(None, c_void_p, c_int, c_char_p, c_int, c_char_p, c_char_p, c_void_p)
|
||||||
tox_options.self_logger_cb = c_callback(tox_log_cb)
|
tox_options.self_logger_cb = c_callback(tox_log_cb)
|
||||||
wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
wrapper.tox.Tox.libtoxcore.tox_options_set_log_callback(
|
||||||
|
|
|
@ -26,7 +26,44 @@ except Exception as e:
|
||||||
LOG.warn(e)
|
LOG.warn(e)
|
||||||
PythonConsole = None
|
PythonConsole = None
|
||||||
else:
|
else:
|
||||||
|
if True:
|
||||||
|
# I want to do reverse video but I cant figure how
|
||||||
|
bg='white'
|
||||||
def hl_format(color, style=''):
|
def hl_format(color, style=''):
|
||||||
|
"""Return a QTextCharFormat with the given attributes.
|
||||||
|
"""
|
||||||
|
_color = QColor()
|
||||||
|
_color.setNamedColor(color)
|
||||||
|
|
||||||
|
_format = QTextCharFormat()
|
||||||
|
_format.setForeground(_color)
|
||||||
|
if 'bold' in style:
|
||||||
|
_format.setFontWeight(QFont.Bold)
|
||||||
|
if 'italic' in style:
|
||||||
|
_format.setFontItalic(True)
|
||||||
|
|
||||||
|
_bgcolor = QColor()
|
||||||
|
_bgcolor.setNamedColor(bg)
|
||||||
|
_format.setBackground(_bgcolor)
|
||||||
|
return _format
|
||||||
|
|
||||||
|
aFORMATS = {
|
||||||
|
'keyword': hl_format('blue', 'bold'),
|
||||||
|
'operator': hl_format('red'),
|
||||||
|
'brace': hl_format('darkGray'),
|
||||||
|
'defclass': hl_format('black', 'bold'),
|
||||||
|
'string': hl_format('magenta'),
|
||||||
|
'string2': hl_format('darkMagenta'),
|
||||||
|
'comment': hl_format('darkGreen', 'italic'),
|
||||||
|
'self': hl_format('black', 'italic'),
|
||||||
|
'numbers': hl_format('brown'),
|
||||||
|
'inprompt': hl_format('darkBlue', 'bold'),
|
||||||
|
'outprompt': hl_format('darkRed', 'bold'),
|
||||||
|
}
|
||||||
|
else:
|
||||||
|
bg = 'black'
|
||||||
|
def hl_format(color, style=''):
|
||||||
|
|
||||||
"""Return a QTextCharFormat with the given attributes.
|
"""Return a QTextCharFormat with the given attributes.
|
||||||
unused
|
unused
|
||||||
"""
|
"""
|
||||||
|
@ -34,29 +71,28 @@ else:
|
||||||
_color.setNamedColor(color)
|
_color.setNamedColor(color)
|
||||||
|
|
||||||
_format = QTextCharFormat()
|
_format = QTextCharFormat()
|
||||||
_format.setBackground(_color)
|
_format.setForeground(_color)
|
||||||
if 'bold' in style:
|
if 'bold' in style:
|
||||||
_format.setFontWeight(QFont.Bold)
|
_format.setFontWeight(QFont.Bold)
|
||||||
if 'italic' in style:
|
if 'italic' in style:
|
||||||
_format.setFontItalic(True)
|
_format.setFontItalic(True)
|
||||||
|
|
||||||
_fgcolor = QColor()
|
_bgcolor = QColor()
|
||||||
_fgcolor.setNamedColor('white')
|
_bgcolor.setNamedColor(bg)
|
||||||
_format.setForeground(_fgcolor)
|
_format.setBackground(_bgcolor)
|
||||||
return _format
|
return _format
|
||||||
|
|
||||||
aFORMATS = {
|
aFORMATS = {
|
||||||
'keyword': hl.format('blue', 'bold'),
|
'keyword': hl_format('blue', 'bold'),
|
||||||
'operator': hl.format('red'),
|
'operator': hl_format('red'),
|
||||||
'brace': hl.format('darkGray'),
|
'brace': hl_format('lightGray'),
|
||||||
'defclass': hl.format('black', 'bold'),
|
'defclass': hl_format('white', 'bold'),
|
||||||
'string': hl.format('magenta'),
|
'string': hl_format('magenta'),
|
||||||
'string2': hl.format('darkMagenta'),
|
'string2': hl_format('lightMagenta'),
|
||||||
'comment': hl.format('darkGreen', 'italic'),
|
'comment': hl_format('lightGreen', 'italic'),
|
||||||
'self': hl.format('black', 'italic'),
|
'self': hl_format('white', 'italic'),
|
||||||
'numbers': hl.format('brown'),
|
'numbers': hl_format('lightBrown'),
|
||||||
'inprompt': hl.format('darkBlue', 'bold'),
|
'inprompt': hl_format('lightBlue', 'bold'),
|
||||||
'outprompt': hl.format('darkRed', 'bold'),
|
'outprompt': hl_format('lightRed', 'bold'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -177,8 +213,10 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
|
|
||||||
self.actionTest_tox = QtWidgets.QAction(window)
|
self.actionTest_tox = QtWidgets.QAction(window)
|
||||||
self.actionTest_tox.setObjectName("actionTest_tox")
|
self.actionTest_tox.setObjectName("actionTest_tox")
|
||||||
self.actionTest_socks = QtWidgets.QAction(window)
|
self.actionTest_nmap = QtWidgets.QAction(window)
|
||||||
self.actionTest_socks.setObjectName("actionTest_socks")
|
self.actionTest_nmap.setObjectName("actionTest_nmap")
|
||||||
|
self.actionTest_main = QtWidgets.QAction(window)
|
||||||
|
self.actionTest_main.setObjectName("actionTest_main")
|
||||||
self.actionQuit_program = QtWidgets.QAction(window)
|
self.actionQuit_program = QtWidgets.QAction(window)
|
||||||
self.actionQuit_program.setObjectName("actionQuit_program")
|
self.actionQuit_program.setObjectName("actionQuit_program")
|
||||||
|
|
||||||
|
@ -231,7 +269,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.menuProfile.addAction(self.actionSettings)
|
self.menuProfile.addAction(self.actionSettings)
|
||||||
self.menuProfile.addAction(self.lockApp)
|
self.menuProfile.addAction(self.lockApp)
|
||||||
self.menuProfile.addAction(self.actionTest_tox)
|
self.menuProfile.addAction(self.actionTest_tox)
|
||||||
self.menuProfile.addAction(self.actionTest_socks)
|
self.menuProfile.addAction(self.actionTest_nmap)
|
||||||
|
self.menuProfile.addAction(self.actionTest_main)
|
||||||
self.menuProfile.addAction(self.actionQuit_program)
|
self.menuProfile.addAction(self.actionQuit_program)
|
||||||
|
|
||||||
self.menuGC.addAction(self.createGC)
|
self.menuGC.addAction(self.createGC)
|
||||||
|
@ -260,7 +299,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.menubar.addAction(self.menuPlugins.menuAction())
|
self.menubar.addAction(self.menuPlugins.menuAction())
|
||||||
self.menubar.addAction(self.menuAbout.menuAction())
|
self.menubar.addAction(self.menuAbout.menuAction())
|
||||||
|
|
||||||
self.actionTest_socks.triggered.connect(self.test_socks)
|
self.actionTest_nmap.triggered.connect(self.test_nmap)
|
||||||
|
self.actionTest_main.triggered.connect(self.test_main)
|
||||||
self.actionTest_tox.triggered.connect(self.test_tox)
|
self.actionTest_tox.triggered.connect(self.test_tox)
|
||||||
|
|
||||||
self.actionQuit_program.triggered.connect(self.quit_program)
|
self.actionQuit_program.triggered.connect(self.quit_program)
|
||||||
|
@ -322,7 +362,8 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
self.actionLog_console.setText(util_ui.tr("Console Log"))
|
self.actionLog_console.setText(util_ui.tr("Console Log"))
|
||||||
self.actionPython_console.setText(util_ui.tr("Python Console"))
|
self.actionPython_console.setText(util_ui.tr("Python Console"))
|
||||||
self.actionTest_tox.setText(util_ui.tr("Bootstrap"))
|
self.actionTest_tox.setText(util_ui.tr("Bootstrap"))
|
||||||
self.actionTest_socks.setText(util_ui.tr("Test program"))
|
self.actionTest_nmap.setText(util_ui.tr("Test Nmap"))
|
||||||
|
self.actionTest_main.setText(util_ui.tr("Test Program"))
|
||||||
self.actionQuit_program.setText(util_ui.tr("Quit program"))
|
self.actionQuit_program.setText(util_ui.tr("Quit program"))
|
||||||
self.actionSettings.setText(util_ui.tr("Settings"))
|
self.actionSettings.setText(util_ui.tr("Settings"))
|
||||||
self.audioSettings.setText(util_ui.tr("Audio"))
|
self.audioSettings.setText(util_ui.tr("Audio"))
|
||||||
|
@ -628,13 +669,17 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if not self._pe:
|
if not self._pe:
|
||||||
self._pe = PythonConsole(sFont=font_name,
|
self._pe = PythonConsole(formats=aFORMATS)
|
||||||
formats=aFORMATS,
|
|
||||||
bBold=True,
|
|
||||||
font_width=size)
|
|
||||||
self._pe.setWindowTitle('variable: app is the application')
|
self._pe.setWindowTitle('variable: app is the application')
|
||||||
# self._pe.edit.setStyleSheet('foreground: white; background-color: black;}')
|
# self._pe.edit.setStyleSheet('foreground: white; background-color: black;}')
|
||||||
# Fix the pyconsole geometry
|
# Fix the pyconsole geometry
|
||||||
|
|
||||||
|
font = self._pe.edit.document().defaultFont()
|
||||||
|
font.setFamily(font_name)
|
||||||
|
font.setBold(True)
|
||||||
|
if font_width is None:
|
||||||
|
font_width = QFontMetrics(font).width('M')
|
||||||
|
self._pe.setFont(font)
|
||||||
geometry = self._pe.geometry()
|
geometry = self._pe.geometry()
|
||||||
geometry.setWidth(font_width*80+20)
|
geometry.setWidth(font_width*80+20)
|
||||||
geometry.setHeight(font_width*40)
|
geometry.setHeight(font_width*40)
|
||||||
|
@ -736,6 +781,9 @@ class MainWindow(QtWidgets.QMainWindow):
|
||||||
def test_nmap(self):
|
def test_nmap(self):
|
||||||
self._app._test_nmap()
|
self._app._test_nmap()
|
||||||
|
|
||||||
|
def test_main(self):
|
||||||
|
self._app._test_main()
|
||||||
|
|
||||||
def quit_program(self):
|
def quit_program(self):
|
||||||
try:
|
try:
|
||||||
self.close_window()
|
self.close_window()
|
||||||
|
|
|
@ -63,9 +63,17 @@ class ProfileManager:
|
||||||
def save_profile(self, data):
|
def save_profile(self, data):
|
||||||
if self._toxes.has_password():
|
if self._toxes.has_password():
|
||||||
data = self._toxes.pass_encrypt(data)
|
data = self._toxes.pass_encrypt(data)
|
||||||
with open(self._path, 'wb') as fl:
|
try:
|
||||||
|
suf = f"{os.getpid()}"
|
||||||
|
with open(self._path+suf, 'wb') as fl:
|
||||||
fl.write(data)
|
fl.write(data)
|
||||||
|
stat = os.stat(self._path+suf)
|
||||||
|
if hasattr(stat, 'st_blocks'):
|
||||||
|
assert stat.st_blocks > 0, f"Zero length file {self._path+suf}"
|
||||||
|
os.rename(self._path+suf,self._path)
|
||||||
LOG_INFO('Profile saved successfully to' +self._path)
|
LOG_INFO('Profile saved successfully to' +self._path)
|
||||||
|
except Exception as e:
|
||||||
|
LOG_WARN(f"Profile save failed to {self._path}\n{e}")
|
||||||
|
|
||||||
self._profile_saved_event(data)
|
self._profile_saved_event(data)
|
||||||
|
|
||||||
|
|
|
@ -138,9 +138,8 @@ class Settings(dict):
|
||||||
self._profile_path = path.replace('.json', '.tox')
|
self._profile_path = path.replace('.json', '.tox')
|
||||||
self._toxes = toxes
|
self._toxes = toxes
|
||||||
self._app = app
|
self._app = app
|
||||||
self._args = app._args
|
self._oArgs = app._oArgs
|
||||||
self.LOG = lambda l: LOG.log(self._args.loglevel, l)
|
self._log = lambda l: LOG.log(self._oArgs.loglevel, l)
|
||||||
self._log = self.LOG
|
|
||||||
|
|
||||||
self._settings_saved_event = Event()
|
self._settings_saved_event = Event()
|
||||||
if path and os.path.isfile(path):
|
if path and os.path.isfile(path):
|
||||||
|
@ -156,29 +155,29 @@ class Settings(dict):
|
||||||
text = title + path
|
text = title + path
|
||||||
LOG.error(title +str(ex))
|
LOG.error(title +str(ex))
|
||||||
util_ui.message_box(text, title)
|
util_ui.message_box(text, title)
|
||||||
info = Settings.get_default_settings(app._args)
|
info = Settings.get_default_settings(app._oArgs)
|
||||||
user_data.settings.clean_settings(info)
|
user_data.settings.clean_settings(info)
|
||||||
else:
|
else:
|
||||||
LOG.debug('get_default_settings for: ' + repr(path))
|
LOG.debug('get_default_settings for: ' + repr(path))
|
||||||
info = Settings.get_default_settings(app._args)
|
info = Settings.get_default_settings(app._oArgs)
|
||||||
|
|
||||||
if not os.path.exists(path):
|
if not os.path.exists(path):
|
||||||
merge_args_into_settings(app._args, info)
|
merge_oArgs_into_settings(app._oArgs, info)
|
||||||
else:
|
else:
|
||||||
aC = self._changed(app._args, info)
|
aC = self._changed(app._oArgs, info)
|
||||||
if aC:
|
if aC:
|
||||||
title = 'Override profile with commandline - '
|
title = 'Override profile with commandline - '
|
||||||
if path:
|
if path:
|
||||||
title += os.path.basename(path)
|
title += os.path.basename(path)
|
||||||
text = 'Override profile with command-line settings? \n'
|
text = 'Override profile with command-line settings? \n'
|
||||||
# text += '\n'.join([str(key) +'=' +str(val) for
|
# text += '\n'.join([str(key) +'=' +str(val) for
|
||||||
# key,val in self._changed(app._args).items()])
|
# key,val in self._changed(app._oArgs).items()])
|
||||||
text += repr(aC)
|
text += repr(aC)
|
||||||
reply = util_ui.question(text, title)
|
reply = util_ui.question(text, title)
|
||||||
if reply:
|
if reply:
|
||||||
merge_args_into_settings(app._args, info)
|
merge_oArgs_into_settings(app._oArgs, info)
|
||||||
info['audio'] = getattr(app._args, 'audio')
|
info['audio'] = getattr(app._oArgs, 'audio')
|
||||||
info['video'] = getattr(app._args, 'video')
|
info['video'] = getattr(app._oArgs, 'video')
|
||||||
super().__init__(info)
|
super().__init__(info)
|
||||||
self._upgrade()
|
self._upgrade()
|
||||||
|
|
||||||
|
@ -316,6 +315,7 @@ class Settings(dict):
|
||||||
# FixMe: match? /var/local/src/c-toxcore/toxcore/tox.h
|
# FixMe: match? /var/local/src/c-toxcore/toxcore/tox.h
|
||||||
'ipv6_enabled': True,
|
'ipv6_enabled': True,
|
||||||
'udp_enabled': True,
|
'udp_enabled': True,
|
||||||
|
'trace_enabled': False,
|
||||||
'local_discovery_enabled': True,
|
'local_discovery_enabled': True,
|
||||||
'dht_announcements_enabled': True,
|
'dht_announcements_enabled': True,
|
||||||
'proxy_type': 0,
|
'proxy_type': 0,
|
||||||
|
|
Loading…
Reference in a new issue