Fixed code formatting
This commit is contained in:
parent
d39bde520f
commit
0a0f249b07
@ -7,19 +7,19 @@ from setuptools import find_packages
|
||||
import syncplay
|
||||
|
||||
common_info = dict(
|
||||
name = 'Syncplay',
|
||||
version = syncplay.version,
|
||||
author = 'Tomasz Kowalczyk, Uriziel',
|
||||
author_email = 'code@fluxid.pl, urizieli@gmail.com',
|
||||
description = 'Syncplay',
|
||||
packages = find_packages(exclude=['venv']),
|
||||
install_requires = ['Twisted>=11.1'],
|
||||
name='Syncplay',
|
||||
version=syncplay.version,
|
||||
author='Tomasz Kowalczyk, Uriziel',
|
||||
author_email='code@fluxid.pl, urizieli@gmail.com',
|
||||
description='Syncplay',
|
||||
packages=find_packages(exclude=['venv']),
|
||||
install_requires=['Twisted>=11.1'],
|
||||
)
|
||||
|
||||
info = dict(
|
||||
common_info,
|
||||
console = [{"script":"syncplayClient.py","icon_resources":[(1,"resources\\icon.ico")]}, 'syncplayServer.py'],
|
||||
options = {'py2exe': {
|
||||
console=[{"script":"syncplayClient.py", "icon_resources":[(1, "resources\\icon.ico")]}, 'syncplayServer.py'],
|
||||
options={'py2exe': {
|
||||
'includes': 'cairo, pango, pangocairo, atk, gobject',
|
||||
'optimize': 2,
|
||||
'compressed': 1
|
||||
|
||||
@ -15,7 +15,7 @@ except ImportError:
|
||||
class SyncplayClientManager(object):
|
||||
def __init__(self):
|
||||
self._prepareArguments()
|
||||
self.interface = ui.getUi(graphical = not self.args.no_gui)
|
||||
self.interface = ui.getUi(graphical=not self.args.no_gui)
|
||||
self._checkAndSaveConfiguration()
|
||||
syncplayClient = None
|
||||
if(self.argsGetter.playerType == "mpc"):
|
||||
@ -49,11 +49,11 @@ class SyncplayClientManager(object):
|
||||
def _promptForMissingArguments(self):
|
||||
if(self.args.no_gui):
|
||||
if (self.args.host == None):
|
||||
self.args.host = self.interface.promptFor(prompt = "Hostname: ", message = "You must supply hostname on the first run, it's easier through command line arguments.")
|
||||
self.args.host = self.interface.promptFor(prompt="Hostname: ", message="You must supply hostname on the first run, it's easier through command line arguments.")
|
||||
if (self.args.name == None):
|
||||
self.args.name = self.interface.promptFor(prompt = "Username: ", message = "You must supply username on the first run, it's easier through command line arguments.")
|
||||
self.args.name = self.interface.promptFor(prompt="Username: ", message="You must supply username on the first run, it's easier through command line arguments.")
|
||||
if (self.args.player_path == None):
|
||||
self.args.player_path = self.interface.promptFor(prompt = "Player executable: ", message = "You must supply path to your player on the first run, it's easier through command line arguments.")
|
||||
self.args.player_path = self.interface.promptFor(prompt="Player executable: ", message="You must supply path to your player on the first run, it's easier through command line arguments.")
|
||||
else:
|
||||
self._guiPromptForMissingArguments()
|
||||
|
||||
|
||||
@ -122,9 +122,9 @@ class MPCHCAPIPlayer(BasePlayer):
|
||||
self.__client.updatePlayerStatus(self.__client.getGlobalPaused(), self.__client.getGlobalPosition())
|
||||
|
||||
def __forcePause(self, paused):
|
||||
i = 0
|
||||
i = 0
|
||||
while(paused <> self._mpcApi.isPaused() and i < 15):
|
||||
i+=1
|
||||
i += 1
|
||||
self.setPaused(paused)
|
||||
time.sleep(0.1)
|
||||
time.sleep(0.1)
|
||||
@ -161,7 +161,7 @@ class MpcHcApi:
|
||||
self.version = None
|
||||
self.__playpause_warden = False
|
||||
self.__locks = self.__Locks()
|
||||
self.__mpcExistenceChecking = threading.Thread(target = self.__mpcReadyInSlaveMode, name ="Check MPC window")
|
||||
self.__mpcExistenceChecking = threading.Thread(target=self.__mpcReadyInSlaveMode, name="Check MPC window")
|
||||
self.__mpcExistenceChecking.setDaemon(True)
|
||||
self.__listener = self.__Listener(self, self.__locks)
|
||||
self.__listener.setDaemon(True)
|
||||
@ -176,7 +176,7 @@ class MpcHcApi:
|
||||
return f(self, *args, **kwds)
|
||||
return wrapper
|
||||
|
||||
def startMpc(self, path, args = ()):
|
||||
def startMpc(self, path, args=()):
|
||||
args = "%s /slave %s" % (" ".join(args), str(self.__listener.hwnd))
|
||||
win32api.ShellExecute(0, "open", path, args, None, 1)
|
||||
if(not self.__locks.mpcStart.wait(10)):
|
||||
@ -208,12 +208,12 @@ class MpcHcApi:
|
||||
def seek(self, position):
|
||||
self.__listener.SendCommand(self.CMD_SETPOSITION, unicode(position))
|
||||
|
||||
def sendOsd(self, message, MsgPos = 2, DurationMs = 3000):
|
||||
def sendOsd(self, message, MsgPos=2, DurationMs=3000):
|
||||
class __OSDDATASTRUCT(ctypes.Structure):
|
||||
_fields_ = [
|
||||
('nMsgPos', ctypes.c_int32),
|
||||
('nDurationMS', ctypes.c_int32),
|
||||
('strMsg', ctypes.c_wchar * (len(message)+1))
|
||||
('strMsg', ctypes.c_wchar * (len(message) + 1))
|
||||
]
|
||||
cmessage = __OSDDATASTRUCT()
|
||||
cmessage.nMsgPos = MsgPos
|
||||
@ -224,7 +224,7 @@ class MpcHcApi:
|
||||
def sendRawCommand(self, cmd, value):
|
||||
self.__listener.SendCommand(cmd, value)
|
||||
|
||||
def handleCommand(self,cmd, value):
|
||||
def handleCommand(self, cmd, value):
|
||||
if (cmd == self.CMD_CONNECT):
|
||||
self.__listener.mpcHandle = int(value)
|
||||
self.__locks.mpcStart.set()
|
||||
@ -245,39 +245,39 @@ class MpcHcApi:
|
||||
elif(cmd == self.CMD_PLAYMODE):
|
||||
self.playState = int(value)
|
||||
if(self.callbacks.onUpdatePlaystate):
|
||||
thread.start_new_thread(self.callbacks.onUpdatePlaystate,(self.playState,))
|
||||
thread.start_new_thread(self.callbacks.onUpdatePlaystate, (self.playState,))
|
||||
|
||||
elif(cmd == self.CMD_NOWPLAYING):
|
||||
value = value.split('|')
|
||||
self.filePath = value[3]
|
||||
self.filePlaying = value[3].split('\\').pop()
|
||||
self.filePlaying = value[3].split('\\').pop()
|
||||
self.fileDuration = float(value[4])
|
||||
if(self.callbacks.onUpdatePath):
|
||||
thread.start_new_thread(self.callbacks.onUpdatePath,(self.onUpdatePath,))
|
||||
thread.start_new_thread(self.callbacks.onUpdatePath, (self.onUpdatePath,))
|
||||
if(self.callbacks.onUpdateFilename):
|
||||
thread.start_new_thread(self.callbacks.onUpdateFilename,(self.filePlaying,))
|
||||
thread.start_new_thread(self.callbacks.onUpdateFilename, (self.filePlaying,))
|
||||
if(self.callbacks.onUpdateFileDuration):
|
||||
thread.start_new_thread(self.callbacks.onUpdateFileDuration,(self.fileDuration,))
|
||||
thread.start_new_thread(self.callbacks.onUpdateFileDuration, (self.fileDuration,))
|
||||
|
||||
elif(cmd == self.CMD_CURRENTPOSITION):
|
||||
self.lastFilePosition = float(value)
|
||||
if(self.callbacks.onGetCurrentPosition):
|
||||
thread.start_new_thread(self.callbacks.onGetCurrentPosition,(self.lastFilePosition,))
|
||||
thread.start_new_thread(self.callbacks.onGetCurrentPosition, (self.lastFilePosition,))
|
||||
|
||||
elif(cmd == self.CMD_NOTIFYSEEK):
|
||||
if(self.lastFilePosition <> float(value)): #Notify seek is sometimes sent twice
|
||||
self.lastFilePosition = float(value)
|
||||
if(self.callbacks.onSeek):
|
||||
thread.start_new_thread(self.callbacks.onSeek,(self.lastFilePosition,))
|
||||
thread.start_new_thread(self.callbacks.onSeek, (self.lastFilePosition,))
|
||||
|
||||
elif(cmd == self.CMD_DISCONNECT):
|
||||
if(self.callbacks.onMpcClosed):
|
||||
thread.start_new_thread(self.callbacks.onMpcClosed,(None,))
|
||||
thread.start_new_thread(self.callbacks.onMpcClosed, (None,))
|
||||
|
||||
elif(cmd == self.CMD_VERSION):
|
||||
if(self.callbacks.onVersion):
|
||||
self.version = value
|
||||
thread.start_new_thread(self.callbacks.onVersion,(value,))
|
||||
thread.start_new_thread(self.callbacks.onVersion, (value,))
|
||||
|
||||
class PlayerNotReadyException(Exception):
|
||||
pass
|
||||
@ -360,9 +360,9 @@ class MpcHcApi:
|
||||
MLS_CLOSING = 3
|
||||
|
||||
class __MPC_PLAYSTATE:
|
||||
PS_PLAY = 0
|
||||
PS_PAUSE = 1
|
||||
PS_STOP = 2
|
||||
PS_PLAY = 0
|
||||
PS_PAUSE = 1
|
||||
PS_STOP = 2
|
||||
PS_UNUSED = 3
|
||||
|
||||
class __Listener(threading.Thread):
|
||||
@ -387,13 +387,13 @@ class MpcHcApi:
|
||||
classAtom,
|
||||
"ListenerGUI",
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
win32con.CW_USEDEFAULT,
|
||||
0,
|
||||
win32con.CW_USEDEFAULT,
|
||||
win32con.CW_USEDEFAULT,
|
||||
0,
|
||||
0,
|
||||
hinst,
|
||||
0,
|
||||
hinst,
|
||||
None
|
||||
)
|
||||
self.locks.listenerStart.set()
|
||||
@ -405,7 +405,7 @@ class MpcHcApi:
|
||||
#print "API:\tin>\t 0x%X\t" % int(pCDS.contents.dwData), ctypes.wstring_at(pCDS.contents.lpData)
|
||||
self.__mpcApi.handleCommand(pCDS.contents.dwData, ctypes.wstring_at(pCDS.contents.lpData))
|
||||
|
||||
def SendCommand(self, cmd, message = u''):
|
||||
def SendCommand(self, cmd, message=u''):
|
||||
#print "API:\t<out\t 0x%X\t" % int(cmd), message
|
||||
if not win32gui.IsWindow(self.mpcHandle):
|
||||
if(self.__mpcApi.callbacks.onMpcClosed):
|
||||
@ -414,14 +414,14 @@ class MpcHcApi:
|
||||
cs.dwData = cmd;
|
||||
|
||||
if(isinstance(message, (unicode, str))):
|
||||
message = ctypes.create_unicode_buffer(message, len(message)+1)
|
||||
message = ctypes.create_unicode_buffer(message, len(message) + 1)
|
||||
elif(isinstance(message, ctypes.Structure)):
|
||||
pass
|
||||
else:
|
||||
raise TypeError
|
||||
cs.lpData = ctypes.addressof(message)
|
||||
cs.cbData = ctypes.sizeof(message)
|
||||
ptr= ctypes.addressof(cs)
|
||||
ptr = ctypes.addressof(cs)
|
||||
win32api.SendMessage(self.mpcHandle, win32con.WM_COPYDATA, self.hwnd, ptr)
|
||||
|
||||
class __COPYDATASTRUCT(ctypes.Structure):
|
||||
@ -433,4 +433,4 @@ class MpcHcApi:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -156,4 +156,4 @@ class MplayerPlayer(BasePlayer):
|
||||
for line in self.__process.stderr.readlines():
|
||||
yield line
|
||||
|
||||
|
||||
|
||||
|
||||
@ -46,8 +46,8 @@ class ConfigurationGetter(object):
|
||||
self._parser.add_argument('--no-gui', action='store_true', help='show no GUI')
|
||||
self._parser.add_argument('-a', '--host', metavar='hostname', type=str, help='server\'s address')
|
||||
self._parser.add_argument('-n', '--name', metavar='username', type=str, help='desired username')
|
||||
self._parser.add_argument('-d','--debug', action='store_true', help='debug mode')
|
||||
self._parser.add_argument('-g','--force-gui-prompt', action='store_true', help='make configuration prompt appear')
|
||||
self._parser.add_argument('-d', '--debug', action='store_true', help='debug mode')
|
||||
self._parser.add_argument('-g', '--force-gui-prompt', action='store_true', help='make configuration prompt appear')
|
||||
self._parser.add_argument('--no-store', action='store_true', help='don\'t store values in syncplay.ini')
|
||||
self._parser.add_argument('-r', '--room', metavar='room', type=str, nargs='?', help='default room')
|
||||
self._parser.add_argument('-p', '--password', metavar='password', type=str, nargs='?', help='server password')
|
||||
|
||||
@ -6,7 +6,7 @@ gtk.set_interactive(False)
|
||||
import cairo, gio, pango, atk, pangocairo, gobject #@UnusedImport
|
||||
|
||||
class GuiConfiguration:
|
||||
def __init__(self, args, force = False):
|
||||
def __init__(self, args, force=False):
|
||||
self.args = args
|
||||
self.closedAndNotSaved = False
|
||||
if(args.player_path == None or args.host == None or args.name == None or force):
|
||||
@ -43,7 +43,7 @@ class GuiConfiguration:
|
||||
|
||||
def _tryToFillUpMpcPath(self):
|
||||
if(self.args.player_path == None):
|
||||
paths = ["C:\Program Files (x86)\MPC-HC\mpc-hc.exe",
|
||||
paths = ["C:\Program Files (x86)\MPC-HC\mpc-hc.exe",
|
||||
"C:\Program Files\MPC-HC\mpc-hc.exe",
|
||||
"C:\Program Files\MPC-HC\mpc-hc64.exe",
|
||||
"C:\Program Files\Media Player Classic - Home Cinema\mpc-hc.exe",
|
||||
@ -106,4 +106,4 @@ class GuiConfiguration:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
from syncplay.ui.gui import GraphicalUI
|
||||
from syncplay.ui.consoleUI import ConsoleUI
|
||||
|
||||
def getUi(graphical = True):
|
||||
def getUi(graphical=True):
|
||||
if(False): #graphical): #TODO: Add graphical ui
|
||||
ui = GraphicalUI()
|
||||
else:
|
||||
ui = ConsoleUI()
|
||||
ui.setDaemon(True)
|
||||
ui.start()
|
||||
return ui
|
||||
return ui
|
||||
|
||||
@ -26,7 +26,7 @@ class ConsoleUI(threading.Thread):
|
||||
elif(self._syncplayClient):
|
||||
self._executeCommand(data)
|
||||
|
||||
def promptFor(self, prompt = ">", message = ""):
|
||||
def promptFor(self, prompt=">", message=""):
|
||||
if message <> "":
|
||||
print(message)
|
||||
self.promptMode.clear()
|
||||
@ -34,9 +34,9 @@ class ConsoleUI(threading.Thread):
|
||||
self.promptMode.wait()
|
||||
return self.PromptResult
|
||||
|
||||
def showMessage(self, message, noTimestamp = False):
|
||||
def showMessage(self, message, noTimestamp=False):
|
||||
if(os.name == "nt"):
|
||||
message = message.encode('ascii','replace')
|
||||
message = message.encode('ascii', 'replace')
|
||||
if(noTimestamp):
|
||||
print(message)
|
||||
else:
|
||||
@ -50,7 +50,7 @@ class ConsoleUI(threading.Thread):
|
||||
|
||||
def __doSeek(self, m):
|
||||
if (m.group(4)):
|
||||
t = int(m.group(5))*60 + int(m.group(6))
|
||||
t = int(m.group(5)) * 60 + int(m.group(6))
|
||||
else:
|
||||
t = int(m.group(2))
|
||||
if(m.group(1)):
|
||||
@ -58,7 +58,7 @@ class ConsoleUI(threading.Thread):
|
||||
sign = -1
|
||||
else:
|
||||
sign = 1
|
||||
t = self._syncplayClient.getGlobalPosition() + sign*t
|
||||
t = self._syncplayClient.getGlobalPosition() + sign * t
|
||||
self._syncplayClient.setPosition(t)
|
||||
|
||||
def _executeCommand(self, data):
|
||||
@ -81,13 +81,13 @@ class ConsoleUI(threading.Thread):
|
||||
elif data == "p":
|
||||
self._syncplayClient.setPaused(not self._syncplayClient.getPlayerPaused())
|
||||
elif data == 'help':
|
||||
self.showMessage( "Available commands:", True)
|
||||
self.showMessage( "\thelp - this help", True )
|
||||
self.showMessage( "\tr - revert last seek", True )
|
||||
self.showMessage( "\tp - toggle pause", True )
|
||||
self.showMessage( "\troom [name] - change room", True )
|
||||
self.showMessage( "\t[s][+-][time] - seek to the given value of time, if + or - is not specified it's absolute time in seconds or min:sec", True )
|
||||
self.showMessage("Available commands:", True)
|
||||
self.showMessage("\thelp - this help", True)
|
||||
self.showMessage("\tr - revert last seek", True)
|
||||
self.showMessage("\tp - toggle pause", True)
|
||||
self.showMessage("\troom [name] - change room", True)
|
||||
self.showMessage("\t[s][+-][time] - seek to the given value of time, if + or - is not specified it's absolute time in seconds or min:sec", True)
|
||||
self.showMessage("Syncplay version: {}".format(syncplay.version), True)
|
||||
self.showMessage("More info available at: {}".format(syncplay.projectURL), True)
|
||||
else:
|
||||
self.showMessage( "Unrecognized command, type 'help' for list of available commands" )
|
||||
self.showMessage("Unrecognized command, type 'help' for list of available commands")
|
||||
|
||||
@ -6,4 +6,4 @@ Created on 05-07-2012
|
||||
|
||||
class GraphicalUI(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
pass
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user