Skip to content

Commit

Permalink
Changed: Moved the listening interface and port to object constructor.
Browse files Browse the repository at this point in the history
  • Loading branch information
basrieter committed Oct 12, 2023
1 parent dcfdb9b commit c2b10e9
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions resources/lib/webdialogue.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,26 @@


class WebDialogue(object):
def __init__(self):
def __init__(self, bind_interface="", port=3145):
""" Initializes a WebDialogue object.
:param str bind_interface: The interface to bind the http server to.
:param int port: The TCP port number to bind to.
"""

self.bind_interface = bind_interface
self.port = port
self.__value = None
return

# noinspection PyCompatibility
def input(self, heading, text, time_out=30, bind_interface="", port=3145):
def input(self, heading, text, time_out=30):
""" Show an input dialog.
:param str|int heading: Dialog heading.
:param str|int text: Default value.
:param int time_out: Seconds to autoclose dialog (default=do not autoclose).
:param str bind_interface: The interface to bind the http server to.
:param int port: The TCP port number to bind to.
:return: Returns the entered data as a string. Returns an empty string if dialog was canceled.
:rtype: str
Expand All @@ -37,7 +44,7 @@ def input(self, heading, text, time_out=30, bind_interface="", port=3145):
if isinstance(text, int):
text = LanguageHelper.get_localized_string(text)

server_address = (bind_interface, port)
server_address = (self.bind_interface, self.port)

try:
# noinspection PyUnresolvedReferences
Expand Down Expand Up @@ -250,7 +257,7 @@ def force_stop(self):
th.daemon = True
th.start()

Logger.info("RetroServer: Serving on %s", port)
Logger.info("RetroServer: Serving on %s", self.port)

d = xbmcgui.DialogProgress()
# TODO: Translate
Expand Down Expand Up @@ -293,7 +300,9 @@ def force_stop(self):
httpd.force_stop()
if th.is_alive():
th.join()
th = None

# noinspection PyUnusedLocal
th = None # NOSONAR
return httpd.value, httpd.cancelled
except:
Logger.critical("RetroServer: Error with WebDialogue", exc_info=True)
Expand Down

0 comments on commit c2b10e9

Please sign in to comment.