From a69caa6c4885f35e3795d9bf07f5c0ace5f7b241 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Wed, 4 Apr 2012 23:47:18 +0200 Subject: [PATCH] Upload confirmation --- bin/asciiio.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/asciiio.py b/bin/asciiio.py index 2daf56c..2f106b8 100755 --- a/bin/asciiio.py +++ b/bin/asciiio.py @@ -39,7 +39,15 @@ class AsciiCast(object): def create(self): self._record() - return self._upload() + if self.confirm_upload(): + return self._upload() + else: + self._delete() + + def confirm_upload(self): + sys.stdout.write("~ Do you want to upload it? [Y/n] ") + answer = sys.stdin.readline().strip() + return answer == 'y' or answer == 'Y' or answer == '' def _record(self): os.makedirs(self.path) @@ -96,6 +104,9 @@ class AsciiCast(object): else: return False + def _delete(self): + shutil.rmtree(self.path) + class TimedFile(object): '''File wrapper that records write times in separate file.'''