setuptools: restructure scripts to use entry_points in setup.py
This commit is contained in:
parent
285d6019ea
commit
091402a4cc
2
.gitignore
vendored
2
.gitignore
vendored
@ -3,7 +3,7 @@
|
|||||||
*.exe
|
*.exe
|
||||||
venv
|
venv
|
||||||
|
|
||||||
/SyncPlay.egg-info
|
/*.egg-info
|
||||||
/build
|
/build
|
||||||
/cert
|
/cert
|
||||||
/dist
|
/dist
|
||||||
|
|||||||
14
setup.py
14
setup.py
@ -28,11 +28,19 @@ setuptools.setup(
|
|||||||
long_description_content_type="text/markdown",
|
long_description_content_type="text/markdown",
|
||||||
url="https://www.syncplay.pl",
|
url="https://www.syncplay.pl",
|
||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
install_requires=["twisted", "pyside2", "requests", 'zope.inteface; platform_system=="Windows"',
|
install_requires=["twisted", "pyside2", 'zope.inteface; platform_system=="Windows"',
|
||||||
'pypiwin32; platform_system=="Windows"', 'appnope; platform_system=="Darwin"'
|
'pypiwin32; platform_system=="Windows"', 'appnope; platform_system=="Darwin"',
|
||||||
|
'requests; platform_system=="Darwin"'
|
||||||
],
|
],
|
||||||
python_requires=">=3.4",
|
python_requires=">=3.4",
|
||||||
scripts=['syncplayClient.py', 'syncplayServer.py'],
|
entry_points={
|
||||||
|
'console_scripts': [
|
||||||
|
'syncplay-server = syncplay.ep_server:main',
|
||||||
|
],
|
||||||
|
'gui_scripts': [
|
||||||
|
'syncplay = syncplay.ep_client:main',
|
||||||
|
]
|
||||||
|
},
|
||||||
include_package_data=True,
|
include_package_data=True,
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Development Status :: 5 - Production/Stable",
|
"Development Status :: 5 - Production/Stable",
|
||||||
|
|||||||
11
syncplay/ep_client.py
Normal file
11
syncplay/ep_client.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
import sys
|
||||||
|
|
||||||
|
from syncplay.clientManager import SyncplayClientManager
|
||||||
|
from syncplay.utils import blackholeStdoutForFrozenWindow
|
||||||
|
|
||||||
|
def main():
|
||||||
|
blackholeStdoutForFrozenWindow()
|
||||||
|
SyncplayClientManager().run()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
58
syncplay/ep_server.py
Normal file
58
syncplay/ep_server.py
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
import socket
|
||||||
|
import sys
|
||||||
|
|
||||||
|
from twisted.internet import reactor
|
||||||
|
from twisted.internet.endpoints import TCP4ServerEndpoint, TCP6ServerEndpoint
|
||||||
|
from twisted.internet.error import CannotListenError
|
||||||
|
|
||||||
|
from syncplay.server import SyncFactory, ConfigurationGetter
|
||||||
|
|
||||||
|
class ServerStatus: pass
|
||||||
|
|
||||||
|
def isListening6(f):
|
||||||
|
ServerStatus.listening6 = True
|
||||||
|
|
||||||
|
def isListening4(f):
|
||||||
|
ServerStatus.listening4 = True
|
||||||
|
|
||||||
|
def failed6(f):
|
||||||
|
ServerStatus.listening6 = False
|
||||||
|
print(f.value)
|
||||||
|
print("IPv6 listening failed.")
|
||||||
|
|
||||||
|
def failed4(f):
|
||||||
|
ServerStatus.listening4 = False
|
||||||
|
if f.type is CannotListenError and ServerStatus.listening6:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
print(f.value)
|
||||||
|
print("IPv4 listening failed.")
|
||||||
|
|
||||||
|
def main():
|
||||||
|
argsGetter = ConfigurationGetter()
|
||||||
|
args = argsGetter.getConfiguration()
|
||||||
|
factory = SyncFactory(
|
||||||
|
args.port,
|
||||||
|
args.password,
|
||||||
|
args.motd_file,
|
||||||
|
args.isolate_rooms,
|
||||||
|
args.salt,
|
||||||
|
args.disable_ready,
|
||||||
|
args.disable_chat,
|
||||||
|
args.max_chat_message_length,
|
||||||
|
args.max_username_length,
|
||||||
|
args.stats_db_file,
|
||||||
|
args.tls
|
||||||
|
)
|
||||||
|
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port))
|
||||||
|
endpoint6.listen(factory).addCallbacks(isListening6, failed6)
|
||||||
|
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port))
|
||||||
|
endpoint4.listen(factory).addCallbacks(isListening4, failed4)
|
||||||
|
if ServerStatus.listening6 or ServerStatus.listening4:
|
||||||
|
reactor.run()
|
||||||
|
else:
|
||||||
|
print("Unable to listen using either IPv4 and IPv6 protocols. Quitting the server now.")
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
@ -11,9 +11,7 @@ except AttributeError:
|
|||||||
import warnings
|
import warnings
|
||||||
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
||||||
|
|
||||||
from syncplay.clientManager import SyncplayClientManager
|
from syncplay import ep_client
|
||||||
from syncplay.utils import blackholeStdoutForFrozenWindow
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
blackholeStdoutForFrozenWindow()
|
ep_client.main()
|
||||||
SyncplayClientManager().run()
|
|
||||||
@ -1,7 +1,6 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
#coding:utf8
|
#coding:utf8
|
||||||
|
|
||||||
import socket
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
# libpath
|
# libpath
|
||||||
@ -13,56 +12,7 @@ except AttributeError:
|
|||||||
import warnings
|
import warnings
|
||||||
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
warnings.warn("You must run Syncplay with Python 3.4 or newer!")
|
||||||
|
|
||||||
from twisted.internet import reactor
|
from syncplay import ep_server
|
||||||
from twisted.internet.endpoints import TCP4ServerEndpoint, TCP6ServerEndpoint
|
|
||||||
from twisted.internet.error import CannotListenError
|
|
||||||
|
|
||||||
from syncplay.server import SyncFactory, ConfigurationGetter
|
|
||||||
|
|
||||||
class ServerStatus: pass
|
|
||||||
|
|
||||||
def isListening6(f):
|
|
||||||
ServerStatus.listening6 = True
|
|
||||||
|
|
||||||
def isListening4(f):
|
|
||||||
ServerStatus.listening4 = True
|
|
||||||
|
|
||||||
def failed6(f):
|
|
||||||
ServerStatus.listening6 = False
|
|
||||||
print(f.value)
|
|
||||||
print("IPv6 listening failed.")
|
|
||||||
|
|
||||||
def failed4(f):
|
|
||||||
ServerStatus.listening4 = False
|
|
||||||
if f.type is CannotListenError and ServerStatus.listening6:
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
print(f.value)
|
|
||||||
print("IPv4 listening failed.")
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
argsGetter = ConfigurationGetter()
|
ep_server.main()
|
||||||
args = argsGetter.getConfiguration()
|
|
||||||
factory = SyncFactory(
|
|
||||||
args.port,
|
|
||||||
args.password,
|
|
||||||
args.motd_file,
|
|
||||||
args.isolate_rooms,
|
|
||||||
args.salt,
|
|
||||||
args.disable_ready,
|
|
||||||
args.disable_chat,
|
|
||||||
args.max_chat_message_length,
|
|
||||||
args.max_username_length,
|
|
||||||
args.stats_db_file,
|
|
||||||
args.tls
|
|
||||||
)
|
|
||||||
endpoint6 = TCP6ServerEndpoint(reactor, int(args.port))
|
|
||||||
endpoint6.listen(factory).addCallbacks(isListening6, failed6)
|
|
||||||
endpoint4 = TCP4ServerEndpoint(reactor, int(args.port))
|
|
||||||
endpoint4.listen(factory).addCallbacks(isListening4, failed4)
|
|
||||||
if ServerStatus.listening6 or ServerStatus.listening4:
|
|
||||||
reactor.run()
|
|
||||||
else:
|
|
||||||
print("Unable to listen using either IPv4 and IPv6 protocols. Quitting the server now.")
|
|
||||||
sys.exit()
|
|
||||||
Loading…
x
Reference in New Issue
Block a user