updates
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Has been cancelled

This commit is contained in:
emdee@spm.plastiras.org 2024-02-02 03:14:37 +00:00
parent 6aca75d2cb
commit 74a29f7ce3
8 changed files with 82 additions and 44 deletions

View File

@ -1,21 +1,28 @@
PYTHON=python3 PREFIX=/usr/local
PYTHON=python3.sh
PIP=pip3.sh
prepare:: prepare::
bash .pylint.sh bash .pylint.sh
check:: check::
PYTHONPATH=$${PWD} pyanalyze \ PYTHONPATH=$${PWD}/src pyanalyze \
tox_wrapper/tox.py tox_wrapper/tests/tests_wrapper.py \ src/tox_wrapper/tox.py src/tox_wrapper/tests/tests_wrapper.py \
> .pyanal.out 2>&1 > .pyanal.out 2>&1
install:: install::
$(PYTHON) setup.py install $(PIP) install --target $PREFIX/lib/python3.11/site-packages --upgrade .
rsync::
bash .rsync.sh
help:: help::
$(PYTHON) tox_wrapper/tests/tests_wrapper.py --help PYTHONPATH=$${PWD}/src \
$(PYTHON) src/tox_wrapper/tests/tests_wrapper.py --help
test:: test::
$(PYTHON) tox_wrapper/tests/tests_wrapper.py PYTHONPATH=$${PWD}/src \
$(PYTHON) src/tox_wrapper/tests/tests_wrapper.py
clean:: clean::
rm -f .[a-z]* *~ */*~ */*/*~ rm -f .[a-z]* *~ */*~ */*/*~

View File

@ -1,22 +1,46 @@
[tool.poetry] [project]
name = "tox_wrapper" name = "tox_wrapper"
version = "1.0.0"
description = "A Python3 ctypes wrapping of c-toxcore into Python." description = "A Python3 ctypes wrapping of c-toxcore into Python."
authors = ["Ingvar"] authors = [{ name = "Ingvar", email = "Ingvar@gitgub.com" } ]
requires-python = ">=3.6"
keywords = ["tox", "python3", "ctypes"]
classifiers = [
"License :: OSI Approved",
"Operating System :: POSIX :: BSD :: FreeBSD",
"Operating System :: POSIX :: Linux",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
]
dynamic = ["version", "readme", ] # cannot be dynamic ['license']
[project.scripts]
tox_wrapper_tests = "tox_wrapper.tests.tests_wrapper:main"
toxygen_echo = "tox_wrapper.toxygen_echo:main"
# ...
[tool.setuptools.dynamic]
version = {attr = "tox_wrapper.__version__"}
readme = {file = ["README.md"]}
[project.license]
file = "LICENSE.md"
[project.urls]
repository = "https://git.plastiras.org/emdee/toxygen_wrapper" repository = "https://git.plastiras.org/emdee/toxygen_wrapper"
keywords = ["tox","python3","ctypes"]
license = "GPL3"
[tool.poetry.dependencies]
python = ">=3.6;<3.12"
# Stuff needed for development, but not for install&usage
# [tool.poetry.dev-dependencies]
[build-system] [build-system]
requires = ["setuptools >= 61.0"] requires = ["setuptools >= 61.0"]
build-backend = "setuptools.build_meta" build-backend = "setuptools.build_meta"
[tool.setuptools.packages.find] [tool.setuptools]
where = "src" packages = ["tox_wrapper", "tox_wrapper.tests"]
#[tool.setuptools.packages.find]
#where = "src"

View File

@ -1,9 +1,7 @@
[metadata] [metadata]
classifiers = classifiers =
License :: OSI Approved License :: OSI Approved
License :: OSI Approved :: BSD 1-clause
Intended Audience :: Web Developers Intended Audience :: Web Developers
Operating System :: Microsoft :: Windows
Operating System :: POSIX :: BSD :: FreeBSD Operating System :: POSIX :: BSD :: FreeBSD
Operating System :: POSIX :: Linux Operating System :: POSIX :: Linux
Programming Language :: Python :: 3 :: Only Programming Language :: Python :: 3 :: Only
@ -15,28 +13,26 @@ classifiers =
Programming Language :: Python :: 3.11 Programming Language :: Python :: 3.11
Programming Language :: Python :: Implementation :: CPython Programming Language :: Python :: Implementation :: CPython
Framework :: AsyncIO Framework :: AsyncIO
description='Tox ctypes wrapping into Python', description='Tox ctypes wrapping into Python'
long_description='Tox ctypes wrapping of c-toxcore into Python3', long_description='Tox ctypes wrapping of c-toxcore into Python3'
url='https://git.plastiras.org/emdee/toxygen_wrapper/', url='https://git.plastiras.org/emdee/toxygen_wrapper/'
keywords='ctypes Tox messenger', keywords='ctypes Tox messenger'
author='Ingvar',
[options] [options]
zip_safe = false zip_safe = false
python_requires = ~=3.6 #python_requires = >=3.6
include_package_data = false include_package_data = false
install_requires =
ctypes
package_dir= package_dir=
=src =src
packages=find: packages = ["tox_wrapper", "tox_wrapper.tests"]
[options.packages.find] [options.packages.find]
where=src where=src
[options.entry_points] [options.entry_points]
console_scripts = console_scripts =
tox_wrapper_tests = tox_wrapper.tests_wrapper:main tox_wrapper_tests = tox_wrapper.tests.tests_wrapper:main
[easy_install] [easy_install]
zip_ok = false zip_ok = false

View File

@ -15,7 +15,7 @@ setup(name='tox_wrapper',
maintainer='', maintainer='',
license='GPL3', license='GPL3',
packages=['tox_wrapper'], packages=['tox_wrapper'],
install_requires=[], install_requires=['ctypes'],
include_package_data=True, include_package_data=True,
# dont run directly if you need a proxy # dont run directly if you need a proxy
# run python3 tox_wrapper/tests/tests_wrapper.py --help # run python3 tox_wrapper/tests/tests_wrapper.py --help

5
src/__init__.py Normal file
View File

@ -0,0 +1,5 @@
# -*- mode: python; indent-tabs-mode: nil; py-indent-offset: 4; coding: utf-8 -*-
# You need a libs directory beside this directory
# and you need to link your libtoxcore.so and libtoxav.so
# and libtoxencryptsave.so into ../libs/
# Link all 3 to libtoxcore.so if you have only libtoxcore.so

View File

@ -3,3 +3,5 @@
# and you need to link your libtoxcore.so and libtoxav.so # and you need to link your libtoxcore.so and libtoxav.so
# and libtoxencryptsave.so into ../libs/ # and libtoxencryptsave.so into ../libs/
# Link all 3 to libtoxcore.so if you have only libtoxcore.so # Link all 3 to libtoxcore.so if you have only libtoxcore.so
__version__ = "1.0.0"

View File

@ -53,7 +53,7 @@ try:
except ImportError: except ImportError:
pycurl = None pycurl = None
from pyannotate_runtime import collect_types # from pyannotate_runtime import collect_types
try: try:
import coloredlogs import coloredlogs
@ -112,7 +112,7 @@ else:
ADDR_SIZE = 38 * 2 ADDR_SIZE = 38 * 2
CLIENT_ID_SIZE = 32 * 2 CLIENT_ID_SIZE = 32 * 2
THRESHOLD = 35 # >25 THRESHOLD = 60 # >25
iN = 6 iN = 6
global oTOX_OPTIONS global oTOX_OPTIONS
@ -264,9 +264,6 @@ def prepare(self):
alice.callback_self_connection_status(alices_on_self_connection_status) alice.callback_self_connection_status(alices_on_self_connection_status)
# only bob logs trace_enabled # only bob logs trace_enabled
if oTOX_OARGS.trace_enabled:
LOG.warning(f"oTOX_OARGS.trace_enabled={oTOX_OARGS.trace_enabled}")
oTOX_OARGS.trace_enabled = False
if oTOX_OARGS.trace_enabled: if oTOX_OARGS.trace_enabled:
LOG.info(f"toxcore trace_enabled") LOG.info(f"toxcore trace_enabled")
ts.vAddLoggerCallback(opts) ts.vAddLoggerCallback(opts)
@ -570,7 +567,7 @@ class ToxSuite(unittest.TestCase):
self.loop(100) self.loop(100)
i += 1 i += 1
else: else:
LOG.warning(f"wait_otox_attrs i >= {THRESHOLD} results={[getattr(obj, attr) for attr in attrs]}") LOG.warning(f"wait_otox_attrs i >= {THRESHOLD} attrs={attrs} results={[getattr(obj, attr) for attr in attrs]}")
return all([getattr(obj, attr) for attr in attrs]) return all([getattr(obj, attr) for attr in attrs])
@ -693,7 +690,7 @@ class ToxSuite(unittest.TestCase):
assert inum >= 0, f"bob_add_alice_as_friend !>= 0 {inum}" assert inum >= 0, f"bob_add_alice_as_friend !>= 0 {inum}"
self.alice.callback_friend_request(alices_on_friend_request) self.alice.callback_friend_request(alices_on_friend_request)
if not self.wait_otox_attrs(self.bob, [sSlot]): if not self.wait_otox_attrs(self.bob, [sSlot]):
LOG_WARN(f"bob_add_alice_as_friend NO {sSlot}") LOG_WARN(f"bob_add_alice_as_friend NO setting {sSlot}")
# return False # return False
self.baid = self.bob.friend_by_public_key(self.alice._address) self.baid = self.bob.friend_by_public_key(self.alice._address)
assert self.baid >= 0, self.baid assert self.baid >= 0, self.baid
@ -1106,6 +1103,7 @@ class ToxSuite(unittest.TestCase):
LOG.warning(f"bootstrap_local NOT CONNECTED iStatus={iStatus}") LOG.warning(f"bootstrap_local NOT CONNECTED iStatus={iStatus}")
return False return False
@unittest.skipIf(os.geteuid() != 0, 'must be root')
def test_bootstrap_iNmapInfo(self) -> None: # works def test_bootstrap_iNmapInfo(self) -> None: # works
# if os.environ['USER'] != 'root': # if os.environ['USER'] != 'root':
# return # return
@ -1295,6 +1293,9 @@ class ToxSuite(unittest.TestCase):
self.alice.friend_delete(self.abid) self.alice.friend_delete(self.abid)
assert len(self.alice.self_get_friend_list()) == 0 assert len(self.alice.self_get_friend_list()) == 0
def test_loop_until_connected(self) -> None: # works
assert self.loop_until_connected()
def test_bob_add_alice_as_friend_and_status(self) -> None: def test_bob_add_alice_as_friend_and_status(self) -> None:
""" """
t:friend_delete t:friend_delete
@ -1313,9 +1314,6 @@ class ToxSuite(unittest.TestCase):
if hasattr(self, 'abid') and self.abid >= 0: if hasattr(self, 'abid') and self.abid >= 0:
self.alice.friend_delete(self.abid) self.alice.friend_delete(self.abid)
def test_loop_until_connected(self) -> None: # works
assert self.loop_until_connected()
def test_bob_assert_connection_status(self) -> None: # works def test_bob_assert_connection_status(self) -> None: # works
if self.bob.self_get_connection_status() == TOX_CONNECTION['NONE']: if self.bob.self_get_connection_status() == TOX_CONNECTION['NONE']:
AssertionError("ERROR: NOT CONNECTED " \ AssertionError("ERROR: NOT CONNECTED " \

View File

@ -447,4 +447,10 @@ def main(lArgs=None) -> int:
return iMain(oArgs) return iMain(oArgs)
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main(sys.argv[1:])) try:
i = main(sys.argv[1:])
except KeyboardInterrupt as e:
i = 0
except Exception as e:
i = 1
sys.exit(i)