MCPcopy Create free account
hub / github.com/Syncplay/syncplay / executeCommand

Method executeCommand

syncplay/ui/consoleUI.py:156–272  ·  view source on GitHub ↗
(self, data)

Source from the content-addressed store, hash-verified

154 return False
155
156 def executeCommand(self, data):
157 command = re.match(constants.UI_COMMAND_REGEX, data)
158 if not command:
159 return
160 if command.group('command') in constants.COMMANDS_UNDO:
161 tmp_pos = self._syncplayClient.getPlayerPosition()
162 self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
163 self._syncplayClient.playerPositionBeforeLastSeek = tmp_pos
164 elif command.group('command') in constants.COMMANDS_LIST:
165 self.getUserlist()
166 elif command.group('command') in constants.COMMANDS_CHAT:
167 message = command.group('parameter')
168 self._syncplayClient.sendChat(message)
169 elif command.group('command') in constants.COMMANDS_PAUSE:
170 self._syncplayClient.setPaused(not self._syncplayClient.getPlayerPaused())
171 elif command.group('command') in constants.COMMANDS_ROOM:
172 room = command.group('parameter')
173 if room is None:
174 if self._syncplayClient.userlist.currentUser.file:
175 room = self._syncplayClient.userlist.currentUser.file["name"]
176 else:
177 room = self._syncplayClient.defaultRoom
178 self._syncplayClient.setRoom(room, resetAutoplay=True)
179 self._syncplayClient.ui.updateRoomName(room)
180 self._syncplayClient.sendRoom()
181 elif command.group('command') in constants.COMMANDS_CREATE:
182 roombasename = command.group('parameter')
183 if roombasename is None:
184 roombasename = self._syncplayClient.getRoom()
185 roombasename = utils.stripRoomName(roombasename)
186 self._syncplayClient.createControlledRoom(roombasename)
187 elif command.group('command') in constants.COMMANDS_AUTH:
188 controlpassword = command.group('parameter')
189 self._syncplayClient.identifyAsController(controlpassword)
190 elif command.group('command') in constants.COMMANDS_TOGGLE:
191 self._syncplayClient.toggleReady()
192 elif command.group('command') in constants.COMMANDS_QUEUE:
193 filename = command.group('parameter')
194 if filename is None:
195 self.showErrorMessage("No file/url given")
196 return
197 self._syncplayClient.ui.addFileToPlaylist(filename)
198 elif command.group('command') in constants.COMMANDS_QUEUEANDSELECT:
199 self._syncplayClient.playlist.switchToNewPlaylistItem = True
200 self.executeCommand("{} {}".format(constants.COMMANDS_QUEUE[0], command.group('parameter')))
201 elif command.group('command') in constants.COMMANDS_PLAYLIST:
202 playlist = self._syncplayClient.playlist
203 playlist_elements = ["\t{}: {}".format(i+1, el) for i, el in enumerate(playlist._playlist)]
204
205 if playlist_elements:
206 i = playlist._playlistIndex
207 if i is not None and i in range(len(playlist_elements)):
208 playlist_elements[i] = " *" + playlist_elements[i]
209
210 self.showMessage("\n".join(playlist_elements), True)
211 else:
212 self.showMessage(getMessage("playlist-empty-error"), True)
213 elif command.group('command') in constants.COMMANDS_SELECT:

Callers 1

runMethod · 0.95

Calls 15

getUserlistMethod · 0.95
showErrorMessageMethod · 0.95
showMessageMethod · 0.95
_tryAdvancedCommandsMethod · 0.95
getMessageFunction · 0.90
getPlayerPositionMethod · 0.80
getPlayerPausedMethod · 0.80
sendRoomMethod · 0.80
toggleReadyMethod · 0.80
rewindFileMethod · 0.80
deleteAtIndexMethod · 0.80

Tested by

no test coverage detected