From 68a9d5be6522dcd126c3be78778940e53a051a9d Mon Sep 17 00:00:00 2001 From: Uriziel Date: Sat, 22 Sep 2012 14:44:05 +0200 Subject: [PATCH] Wait for interaction on unclean exit --- syncplay/SyncplayMPC.py | 2 +- syncplay/client.py | 8 ++++++-- syncplay/ui/consoleUI.py | 4 ++-- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/syncplay/SyncplayMPC.py b/syncplay/SyncplayMPC.py index 68d53f6..73301a8 100644 --- a/syncplay/SyncplayMPC.py +++ b/syncplay/SyncplayMPC.py @@ -27,6 +27,6 @@ class SyncplayMPC(SyncplayClient): def _promptForMissingArguments(self): SyncplayClient._promptForMissingArguments(self) if (self.args.mpc_path == None): - self.args.mpc_path = self.interface.promptFor(promptName = "Path to mpc-hc.exe", message = "You must supply path to mpc on the first run, it's easier through command line arguments.") + self.args.mpc_path = self.interface.promptFor(prompt = "Path to mpc-hc.exe: ", message = "You must supply path to mpc on the first run, it's easier through command line arguments.") \ No newline at end of file diff --git a/syncplay/client.py b/syncplay/client.py index 3d13513..2bfaa36 100644 --- a/syncplay/client.py +++ b/syncplay/client.py @@ -263,6 +263,7 @@ class SyncplayClientManager(object): if self.player: self.player.drop() reactor.callLater(0.1, reactor.stop) + self.ui.promptFor("Press enter to exit") def checkIfFileMatchesOthers(self): notMatchingList = self.users.getUsersWithNotMatchingFilenames() @@ -480,6 +481,9 @@ class SyncplayClientManager(object): def showErrorMessage(self, message): self.__ui.showErrorMessage(message) + def promptFor(self, prompt): + return self.__ui.promptFor(prompt) + class SyncplayUser(object): def __init__(self, name = None, filename = None, room = None, fileduration = None, filesize = None): self.name = name @@ -561,8 +565,8 @@ class SyncplayClient(object): def _promptForMissingArguments(self): if(self.args.no_gui): if (self.args.host == None): - self.args.host = self.interface.promptFor(promptName = "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(promptName = "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.") else: self._guiPromptForMissingArguments() \ No newline at end of file diff --git a/syncplay/ui/consoleUI.py b/syncplay/ui/consoleUI.py index a4df89c..75e52dc 100644 --- a/syncplay/ui/consoleUI.py +++ b/syncplay/ui/consoleUI.py @@ -34,10 +34,10 @@ class ConsoleUI(threading.Thread): self._syncplayClient.protocol_factory.stop_retrying() pass - def promptFor(self, promptName = ">", message = ""): + def promptFor(self, prompt = ">", message = ""): print(message) self.promptMode.clear() - print(promptName+": ", end='') + print(prompt, end='') self.promptMode.wait() return self.PromptResult