コード例 #1
0
ファイル: consoleUI.py プロジェクト: Penacillin/syncplay
    def _executeCommand(self, data):
        command = re.match(constants.UI_COMMAND_REGEX, data)
        if not command:
            return
        if command.group('command') in constants.COMMANDS_UNDO:
            tmp_pos = self._syncplayClient.getPlayerPosition()
            self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
            self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
        elif command.group('command') in constants.COMMANDS_LIST:
            self._syncplayClient.getUserList()
        elif command.group('command') in constants.COMMANDS_CHAT:
            message= command.group('parameter')            
            self._syncplayClient.sendChat(message)
        elif command.group('command') in constants.COMMANDS_PAUSE:
            self._syncplayClient.setPaused(not self._syncplayClient.getPlayerPaused())
        elif command.group('command') in constants.COMMANDS_ROOM:
            room = command.group('parameter')
            if room == None:
                if  self._syncplayClient.userlist.currentUser.file:
                    room = self._syncplayClient.userlist.currentUser.file["name"]
                else:
                    room = self._syncplayClient.defaultRoom

            self._syncplayClient.setRoom(room, resetAutoplay=True)
            self._syncplayClient.sendRoom()
        elif command.group('command') in constants.COMMANDS_CREATE:
            roombasename = command.group('parameter')
            if roombasename == None:
                roombasename = self._syncplayClient.getRoom()
            roombasename = utils.stripRoomName(roombasename)
            self._syncplayClient.createControlledRoom(roombasename)
        elif command.group('command') in constants.COMMANDS_AUTH:
            controlpassword = command.group('parameter')
            self._syncplayClient.identifyAsController(controlpassword)
        elif command.group('command') in constants.COMMANDS_TOGGLE:
            self._syncplayClient.toggleReady()
        else:
            if self._tryAdvancedCommands(data):
                return
            if command.group('command') not in constants.COMMANDS_HELP:
                self.showMessage(getMessage("unrecognized-command-notification"))
            self.showMessage(getMessage("commandlist-notification"), True)
            self.showMessage(getMessage("commandlist-notification/room"), True)
            self.showMessage(getMessage("commandlist-notification/list"), True)
            self.showMessage(getMessage("commandlist-notification/undo"), True)
            self.showMessage(getMessage("commandlist-notification/pause"), True)
            self.showMessage(getMessage("commandlist-notification/seek"), True)
            self.showMessage(getMessage("commandlist-notification/help"), True)
            self.showMessage(getMessage("commandlist-notification/toggle"), True)
            self.showMessage(getMessage("commandlist-notification/create"), True)
            self.showMessage(getMessage("commandlist-notification/auth"), True)
            self.showMessage(getMessage("commandlist-notification/chat"), True)
            self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True)
            self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)
コード例 #2
0
ファイル: consoleUI.py プロジェクト: squeaksies/syncplay
 def executeCommand(self, data):
     command = re.match(constants.UI_COMMAND_REGEX, data)
     if not command:
         return
     if command.group('command') in constants.COMMANDS_UNDO:
         tmp_pos = self._syncplayClient.getPlayerPosition()
         self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
         self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
     elif command.group('command') in constants.COMMANDS_LIST:
         self.getUserlist()
     elif command.group('command') in constants.COMMANDS_CHAT:
         message = command.group('parameter')
         self._syncplayClient.sendChat(message)
     elif command.group('command') in constants.COMMANDS_PAUSE:
         self._syncplayClient.setPaused(not self._syncplayClient.getPlayerPaused())
     elif command.group('command') in constants.COMMANDS_ROOM:
         room = command.group('parameter')
         if room is None:
             if self._syncplayClient.userlist.currentUser.file:
                 room = self._syncplayClient.userlist.currentUser.file["name"]
             else:
                 room = self._syncplayClient.defaultRoom
         self._syncplayClient.setRoom(room, resetAutoplay=True)
         self._syncplayClient.ui.updateRoomName(room)
         self._syncplayClient.sendRoom()
     elif command.group('command') in constants.COMMANDS_CREATE:
         roombasename = command.group('parameter')
         if roombasename is None:
             roombasename = self._syncplayClient.getRoom()
         roombasename = utils.stripRoomName(roombasename)
         self._syncplayClient.createControlledRoom(roombasename)
     elif command.group('command') in constants.COMMANDS_AUTH:
         controlpassword = command.group('parameter')
         self._syncplayClient.identifyAsController(controlpassword)
     elif command.group('command') in constants.COMMANDS_TOGGLE:
         self._syncplayClient.toggleReady()
     else:
         if self._tryAdvancedCommands(data):
             return
         if command.group('command') not in constants.COMMANDS_HELP:
             self.showMessage(getMessage("unrecognized-command-notification"))
         self.showMessage(getMessage("commandlist-notification"), True)
         self.showMessage(getMessage("commandlist-notification/room"), True)
         self.showMessage(getMessage("commandlist-notification/list"), True)
         self.showMessage(getMessage("commandlist-notification/undo"), True)
         self.showMessage(getMessage("commandlist-notification/pause"), True)
         self.showMessage(getMessage("commandlist-notification/seek"), True)
         self.showMessage(getMessage("commandlist-notification/help"), True)
         self.showMessage(getMessage("commandlist-notification/toggle"), True)
         self.showMessage(getMessage("commandlist-notification/create"), True)
         self.showMessage(getMessage("commandlist-notification/auth"), True)
         self.showMessage(getMessage("commandlist-notification/chat"), True)
         self.showMessage(getMessage("syncplay-version-notification").format(syncplay.version), True)
         self.showMessage(getMessage("more-info-notification").format(syncplay.projectURL), True)
