diff --git a/buildPy2exe.py b/buildPy2exe.py index 32a02c0..921e3b7 100644 --- a/buildPy2exe.py +++ b/buildPy2exe.py @@ -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 diff --git a/syncplay/clientManager.py b/syncplay/clientManager.py index b08f903..a60d075 100644 --- a/syncplay/clientManager.py +++ b/syncplay/clientManager.py @@ -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() diff --git a/syncplay/players/mpc.py b/syncplay/players/mpc.py index d63c489..8084818 100644 --- a/syncplay/players/mpc.py +++ b/syncplay/players/mpc.py @@ -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 "": 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") diff --git a/syncplay/ui/gui.py b/syncplay/ui/gui.py index 661c2f7..0ae7f4d 100644 --- a/syncplay/ui/gui.py +++ b/syncplay/ui/gui.py @@ -6,4 +6,4 @@ Created on 05-07-2012 class GraphicalUI(object): def __init__(self): - pass \ No newline at end of file + pass