From 281d8023fd0e06e346f0e2c9a3e61a12ffeeac02 Mon Sep 17 00:00:00 2001 From: Alberto Sottile Date: Sat, 13 Apr 2019 15:39:55 +0200 Subject: [PATCH] Edit folder structure and add setuptools support (#231) * setuptools: Initial commit * setuptools: remove the .py extension from installed commands * setuptools: restructure scripts to use entry_points in setup.py * setuptools: include TLS dependencies and remove unneeded code * setuptools: change resources path * AppVeyor: upgrade Python and py2exe, embed TLS dependencies * buildpy2exe: fix path for resources * AppVeyor: upgrade py2exe and PySide2 * Amend setup.py according to the suggestions from PR #230 * Insert TLS dependencies in requirements * AppVeyor: fix build for master * AppVeyor: revert to PySide2 5.12.0 --- .appveyor.yml | 12 ++-- .gitignore | 2 +- .travis.yml | 2 +- GNUmakefile | 18 ++--- MANIFEST.in | 6 ++ appdmg.py | 4 +- buildPy2app.py | 6 +- buildPy2exe.py | 29 ++++---- requirements.txt | 3 +- requirements_tls.txt | 2 - setup.py | 64 ++++++++++++++++++ syncplay/ep_client.py | 11 +++ syncplay/ep_server.py | 58 ++++++++++++++++ {resources => syncplay/resources}/accept.png | Bin .../resources}/application_get.png | Bin .../resources}/arrow_refresh.png | Bin .../resources}/arrow_switch.png | Bin .../resources}/arrow_undo.png | Bin .../resources}/bullet_right_grey.png | Bin .../resources}/chevrons_right.png | Bin .../resources}/clock_go.png | Bin {resources => syncplay/resources}/cog.png | Bin .../resources}/cog_delete.png | Bin .../resources}/comments.png | Bin .../resources}/control_pause_blue.png | Bin .../resources}/control_play_blue.png | Bin {resources => syncplay/resources}/cross.png | Bin .../resources}/cross_checkbox.png | Bin {resources => syncplay/resources}/delete.png | Bin {resources => syncplay/resources}/door_in.png | Bin .../resources}/email_go.png | Bin .../resources}/empty_checkbox.png | Bin {resources => syncplay/resources}/error.png | Bin {resources => syncplay/resources}/eye.png | Bin .../resources}/film_add.png | Bin .../resources}/film_edit.png | Bin .../resources}/film_folder_edit.png | Bin {resources => syncplay/resources}/film_go.png | Bin .../resources}/film_link.png | Bin .../resources}/folder_explore.png | Bin .../resources}/folder_film.png | Bin {resources => syncplay/resources}/help.png | Bin .../hicolor/128x128/apps/syncplay.png | Bin .../hicolor/16x16/apps/syncplay.png | Bin .../hicolor/24x24/apps/syncplay.png | Bin .../hicolor/256x256/apps/syncplay.png | Bin .../hicolor/32x32/apps/syncplay.png | Bin .../hicolor/48x48/apps/syncplay.png | Bin .../hicolor/64x64/apps/syncplay.png | Bin .../hicolor/96x96/apps/syncplay.png | Bin {resources => syncplay/resources}/house.png | Bin {resources => syncplay/resources}/icon.icns | Bin {resources => syncplay/resources}/icon.ico | Bin {resources => syncplay/resources}/key_go.png | Bin {resources => syncplay/resources}/license.rtf | 0 {resources => syncplay/resources}/lock.png | Bin .../resources}/lock_green.png | Bin .../resources}/lock_green_dialog.png | Bin .../resources}/lock_open.png | Bin .../resources}/lua/intf/syncplay.lua | 0 .../resources}/macOS_dmg_bkg.tiff | Bin .../resources}/macOS_readme.pdf | Bin .../resources}/man/changelog.md | 0 {resources => syncplay/resources}/mpc-be.png | Bin {resources => syncplay/resources}/mpc-hc.png | Bin .../resources}/mpc-hc64.png | Bin {resources => syncplay/resources}/mplayer.png | Bin {resources => syncplay/resources}/mpv.png | Bin .../resources}/page_white_key.png | Bin .../resources}/shield_add.png | Bin .../resources}/shield_edit.png | Bin {resources => syncplay/resources}/spinner.mng | Bin .../resources}/syncplay-server.desktop | 0 .../resources}/syncplay.desktop | 0 .../resources}/syncplay.png | Bin .../resources}/syncplayintf.lua | 0 .../resources}/table_refresh.png | Bin .../resources}/third-party-notices.rtf | 0 {resources => syncplay/resources}/tick.png | Bin .../resources}/tick_checkbox.png | Bin .../resources}/timeline_marker.png | Bin .../resources}/user_comment.png | Bin .../resources}/user_key.png | Bin {resources => syncplay/resources}/vlc.png | Bin .../resources}/world_add.png | Bin .../resources}/world_explore.png | Bin .../resources}/world_go.png | Bin syncplay/utils.py | 4 +- syncplayClient.py | 6 +- syncplayServer.py | 54 +-------------- 90 files changed, 185 insertions(+), 96 deletions(-) create mode 100644 MANIFEST.in mode change 100644 => 100755 buildPy2exe.py delete mode 100644 requirements_tls.txt create mode 100644 setup.py create mode 100644 syncplay/ep_client.py create mode 100644 syncplay/ep_server.py rename {resources => syncplay/resources}/accept.png (100%) rename {resources => syncplay/resources}/application_get.png (100%) rename {resources => syncplay/resources}/arrow_refresh.png (100%) rename {resources => syncplay/resources}/arrow_switch.png (100%) rename {resources => syncplay/resources}/arrow_undo.png (100%) rename {resources => syncplay/resources}/bullet_right_grey.png (100%) rename {resources => syncplay/resources}/chevrons_right.png (100%) rename {resources => syncplay/resources}/clock_go.png (100%) rename {resources => syncplay/resources}/cog.png (100%) rename {resources => syncplay/resources}/cog_delete.png (100%) rename {resources => syncplay/resources}/comments.png (100%) rename {resources => syncplay/resources}/control_pause_blue.png (100%) rename {resources => syncplay/resources}/control_play_blue.png (100%) rename {resources => syncplay/resources}/cross.png (100%) rename {resources => syncplay/resources}/cross_checkbox.png (100%) rename {resources => syncplay/resources}/delete.png (100%) rename {resources => syncplay/resources}/door_in.png (100%) rename {resources => syncplay/resources}/email_go.png (100%) rename {resources => syncplay/resources}/empty_checkbox.png (100%) rename {resources => syncplay/resources}/error.png (100%) rename {resources => syncplay/resources}/eye.png (100%) rename {resources => syncplay/resources}/film_add.png (100%) rename {resources => syncplay/resources}/film_edit.png (100%) rename {resources => syncplay/resources}/film_folder_edit.png (100%) rename {resources => syncplay/resources}/film_go.png (100%) rename {resources => syncplay/resources}/film_link.png (100%) rename {resources => syncplay/resources}/folder_explore.png (100%) rename {resources => syncplay/resources}/folder_film.png (100%) rename {resources => syncplay/resources}/help.png (100%) rename {resources => syncplay/resources}/hicolor/128x128/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/16x16/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/24x24/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/256x256/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/32x32/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/48x48/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/64x64/apps/syncplay.png (100%) rename {resources => syncplay/resources}/hicolor/96x96/apps/syncplay.png (100%) rename {resources => syncplay/resources}/house.png (100%) rename {resources => syncplay/resources}/icon.icns (100%) rename {resources => syncplay/resources}/icon.ico (100%) rename {resources => syncplay/resources}/key_go.png (100%) rename {resources => syncplay/resources}/license.rtf (100%) rename {resources => syncplay/resources}/lock.png (100%) rename {resources => syncplay/resources}/lock_green.png (100%) rename {resources => syncplay/resources}/lock_green_dialog.png (100%) rename {resources => syncplay/resources}/lock_open.png (100%) rename {resources => syncplay/resources}/lua/intf/syncplay.lua (100%) rename {resources => syncplay/resources}/macOS_dmg_bkg.tiff (100%) rename {resources => syncplay/resources}/macOS_readme.pdf (100%) rename {resources => syncplay/resources}/man/changelog.md (100%) rename {resources => syncplay/resources}/mpc-be.png (100%) rename {resources => syncplay/resources}/mpc-hc.png (100%) rename {resources => syncplay/resources}/mpc-hc64.png (100%) rename {resources => syncplay/resources}/mplayer.png (100%) rename {resources => syncplay/resources}/mpv.png (100%) rename {resources => syncplay/resources}/page_white_key.png (100%) rename {resources => syncplay/resources}/shield_add.png (100%) rename {resources => syncplay/resources}/shield_edit.png (100%) rename {resources => syncplay/resources}/spinner.mng (100%) rename {resources => syncplay/resources}/syncplay-server.desktop (100%) rename {resources => syncplay/resources}/syncplay.desktop (100%) rename {resources => syncplay/resources}/syncplay.png (100%) rename {resources => syncplay/resources}/syncplayintf.lua (100%) rename {resources => syncplay/resources}/table_refresh.png (100%) rename {resources => syncplay/resources}/third-party-notices.rtf (100%) rename {resources => syncplay/resources}/tick.png (100%) rename {resources => syncplay/resources}/tick_checkbox.png (100%) rename {resources => syncplay/resources}/timeline_marker.png (100%) rename {resources => syncplay/resources}/user_comment.png (100%) rename {resources => syncplay/resources}/user_key.png (100%) rename {resources => syncplay/resources}/vlc.png (100%) rename {resources => syncplay/resources}/world_add.png (100%) rename {resources => syncplay/resources}/world_explore.png (100%) rename {resources => syncplay/resources}/world_go.png (100%) diff --git a/.appveyor.yml b/.appveyor.yml index c746a4f..3611be7 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -4,8 +4,8 @@ branches: environment: MINICONDA: "C:\\Miniconda" - PYTHON: "C:\\Python35" - PYTHON_VERSION: 3.5 + PYTHON: "C:\\Python36" + PYTHON_VERSION: 3.6 PYTHON_ARCH: 32 platform: x86 @@ -19,12 +19,12 @@ init: - python --version - python -m pip install -U pip setuptools wheel - pip install -U pypiwin32==223 - - pip install twisted + - pip install twisted[tls] certifi - pip install zope.interface - type nul > %PYTHON%\lib\site-packages\zope\__init__.py - - curl -L https://bintray.com/alby128/Syncplay/download_file?file_path=py2exe-0.9.2.2-py33.py34.py35-none-any.whl -o py2exe-0.9.2.2-py33.py34.py35-none-any.whl - - pip install py2exe-0.9.2.2-py33.py34.py35-none-any.whl - - del py2exe-0.9.2.2-py33.py34.py35-none-any.whl + - curl -L https://bintray.com/alby128/py2exe/download_file?file_path=py2exe-0.9.3.0-cp36-none-win32.whl -o py2exe-0.9.3.0-cp36-none-win32.whl + - pip install py2exe-0.9.3.0-cp36-none-win32.whl + - del py2exe-0.9.3.0-cp36-none-win32.whl - pip install shiboken2==5.12.0 PySide2==5.12.0 - pip freeze diff --git a/.gitignore b/.gitignore index 95fe6f5..298a39b 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ *.exe venv -/SyncPlay.egg-info +/*.egg-info /build /cert /dist diff --git a/.travis.yml b/.travis.yml index fd8ec48..cf4d283 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,7 +28,7 @@ install: before_deploy: - pip3 install dmgbuild - mkdir dist_dmg -- mv resources/macOS_readme.pdf resources/.macOS_readme.pdf +- mv syncplay/resources/macOS_readme.pdf syncplay/resources/.macOS_readme.pdf - export VER="$(cat syncplay/__init__.py | awk '/version/ {gsub("\047", "", $3); print $NF}')" - dmgbuild -s appdmg.py "Syncplay" dist_dmg/Syncplay_${VER}.dmg - python3 bintray_version.py diff --git a/GNUmakefile b/GNUmakefile index 6936f70..d68b634 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -35,18 +35,18 @@ endif SHARE_PATH = ${DESTDIR}${PREFIX}/share common: - -mkdir -p $(LIB_PATH)/syncplay/resources/lua/intf + -mkdir -p $(LIB_PATH)/syncplay/syncplay/resources/lua/intf -mkdir -p $(APP_SHORTCUT_PATH) -mkdir -p $(SHARE_PATH)/app-install/icons -mkdir -p $(SHARE_PATH)/pixmaps/ cp -r syncplay $(LIB_PATH)/syncplay/ chmod 755 $(LIB_PATH)/syncplay/ - cp -r resources/hicolor $(SHARE_PATH)/icons/ - cp -r resources/*.png $(LIB_PATH)/syncplay/resources/ - cp -r resources/*.lua $(LIB_PATH)/syncplay/resources/ - cp -r resources/lua/intf/*.lua $(LIB_PATH)/syncplay/resources/lua/intf/ - cp resources/hicolor/48x48/apps/syncplay.png $(SHARE_PATH)/app-install/icons/ - cp resources/hicolor/48x48/apps/syncplay.png $(SHARE_PATH)/pixmaps/ + cp -r syncplay/resources/hicolor $(SHARE_PATH)/icons/ + cp -r syncplay/resources/*.png $(LIB_PATH)/syncplay/syncplay/resources/ + cp -r syncplay/resources/*.lua $(LIB_PATH)/syncplay/syncplay/resources/ + cp -r syncplay/resources/lua/intf/*.lua $(LIB_PATH)/syncplay/syncplay/resources/lua/intf/ + cp syncplay/resources/hicolor/48x48/apps/syncplay.png $(SHARE_PATH)/app-install/icons/ + cp syncplay/resources/hicolor/48x48/apps/syncplay.png $(SHARE_PATH)/pixmaps/ u-common: -rm -rf $(LIB_PATH)/syncplay @@ -60,7 +60,7 @@ client: sed -i -e '/# libpath/ a\import site\nsite.addsitedir\("${PREFIX}/lib/syncplay"\)' $(BIN_PATH)/syncplay chmod 755 $(BIN_PATH)/syncplay cp syncplayClient.py $(LIB_PATH)/syncplay/ - cp resources/syncplay.desktop $(APP_SHORTCUT_PATH)/ + cp syncplay/resources/syncplay.desktop $(APP_SHORTCUT_PATH)/ ifeq ($(SINGLE_USER),false) chmod 755 $(APP_SHORTCUT_PATH)/syncplay.desktop @@ -79,7 +79,7 @@ server: sed -i -e '/# libpath/ a\import site\nsite.addsitedir\("${PREFIX}/lib/syncplay"\)' $(BIN_PATH)/syncplay-server chmod 755 $(BIN_PATH)/syncplay-server cp syncplayServer.py $(LIB_PATH)/syncplay/ - cp resources/syncplay-server.desktop $(APP_SHORTCUT_PATH)/ + cp syncplay/resources/syncplay-server.desktop $(APP_SHORTCUT_PATH)/ ifeq ($(SINGLE_USER),false) chmod 755 $(APP_SHORTCUT_PATH)/syncplay-server.desktop diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..f3809a6 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,6 @@ +include LICENSE +include syncplay/resources/*.png +include syncplay/resources/*.mng +include syncplay/resources/*.lua +include syncplay/resources/*.rtf +include syncplay/resources/lua/intf/*.lua \ No newline at end of file diff --git a/appdmg.py b/appdmg.py index 8c23084..2c08dd9 100755 --- a/appdmg.py +++ b/appdmg.py @@ -31,7 +31,7 @@ size = defines.get('size', None) # Files to include files = [ application, - 'resources/.macOS_readme.pdf' + 'syncplay/resources/.macOS_readme.pdf' ] # Symlinks to create @@ -78,7 +78,7 @@ icon_locations = { # # Other color components may be expressed either in the range 0 to 1, or # as percentages (e.g. 60% is equivalent to 0.6). -background = 'resources/macOS_dmg_bkg.tiff' +background = 'syncplay/resources/macOS_dmg_bkg.tiff' show_status_bar = False show_tab_view = False diff --git a/buildPy2app.py b/buildPy2app.py index 4e921c9..68e6466 100755 --- a/buildPy2app.py +++ b/buildPy2app.py @@ -11,11 +11,11 @@ import syncplay APP = ['syncplayClient.py'] DATA_FILES = [ - ('resources', glob('resources/*.png') + glob('resources/*.rtf') + glob('resources/*.lua')), - ('resources/lua/intf', glob('resources/lua/intf/*.lua')) + ('resources', glob('syncplay/resources/*.png') + glob('syncplay/resources/*.rtf') + glob('syncplay/resources/*.lua')), + ('resources/lua/intf', glob('syncplay/resources/lua/intf/*.lua')) ] OPTIONS = { - 'iconfile': 'resources/icon.icns', + 'iconfile': 'syncplay/resources/icon.icns', 'extra_scripts': 'syncplayServer.py', 'includes': {'PySide2.QtCore', 'PySide2.QtUiTools', 'PySide2.QtGui', 'PySide2.QtWidgets', 'certifi', 'cffi'}, 'excludes': {'PySide', 'PySide.QtCore', 'PySide.QtUiTools', 'PySide.QtGui'}, diff --git a/buildPy2exe.py b/buildPy2exe.py old mode 100644 new mode 100755 index de662c3..d9a60d7 --- a/buildPy2exe.py +++ b/buildPy2exe.py @@ -71,7 +71,7 @@ NSIS_SCRIPT_TEMPLATE = r""" RequestExecutionLevel admin ManifestDPIAware false XPStyle on - Icon resources\icon.ico ;Change DIR + Icon syncplay\resources\icon.ico ;Change DIR SetCompressor /SOLID lzma VIProductVersion "$version.0" @@ -157,7 +157,7 @@ NSIS_SCRIPT_TEMPLATE = r""" LangString ^ClickInstall $${LANG_GERMAN} " " PageEx license - LicenseData resources\license.rtf + LicenseData syncplay\resources\license.rtf PageExEnd Page custom DirectoryCustom DirectoryCustomLeave Page instFiles @@ -690,15 +690,18 @@ guiIcons = [ 'resources/email_go.png', 'resources/world_add.png', 'resources/film_add.png', 'resources/delete.png', 'resources/spinner.mng' ] + +guiIcons = ['syncplay/' + s for s in guiIcons] + resources = [ - "resources/icon.ico", - "resources/syncplay.png", - "resources/syncplayintf.lua", - "resources/license.rtf", - "resources/third-party-notices.rtf" + "syncplay/resources/icon.ico", + "syncplay/resources/syncplay.png", + "syncplay/resources/syncplayintf.lua", + "syncplay/resources/license.rtf", + "syncplay/resources/third-party-notices.rtf" ] resources.extend(guiIcons) -intf_resources = ["resources/lua/intf/syncplay.lua"] +intf_resources = ["syncplay/resources/lua/intf/syncplay.lua"] qt_plugins = ['platforms\\qwindows.dll', 'styles\\qwindowsvistastyle.dll'] @@ -714,7 +717,7 @@ info = dict( common_info, windows=[{ "script": "syncplayClient.py", - "icon_resources": [(1, "resources\\icon.ico")], + "icon_resources": [(1, "syncplay\\resources\\icon.ico")], 'dest_base': "Syncplay"}, ], console=['syncplayServer.py'], @@ -724,8 +727,8 @@ info = dict( options={ 'py2exe': { 'dist_dir': OUT_DIR, - 'packages': 'PySide2', - 'includes': 'twisted, sys, encodings, datetime, os, time, math, liburl, ast, unicodedata, _ssl, win32pipe, win32file', + 'packages': 'PySide2, cffi, OpenSSL, certifi', + 'includes': 'twisted, sys, encodings, datetime, os, time, math, urllib, ast, unicodedata, _ssl, win32pipe, win32file', 'excludes': 'venv, doctest, pdb, unittest, win32clipboard, win32pdh, win32security, win32trace, win32ui, winxpgui, win32process, Tkinter', 'dll_excludes': 'msvcr71.dll, MSVCP90.dll, POWRPROF.dll', 'optimize': 2, @@ -737,5 +740,5 @@ info = dict( cmdclass={"py2exe": build_installer}, ) -sys.argv.extend(['py2exe', '-p win32com ', '-i twisted.web.resource', '-p PySide2']) -setup(**info) +sys.argv.extend(['py2exe']) +setup(**info) \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 949df73..84f4305 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,5 @@ -twisted>=16.4.0 +certifi>=2018.11.29 +twisted[tls]>=16.4.0 appnope>=0.1.0; sys_platform == 'darwin' pypiwin32>=223; sys_platform == 'win32' zope.inteface>=4.4.0; sys_platform == 'win32' \ No newline at end of file diff --git a/requirements_tls.txt b/requirements_tls.txt deleted file mode 100644 index 5a7646a..0000000 --- a/requirements_tls.txt +++ /dev/null @@ -1,2 +0,0 @@ -certifi>=2018.11.29 -twisted[tls]>=16.4.0 \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..91b2602 --- /dev/null +++ b/setup.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python3 + +import distutils.command.install_scripts +import setuptools + +from syncplay import projectURL, version as syncplay_version + +def read(fname): + with open(fname, 'r') as f: + return f.read() + +installRequirements = read('requirements.txt').splitlines() +\ + read('requirements_gui.txt').splitlines() + +setuptools.setup( + name="syncplay", + version=syncplay_version, + author="Syncplay", + author_email="dev@syncplay.pl", + description=' '.join([ + 'Client/server to synchronize media playback', + 'on mpv/VLC/MPC-HC/MPC-BE on many computers' + ]), + long_description=read('README.md'), + long_description_content_type="text/markdown", + url=projectURL, + download_url=projectURL + 'download/', + packages=setuptools.find_packages(), + install_requires=installRequirements, + python_requires=">=3.4", + entry_points={ + 'console_scripts': [ + 'syncplay-server = syncplay.ep_server:main', + ], + 'gui_scripts': [ + 'syncplay = syncplay.ep_client:main', + ] + }, + include_package_data=True, + classifiers=[ + "Development Status :: 5 - Production/Stable", + "Environment :: MacOS X :: Cocoa", + "Environment :: Win32 (MS Windows)", + "Environment :: X11 Applications :: Qt", + "Framework :: Twisted", + "Intended Audience :: End Users/Desktop", + "License :: OSI Approved :: Apache Software License", + "Operating System :: MacOS :: MacOS X", + "Operating System :: Microsoft :: Windows", + "Operating System :: POSIX :: Linux", + "Natural Language :: English", + "Natural Language :: German", + "Natural Language :: Italian", + "Natural Language :: Russian", + "Natural Language :: Spanish", + "Programming Language :: Python :: 3", + "Programming Language :: Python :: 3.4", + "Programming Language :: Python :: 3.5", + "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", + "Topic :: Internet", + "Topic :: Multimedia :: Video" + ], +) \ No newline at end of file diff --git a/syncplay/ep_client.py b/syncplay/ep_client.py new file mode 100644 index 0000000..f93793b --- /dev/null +++ b/syncplay/ep_client.py @@ -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() \ No newline at end of file diff --git a/syncplay/ep_server.py b/syncplay/ep_server.py new file mode 100644 index 0000000..7bb899e --- /dev/null +++ b/syncplay/ep_server.py @@ -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() \ No newline at end of file diff --git a/resources/accept.png b/syncplay/resources/accept.png similarity index 100% rename from resources/accept.png rename to syncplay/resources/accept.png diff --git a/resources/application_get.png b/syncplay/resources/application_get.png similarity index 100% rename from resources/application_get.png rename to syncplay/resources/application_get.png diff --git a/resources/arrow_refresh.png b/syncplay/resources/arrow_refresh.png similarity index 100% rename from resources/arrow_refresh.png rename to syncplay/resources/arrow_refresh.png diff --git a/resources/arrow_switch.png b/syncplay/resources/arrow_switch.png similarity index 100% rename from resources/arrow_switch.png rename to syncplay/resources/arrow_switch.png diff --git a/resources/arrow_undo.png b/syncplay/resources/arrow_undo.png similarity index 100% rename from resources/arrow_undo.png rename to syncplay/resources/arrow_undo.png diff --git a/resources/bullet_right_grey.png b/syncplay/resources/bullet_right_grey.png similarity index 100% rename from resources/bullet_right_grey.png rename to syncplay/resources/bullet_right_grey.png diff --git a/resources/chevrons_right.png b/syncplay/resources/chevrons_right.png similarity index 100% rename from resources/chevrons_right.png rename to syncplay/resources/chevrons_right.png diff --git a/resources/clock_go.png b/syncplay/resources/clock_go.png similarity index 100% rename from resources/clock_go.png rename to syncplay/resources/clock_go.png diff --git a/resources/cog.png b/syncplay/resources/cog.png similarity index 100% rename from resources/cog.png rename to syncplay/resources/cog.png diff --git a/resources/cog_delete.png b/syncplay/resources/cog_delete.png similarity index 100% rename from resources/cog_delete.png rename to syncplay/resources/cog_delete.png diff --git a/resources/comments.png b/syncplay/resources/comments.png similarity index 100% rename from resources/comments.png rename to syncplay/resources/comments.png diff --git a/resources/control_pause_blue.png b/syncplay/resources/control_pause_blue.png similarity index 100% rename from resources/control_pause_blue.png rename to syncplay/resources/control_pause_blue.png diff --git a/resources/control_play_blue.png b/syncplay/resources/control_play_blue.png similarity index 100% rename from resources/control_play_blue.png rename to syncplay/resources/control_play_blue.png diff --git a/resources/cross.png b/syncplay/resources/cross.png similarity index 100% rename from resources/cross.png rename to syncplay/resources/cross.png diff --git a/resources/cross_checkbox.png b/syncplay/resources/cross_checkbox.png similarity index 100% rename from resources/cross_checkbox.png rename to syncplay/resources/cross_checkbox.png diff --git a/resources/delete.png b/syncplay/resources/delete.png similarity index 100% rename from resources/delete.png rename to syncplay/resources/delete.png diff --git a/resources/door_in.png b/syncplay/resources/door_in.png similarity index 100% rename from resources/door_in.png rename to syncplay/resources/door_in.png diff --git a/resources/email_go.png b/syncplay/resources/email_go.png similarity index 100% rename from resources/email_go.png rename to syncplay/resources/email_go.png diff --git a/resources/empty_checkbox.png b/syncplay/resources/empty_checkbox.png similarity index 100% rename from resources/empty_checkbox.png rename to syncplay/resources/empty_checkbox.png diff --git a/resources/error.png b/syncplay/resources/error.png similarity index 100% rename from resources/error.png rename to syncplay/resources/error.png diff --git a/resources/eye.png b/syncplay/resources/eye.png similarity index 100% rename from resources/eye.png rename to syncplay/resources/eye.png diff --git a/resources/film_add.png b/syncplay/resources/film_add.png similarity index 100% rename from resources/film_add.png rename to syncplay/resources/film_add.png diff --git a/resources/film_edit.png b/syncplay/resources/film_edit.png similarity index 100% rename from resources/film_edit.png rename to syncplay/resources/film_edit.png diff --git a/resources/film_folder_edit.png b/syncplay/resources/film_folder_edit.png similarity index 100% rename from resources/film_folder_edit.png rename to syncplay/resources/film_folder_edit.png diff --git a/resources/film_go.png b/syncplay/resources/film_go.png similarity index 100% rename from resources/film_go.png rename to syncplay/resources/film_go.png diff --git a/resources/film_link.png b/syncplay/resources/film_link.png similarity index 100% rename from resources/film_link.png rename to syncplay/resources/film_link.png diff --git a/resources/folder_explore.png b/syncplay/resources/folder_explore.png similarity index 100% rename from resources/folder_explore.png rename to syncplay/resources/folder_explore.png diff --git a/resources/folder_film.png b/syncplay/resources/folder_film.png similarity index 100% rename from resources/folder_film.png rename to syncplay/resources/folder_film.png diff --git a/resources/help.png b/syncplay/resources/help.png similarity index 100% rename from resources/help.png rename to syncplay/resources/help.png diff --git a/resources/hicolor/128x128/apps/syncplay.png b/syncplay/resources/hicolor/128x128/apps/syncplay.png similarity index 100% rename from resources/hicolor/128x128/apps/syncplay.png rename to syncplay/resources/hicolor/128x128/apps/syncplay.png diff --git a/resources/hicolor/16x16/apps/syncplay.png b/syncplay/resources/hicolor/16x16/apps/syncplay.png similarity index 100% rename from resources/hicolor/16x16/apps/syncplay.png rename to syncplay/resources/hicolor/16x16/apps/syncplay.png diff --git a/resources/hicolor/24x24/apps/syncplay.png b/syncplay/resources/hicolor/24x24/apps/syncplay.png similarity index 100% rename from resources/hicolor/24x24/apps/syncplay.png rename to syncplay/resources/hicolor/24x24/apps/syncplay.png diff --git a/resources/hicolor/256x256/apps/syncplay.png b/syncplay/resources/hicolor/256x256/apps/syncplay.png similarity index 100% rename from resources/hicolor/256x256/apps/syncplay.png rename to syncplay/resources/hicolor/256x256/apps/syncplay.png diff --git a/resources/hicolor/32x32/apps/syncplay.png b/syncplay/resources/hicolor/32x32/apps/syncplay.png similarity index 100% rename from resources/hicolor/32x32/apps/syncplay.png rename to syncplay/resources/hicolor/32x32/apps/syncplay.png diff --git a/resources/hicolor/48x48/apps/syncplay.png b/syncplay/resources/hicolor/48x48/apps/syncplay.png similarity index 100% rename from resources/hicolor/48x48/apps/syncplay.png rename to syncplay/resources/hicolor/48x48/apps/syncplay.png diff --git a/resources/hicolor/64x64/apps/syncplay.png b/syncplay/resources/hicolor/64x64/apps/syncplay.png similarity index 100% rename from resources/hicolor/64x64/apps/syncplay.png rename to syncplay/resources/hicolor/64x64/apps/syncplay.png diff --git a/resources/hicolor/96x96/apps/syncplay.png b/syncplay/resources/hicolor/96x96/apps/syncplay.png similarity index 100% rename from resources/hicolor/96x96/apps/syncplay.png rename to syncplay/resources/hicolor/96x96/apps/syncplay.png diff --git a/resources/house.png b/syncplay/resources/house.png similarity index 100% rename from resources/house.png rename to syncplay/resources/house.png diff --git a/resources/icon.icns b/syncplay/resources/icon.icns similarity index 100% rename from resources/icon.icns rename to syncplay/resources/icon.icns diff --git a/resources/icon.ico b/syncplay/resources/icon.ico similarity index 100% rename from resources/icon.ico rename to syncplay/resources/icon.ico diff --git a/resources/key_go.png b/syncplay/resources/key_go.png similarity index 100% rename from resources/key_go.png rename to syncplay/resources/key_go.png diff --git a/resources/license.rtf b/syncplay/resources/license.rtf similarity index 100% rename from resources/license.rtf rename to syncplay/resources/license.rtf diff --git a/resources/lock.png b/syncplay/resources/lock.png similarity index 100% rename from resources/lock.png rename to syncplay/resources/lock.png diff --git a/resources/lock_green.png b/syncplay/resources/lock_green.png similarity index 100% rename from resources/lock_green.png rename to syncplay/resources/lock_green.png diff --git a/resources/lock_green_dialog.png b/syncplay/resources/lock_green_dialog.png similarity index 100% rename from resources/lock_green_dialog.png rename to syncplay/resources/lock_green_dialog.png diff --git a/resources/lock_open.png b/syncplay/resources/lock_open.png similarity index 100% rename from resources/lock_open.png rename to syncplay/resources/lock_open.png diff --git a/resources/lua/intf/syncplay.lua b/syncplay/resources/lua/intf/syncplay.lua similarity index 100% rename from resources/lua/intf/syncplay.lua rename to syncplay/resources/lua/intf/syncplay.lua diff --git a/resources/macOS_dmg_bkg.tiff b/syncplay/resources/macOS_dmg_bkg.tiff similarity index 100% rename from resources/macOS_dmg_bkg.tiff rename to syncplay/resources/macOS_dmg_bkg.tiff diff --git a/resources/macOS_readme.pdf b/syncplay/resources/macOS_readme.pdf similarity index 100% rename from resources/macOS_readme.pdf rename to syncplay/resources/macOS_readme.pdf diff --git a/resources/man/changelog.md b/syncplay/resources/man/changelog.md similarity index 100% rename from resources/man/changelog.md rename to syncplay/resources/man/changelog.md diff --git a/resources/mpc-be.png b/syncplay/resources/mpc-be.png similarity index 100% rename from resources/mpc-be.png rename to syncplay/resources/mpc-be.png diff --git a/resources/mpc-hc.png b/syncplay/resources/mpc-hc.png similarity index 100% rename from resources/mpc-hc.png rename to syncplay/resources/mpc-hc.png diff --git a/resources/mpc-hc64.png b/syncplay/resources/mpc-hc64.png similarity index 100% rename from resources/mpc-hc64.png rename to syncplay/resources/mpc-hc64.png diff --git a/resources/mplayer.png b/syncplay/resources/mplayer.png similarity index 100% rename from resources/mplayer.png rename to syncplay/resources/mplayer.png diff --git a/resources/mpv.png b/syncplay/resources/mpv.png similarity index 100% rename from resources/mpv.png rename to syncplay/resources/mpv.png diff --git a/resources/page_white_key.png b/syncplay/resources/page_white_key.png similarity index 100% rename from resources/page_white_key.png rename to syncplay/resources/page_white_key.png diff --git a/resources/shield_add.png b/syncplay/resources/shield_add.png similarity index 100% rename from resources/shield_add.png rename to syncplay/resources/shield_add.png diff --git a/resources/shield_edit.png b/syncplay/resources/shield_edit.png similarity index 100% rename from resources/shield_edit.png rename to syncplay/resources/shield_edit.png diff --git a/resources/spinner.mng b/syncplay/resources/spinner.mng similarity index 100% rename from resources/spinner.mng rename to syncplay/resources/spinner.mng diff --git a/resources/syncplay-server.desktop b/syncplay/resources/syncplay-server.desktop similarity index 100% rename from resources/syncplay-server.desktop rename to syncplay/resources/syncplay-server.desktop diff --git a/resources/syncplay.desktop b/syncplay/resources/syncplay.desktop similarity index 100% rename from resources/syncplay.desktop rename to syncplay/resources/syncplay.desktop diff --git a/resources/syncplay.png b/syncplay/resources/syncplay.png similarity index 100% rename from resources/syncplay.png rename to syncplay/resources/syncplay.png diff --git a/resources/syncplayintf.lua b/syncplay/resources/syncplayintf.lua similarity index 100% rename from resources/syncplayintf.lua rename to syncplay/resources/syncplayintf.lua diff --git a/resources/table_refresh.png b/syncplay/resources/table_refresh.png similarity index 100% rename from resources/table_refresh.png rename to syncplay/resources/table_refresh.png diff --git a/resources/third-party-notices.rtf b/syncplay/resources/third-party-notices.rtf similarity index 100% rename from resources/third-party-notices.rtf rename to syncplay/resources/third-party-notices.rtf diff --git a/resources/tick.png b/syncplay/resources/tick.png similarity index 100% rename from resources/tick.png rename to syncplay/resources/tick.png diff --git a/resources/tick_checkbox.png b/syncplay/resources/tick_checkbox.png similarity index 100% rename from resources/tick_checkbox.png rename to syncplay/resources/tick_checkbox.png diff --git a/resources/timeline_marker.png b/syncplay/resources/timeline_marker.png similarity index 100% rename from resources/timeline_marker.png rename to syncplay/resources/timeline_marker.png diff --git a/resources/user_comment.png b/syncplay/resources/user_comment.png similarity index 100% rename from resources/user_comment.png rename to syncplay/resources/user_comment.png diff --git a/resources/user_key.png b/syncplay/resources/user_key.png similarity index 100% rename from resources/user_key.png rename to syncplay/resources/user_key.png diff --git a/resources/vlc.png b/syncplay/resources/vlc.png similarity index 100% rename from resources/vlc.png rename to syncplay/resources/vlc.png diff --git a/resources/world_add.png b/syncplay/resources/world_add.png similarity index 100% rename from resources/world_add.png rename to syncplay/resources/world_add.png diff --git a/resources/world_explore.png b/syncplay/resources/world_explore.png similarity index 100% rename from resources/world_explore.png rename to syncplay/resources/world_explore.png diff --git a/resources/world_go.png b/syncplay/resources/world_go.png similarity index 100% rename from resources/world_go.png rename to syncplay/resources/world_go.png diff --git a/syncplay/utils.py b/syncplay/utils.py index 776889b..6b49129 100755 --- a/syncplay/utils.py +++ b/syncplay/utils.py @@ -147,7 +147,7 @@ def isASCII(s): def findResourcePath(resourceName): if resourceName == "syncplay.lua": - resourcePath = os.path.join(findWorkingDir(),"resources", "lua", "intf", resourceName) + resourcePath = os.path.join(findWorkingDir(), "resources", "lua", "intf", resourceName) else: resourcePath = os.path.join(findWorkingDir(), "resources", resourceName) return resourcePath @@ -156,7 +156,7 @@ def findResourcePath(resourceName): def findWorkingDir(): frozen = getattr(sys, 'frozen', '') if not frozen: - path = os.path.dirname(os.path.dirname(__file__)) + path = os.path.dirname(__file__) elif frozen in ('dll', 'console_exe', 'windows_exe', 'macosx_app'): path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) elif frozen: # needed for PyInstaller diff --git a/syncplayClient.py b/syncplayClient.py index dad7ac3..2f40d78 100755 --- a/syncplayClient.py +++ b/syncplayClient.py @@ -11,9 +11,7 @@ except AttributeError: import warnings warnings.warn("You must run Syncplay with Python 3.4 or newer!") -from syncplay.clientManager import SyncplayClientManager -from syncplay.utils import blackholeStdoutForFrozenWindow +from syncplay import ep_client if __name__ == '__main__': - blackholeStdoutForFrozenWindow() - SyncplayClientManager().run() + ep_client.main() \ No newline at end of file diff --git a/syncplayServer.py b/syncplayServer.py index b0538d3..369714f 100755 --- a/syncplayServer.py +++ b/syncplayServer.py @@ -1,7 +1,6 @@ #!/usr/bin/env python3 #coding:utf8 -import socket import sys # libpath @@ -13,56 +12,7 @@ except AttributeError: import warnings warnings.warn("You must run Syncplay with Python 3.4 or newer!") -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.") - +from syncplay import ep_server if __name__ == '__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() + ep_server.main() \ No newline at end of file