コード例 #3
0
ファイル: consoleUI.py プロジェクト: zeroeightysix/syncplay
    def executeCommand(self, data):
        command = re.match(constants.UI_COMMAND_REGEX, data)
        if not command:
            return
        if command.group('command') in constants.COMMANDS_UNDO:
            tmp_pos = self._syncplayClient.getPlayerPosition()
            self._syncplayClient.setPosition(
                self._syncplayClient.playerPositionBeforeLastSeek)
            self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
        elif command.group('command') in constants.COMMANDS_LIST:
            self.getUserlist()
        elif command.group('command') in constants.COMMANDS_CHAT:
            message = command.group('parameter')
            self._syncplayClient.sendChat(message)
        elif command.group('command') in constants.COMMANDS_PAUSE:
            self._syncplayClient.setPaused(
                not self._syncplayClient.getPlayerPaused())
        elif command.group('command') in constants.COMMANDS_ROOM:
            room = command.group('parameter')
            if room is None:
                if self._syncplayClient.userlist.currentUser.file:
                    room = self._syncplayClient.userlist.currentUser.file[
                        "name"]
                else:
                    room = self._syncplayClient.defaultRoom
            self._syncplayClient.setRoom(room, resetAutoplay=True)
            self._syncplayClient.ui.updateRoomName(room)
            self._syncplayClient.sendRoom()
        elif command.group('command') in constants.COMMANDS_CREATE:
            roombasename = command.group('parameter')
            if roombasename is None:
                roombasename = self._syncplayClient.getRoom()
            roombasename = utils.stripRoomName(roombasename)
            self._syncplayClient.createControlledRoom(roombasename)
        elif command.group('command') in constants.COMMANDS_AUTH:
            controlpassword = command.group('parameter')
            self._syncplayClient.identifyAsController(controlpassword)
        elif command.group('command') in constants.COMMANDS_TOGGLE:
            self._syncplayClient.toggleReady()
        elif command.group('command') in constants.COMMANDS_QUEUE:
            filename = command.group('parameter')
            if filename is None:
                self.showErrorMessage("No file/url given")
                return

            self._syncplayClient.ui.addFileToPlaylist(filename)
        elif command.group('command') in constants.COMMANDS_PLAYLIST:
            playlist = self._syncplayClient.playlist
            playlist_elements = [
                "\t{}: {}".format(i + 1, el)
                for i, el in enumerate(playlist._playlist)
            ]

            if playlist_elements:
                i = playlist._playlistIndex
                if i is not None and i in range(len(playlist_elements)):
                    playlist_elements[i] = " *" + playlist_elements[i]

                self.showMessage("\n".join(playlist_elements), True)
            else:
                self.showMessage(getMessage("playlist-empty-error"), True)
        elif command.group('command') in constants.COMMANDS_SELECT:
            try:
                index = int(command.group('parameter').strip()) - 1

                if index < 0 or index >= len(
                        self._syncplayClient.playlist._playlist):
                    raise TypeError("Invalid playlist index")
                self._syncplayClient.playlist.changeToPlaylistIndex(
                    index, resetPosition=True)
                self._syncplayClient.rewindFile()

            except (TypeError, AttributeError):
                self.showErrorMessage(
                    getMessage("playlist-invalid-index-error"))
        elif command.group('command') in constants.COMMANDS_DELETE:
            try:
                index = int(command.group('parameter').strip()) - 1
                self._syncplayClient.playlist.deleteAtIndex(index)

            except (TypeError, AttributeError):
                self.showErrorMessage(
                    getMessage("playlist-invalid-index-error"))

        else:
            if self._tryAdvancedCommands(data):
                return
            if command.group('command') not in constants.COMMANDS_HELP:
                self.showMessage(
                    getMessage("unrecognized-command-notification"))
            self.showMessage(getMessage("commandlist-notification"), True)
            self.showMessage(getMessage("commandlist-notification/room"), True)
            self.showMessage(getMessage("commandlist-notification/list"), True)
            self.showMessage(getMessage("commandlist-notification/undo"), True)
            self.showMessage(getMessage("commandlist-notification/pause"),
                             True)
            self.showMessage(getMessage("commandlist-notification/seek"), True)
            self.showMessage(getMessage("commandlist-notification/help"), True)
            self.showMessage(getMessage("commandlist-notification/toggle"),
                             True)
            self.showMessage(getMessage("commandlist-notification/create"),
                             True)
            self.showMessage(getMessage("commandlist-notification/auth"), True)
            self.showMessage(getMessage("commandlist-notification/chat"), True)
            self.showMessage(getMessage("commandList-notification/queue"),
                             True)
            self.showMessage(getMessage("commandList-notification/playlist"),
                             True)
            self.showMessage(getMessage("commandList-notification/select"),
                             True)
            self.showMessage(getMessage("commandList-notification/delete"),
                             True)
            self.showMessage(
                getMessage("syncplay-version-notification").format(
                    syncplay.version), True)
            self.showMessage(
                getMessage("more-info-notification").format(
                    syncplay.projectURL), True)
コード例 #4
0
ファイル: gui.py プロジェクト: SLKTH/syncplay
 def createControlledRoom(self):
     controlroom, ok = QtGui.QInputDialog.getText(self, getMessage("createcontrolledroom-msgbox-label"),
             getMessage("controlledroominfo-msgbox-label"), QtGui.QLineEdit.Normal,
             utils.stripRoomName(self._syncplayClient.getRoom()))
     if ok and controlroom != '':
         self._syncplayClient.createControlledRoom(controlroom)