projects
/
plugin.video.netflix.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
864a936
)
feat(service): Dynamic port allocation
author
Sebastian Golasch
<public@asciidisco.com>
Sat, 4 Feb 2017 14:38:10 +0000
(15:38 +0100)
committer
Sebastian Golasch
<public@asciidisco.com>
Sat, 4 Feb 2017 14:38:10 +0000
(15:38 +0100)
service.py
patch
|
blob
|
history
diff --git
a/service.py
b/service.py
index 8600979b65e1d5b78324cf9f1afbb195e49e2c94..2af981351995a7db48d9769a63274cdd21591fea 100644
(file)
--- a/
service.py
+++ b/
service.py
@@
-1,10
+1,22
@@
import threading
import SocketServer
import xbmc
import threading
import SocketServer
import xbmc
+import xbmcaddon
+import socket
from resources.lib.common import log
from resources.lib.MSLHttpRequestHandler import MSLHttpRequestHandler
from resources.lib.common import log
from resources.lib.MSLHttpRequestHandler import MSLHttpRequestHandler
-PORT = 8000
+def select_unused_port():
+ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+ s.bind(('localhost', 0))
+ addr, port = s.getsockname()
+ s.close()
+ return port
+
+addon = xbmcaddon.Addon()
+PORT = select_unused_port()
+addon.setSetting('msl_service_port', str(PORT))
+log("Picked Port: " + str(PORT))
Handler = MSLHttpRequestHandler
SocketServer.TCPServer.allow_reuse_address = True
server = SocketServer.TCPServer(('127.0.0.1', PORT), Handler)
Handler = MSLHttpRequestHandler
SocketServer.TCPServer.allow_reuse_address = True
server = SocketServer.TCPServer(('127.0.0.1', PORT), Handler)