removed unneded functions
This commit is contained in:
parent
1c232bb2dc
commit
c871cd8837
@ -3,6 +3,7 @@ import threading
|
|||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
import syncplay
|
import syncplay
|
||||||
|
import os
|
||||||
|
|
||||||
class ConsoleUI(threading.Thread):
|
class ConsoleUI(threading.Thread):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -27,7 +28,7 @@ class ConsoleUI(threading.Thread):
|
|||||||
self._executeCommand(data)
|
self._executeCommand(data)
|
||||||
except:
|
except:
|
||||||
self._syncplayClient.protocolFactory.stopRetrying()
|
self._syncplayClient.protocolFactory.stopRetrying()
|
||||||
pass
|
|
||||||
|
|
||||||
def promptFor(self, prompt = ">", message = ""):
|
def promptFor(self, prompt = ">", message = ""):
|
||||||
if message <> "":
|
if message <> "":
|
||||||
@ -38,6 +39,8 @@ class ConsoleUI(threading.Thread):
|
|||||||
return self.PromptResult
|
return self.PromptResult
|
||||||
|
|
||||||
def showMessage(self, message, noTimestamp):
|
def showMessage(self, message, noTimestamp):
|
||||||
|
if(os.name == "nt"):
|
||||||
|
message = message.encode('ascii','replace')
|
||||||
if(noTimestamp):
|
if(noTimestamp):
|
||||||
print(message)
|
print(message)
|
||||||
else:
|
else:
|
||||||
@ -49,32 +52,17 @@ class ConsoleUI(threading.Thread):
|
|||||||
def showErrorMessage(self, message):
|
def showErrorMessage(self, message):
|
||||||
print("ERROR:\t" + message)
|
print("ERROR:\t" + message)
|
||||||
|
|
||||||
def __exectueSeekCmd(self, seek_type, minutes, seconds):
|
|
||||||
self._syncplayClient.playerPositionBeforeLastSeek = self._syncplayClient.player_position
|
|
||||||
if seek_type == 's':
|
|
||||||
seconds = int(seconds) if seconds <> None else 0
|
|
||||||
seconds += int(minutes) * 60 if minutes <> None else 0
|
|
||||||
self._syncplayClient.setPosition(seconds)
|
|
||||||
else: #seek_type s+
|
|
||||||
seconds = int(seconds) if seconds <> None and minutes <> None else 20
|
|
||||||
seconds += int(minutes) * 60 if minutes <> None else 60
|
|
||||||
self._syncplayClient.setPosition(self.player_position+seconds)
|
|
||||||
|
|
||||||
def _executeCommand(self, data):
|
def _executeCommand(self, data):
|
||||||
RE_SEEK = re.compile("^([\+\-s]+) ?(-?\d+)?([^0-9](\d+))?$")
|
|
||||||
RE_ROOM = re.compile("^room( (\w+))?")
|
RE_ROOM = re.compile("^room( (\w+))?")
|
||||||
matched_seek = RE_SEEK.match(data)
|
|
||||||
matched_room = RE_ROOM.match(data)
|
matched_room = RE_ROOM.match(data)
|
||||||
if matched_seek :
|
if matched_room:
|
||||||
self.__exectueSeekCmd(matched_seek.group(1), matched_seek.group(2), matched_seek.group(4))
|
|
||||||
elif matched_room:
|
|
||||||
room = matched_room.group(2)
|
room = matched_room.group(2)
|
||||||
if room == None:
|
if room == None:
|
||||||
if self._syncplayClient.users.currentUser._filename <> None:
|
if self._syncplayClient.userlist.currentUser.file:
|
||||||
room = self._syncplayClient.users.currentUser._filename
|
room = self._syncplayClient.userlist.currentUser.file["name"]
|
||||||
else:
|
else:
|
||||||
room = self._syncplayClient.defaultRoom
|
room = self._syncplayClient.defaultRoom
|
||||||
self._syncplayClient.protocol.sendRoomSetting(room)
|
self._syncplayClient.setRoom(room)
|
||||||
elif data == "r":
|
elif data == "r":
|
||||||
tmp_pos = self._syncplayClient.getPlayerPosition()
|
tmp_pos = self._syncplayClient.getPlayerPosition()
|
||||||
self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
|
self._syncplayClient.setPosition(self._syncplayClient.playerPositionBeforeLastSeek)
|
||||||
@ -86,8 +74,6 @@ class ConsoleUI(threading.Thread):
|
|||||||
elif data == 'help':
|
elif data == 'help':
|
||||||
self.showMessage( "Available commands:" )
|
self.showMessage( "Available commands:" )
|
||||||
self.showMessage( "\thelp - this help" )
|
self.showMessage( "\thelp - this help" )
|
||||||
self.showMessage( "\ts [time] - seek" )
|
|
||||||
self.showMessage( "\ts+ [time] - seek to: current position += time" )
|
|
||||||
self.showMessage( "\tr - revert last seek" )
|
self.showMessage( "\tr - revert last seek" )
|
||||||
self.showMessage( "\tp - toggle pause" )
|
self.showMessage( "\tp - toggle pause" )
|
||||||
self.showMessage( "\troom [name] - change room" )
|
self.showMessage( "\troom [name] - change room" )
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user