added generation exception while creating tox_options instance
This commit is contained in:
parent
0269b81319
commit
6754b2bbbf
2 changed files with 19 additions and 4 deletions
|
@ -4,7 +4,7 @@ from mainscreen import MainWindow
|
|||
from profile import Profile
|
||||
import sys
|
||||
from PySide import QtCore, QtGui
|
||||
from tox import Tox
|
||||
from tox import Tox, tox_factory
|
||||
from bootstrap import node_generator
|
||||
|
||||
|
||||
|
@ -76,7 +76,7 @@ def main():
|
|||
data = Profile.open_profile(path, name)
|
||||
ms = MainWindow()
|
||||
# creating tox instance
|
||||
tox = Tox(data, settings)
|
||||
tox = tox_factory(data, settings)
|
||||
# bootstrap
|
||||
for data in node_generator():
|
||||
tox.bootstrap(*data)
|
||||
|
|
17
src/tox.py
17
src/tox.py
|
@ -108,7 +108,7 @@ class Tox(object):
|
|||
|
||||
Objects returned from this function must be freed using the tox_options_free function.
|
||||
|
||||
:return: A pointer to new ToxOptions object with default options or NULL on failure.
|
||||
:return: A pointer to new ToxOptions object with default options or raise MemoryError.
|
||||
"""
|
||||
tox_err_options_new = c_int()
|
||||
Tox.libtoxcore.tox_options_new.restype = POINTER(ToxOptions)
|
||||
|
@ -1003,6 +1003,21 @@ class Tox(object):
|
|||
Tox.libtoxcore.tox_kill(self._tox_pointer)
|
||||
|
||||
|
||||
def tox_factory(data, settings):
|
||||
tox_options = Tox.options_new()
|
||||
tox_options.contents.udp_enabled = settings['udp_enabled']
|
||||
tox_options.contents.proxy_type = settings['proxy_type']
|
||||
tox_options.contents.proxy_host = settings['proxy_host']
|
||||
tox_options.contents.proxy_port = settings['proxy_port']
|
||||
tox_options.contents.start_port = settings['start_port']
|
||||
tox_options.contents.end_port = settings['end_port']
|
||||
tox_options.contents.tcp_port = settings['tcp_port']
|
||||
tox_options.contents.savedata_type = TOX_SAVEDATA_TYPE['TOX_SAVEDATA_TYPE_TOX_SAVE']
|
||||
tox_options.contents.savedata_data = c_char_p(data)
|
||||
tox_options.contents.savedata_length = len(data)
|
||||
return Tox(tox_options)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
options = Tox.options_new()
|
||||
|
||||
|
|
Loading…
Reference in a new issue