Merge for tox_irc_sync

This commit is contained in:
emdee 2022-10-27 06:50:47 +00:00
parent 564e24fba5
commit a3ad33495a
4 changed files with 23 additions and 24 deletions

View File

@ -84,4 +84,4 @@ To our point of view, the ability of CTYPEs to follow code in the
debugger is a crucial advantage. debugger is a crucial advantage.
Work on this project is suspended until the Work on this project is suspended until the
[MultiDevice](https://git.macaw.me/emdee/tox_profile/wiki/MultiDevice-Announcements-POC) problem is solved. Fork me! [MultiDevice](https://git.plastiras.org/emdee/tox_profile/wiki/MultiDevice-Announcements-POC) problem is solved. Fork me!

View File

@ -1938,7 +1938,7 @@ class Tox:
byref(error)) byref(error))
if error.value: if error.value:
LOG_ERROR(f"group_join {error.value}") LOG_ERROR(f"group_join {error.value}")
raise ToxError("group_join {error.value}") raise ToxError(f"group_join {error.value}")
return result return result
def group_reconnect(self, group_number): def group_reconnect(self, group_number):

View File

@ -15,9 +15,6 @@ import unittest
from random import Random from random import Random
random = Random() random = Random()
from PyQt5 import QtCore, QtWidgets
from qtpy.QtWidgets import QApplication
try: try:
import coloredlogs import coloredlogs
if 'COLOREDLOGS_LEVEL_STYLES' not in os.environ: if 'COLOREDLOGS_LEVEL_STYLES' not in os.environ:
@ -107,8 +104,10 @@ lDEAD_BS = [
"tox3.plastiras.org", "tox3.plastiras.org",
] ]
def assert_main_thread(): def assert_main_thread():
from PyQt5 import QtCore, QtWidgets
from qtpy.QtWidgets import QApplication
# this "instance" method is very useful! # this "instance" method is very useful!
app_thread = QtWidgets.QApplication.instance().thread() app_thread = QtWidgets.QApplication.instance().thread()
curr_thread = QtCore.QThread.currentThread() curr_thread = QtCore.QThread.currentThread()
@ -757,6 +756,24 @@ def bootstrap_tcp(lelts, lToxes):
LOG.debug(f'bootstrap_tcp to {host} but not connected') LOG.debug(f'bootstrap_tcp to {host} but not connected')
pass pass
def iNmapInfo(sProt, sHost, sPort, key=None, environ=None, bTest=False):
sFile = os.path.join("/tmp", f"{sHost}.{os.getpid()}.nmap")
if sProt in ['socks', 'socks5', 'tcp4']:
cmd = f"nmap -Pn -n -sT -p T:{sPort} {sHost} | grep /tcp >{sFile}"
else:
cmd = f"nmap -Pn -n -sU -p U:{sPort} {sHost} | grep /tcp >{sFile}"
iRet = os.system(cmd)
LOG.debug(f"iNmapInfo cmd={cmd} {iRet}")
if iRet != 0:
return iRet
assert os.path.exists(sFile), sFile
with open(sFile, 'rt') as oFd:
l = oFd.readlines()
assert len(l)
s = '\n'.join([s.strip() for s in l])
LOG.debug(f"iNmapInfo: {s}")
return 0
def bootstrap_iNmapInfo(lElts, oArgs, bIS_LOCAL=False, iNODES=iNODES): def bootstrap_iNmapInfo(lElts, oArgs, bIS_LOCAL=False, iNODES=iNODES):
if not bIS_LOCAL and not bAreWeConnected(): if not bIS_LOCAL and not bAreWeConnected():
LOG.warn(f"bootstrap_iNmapInfo not local and NOT CONNECTED") LOG.warn(f"bootstrap_iNmapInfo not local and NOT CONNECTED")

View File

@ -121,24 +121,6 @@ if not hasattr(unittest, 'skip'):
return _wrap1 return _wrap1
unittest.skip = unittest_skip unittest.skip = unittest_skip
def iNmapInfo(sProt, sHost, sPort, key=None, environ=None, bTest=False):
sFile = os.path.join("/tmp", f"{sHost}.{os.getpid()}.nmap")
if sProt in ['socks', 'socks5', 'tcp4']:
cmd = f"nmap -Pn -n -sT -p T:{sPort} {sHost} | grep /tcp >{sFile}"
else:
cmd = f"nmap -Pn -n -sU -p U:{sPort} {sHost} | grep /tcp >{sFile}"
iRet = os.system(cmd)
LOG.debug(f"iNmapInfo cmd={cmd} {iRet}")
if iRet != 0:
return iRet
assert os.path.exists(sFile), sFile
with open(sFile, 'rt') as oFd:
l = oFd.readlines()
assert len(l)
s = '\n'.join([s.strip() for s in l])
LOG.debug(f"iNmapInfo: {s}")
return 0
class ToxOptions(): class ToxOptions():
def __init__(self): def __init__(self):
self.ipv6_enabled = True self.ipv6_enabled = True