Permalink
Browse files

remove recursion from preloader

  • Loading branch information...
1 parent 27da7e4 commit 03cbd696bce03c7f1d8eecfc9791da9f800c9bcc @stepler stepler committed Jul 2, 2012
Showing with 14 additions and 13 deletions.
  1. +12 −12 out.py
  2. +2 −1 tools.py
View
24 out.py
@@ -62,7 +62,7 @@ def stop():
if not config.IS_OUT_TERMINAL:
return
preloader.counter = -1
- preloader.draw()
+ printLine(preloader.clearLine, "")
preloader.isLaunch = False
@staticmethod
@@ -72,18 +72,18 @@ def exit():
@staticmethod
def draw():
- if not preloader.isLaunch:
- return
-
- printLine(preloader.clearLine, "")
- if preloader.counter == -1:
- return
+ try:
+ if not preloader.isLaunch:
+ return
- preloader.counter += 1
- printLine("%s : %s" % (preloader.progress[preloader.counter % len(preloader.progress)], preloader.message), "")
+ while preloader.counter >= 0:
+ printLine(preloader.clearLine, "")
+ preloader.counter += 1
+ printLine("%s : %s" % (preloader.progress[preloader.counter % len(preloader.progress)], preloader.message), "")
- time.sleep(0.3)
- preloader.draw()
+ time.sleep(0.3)
+ except (KeyboardInterrupt, SystemExit, tools.ExitException):
+ pass
@preloaderPause
def GetUserCredentials():
@@ -97,7 +97,7 @@ def GetUserCredentials():
if password is None:
password = rawInput("Password: ", True)
except KeyboardInterrupt:
- tools.KeyboardInterruptSignalHendler(None, None)
+ tools.exit()
return (login, password)
View
@@ -4,6 +4,7 @@
from log import logging
import sys
import shlex
+import time
def checkIsInt(value):
try:
@@ -51,10 +52,10 @@ class ExitException(Exception):
def exit(message='exit'):
out.preloader.exit()
+ time.sleep(0.33)
raise ExitException(message)
def KeyboardInterruptSignalHendler(signal, frame):
- out.printLine("\nYou pressed Ctrl+C!")
exit()
class Struct:
@liushuaikobe

liushuaikobe Aug 7, 2013

Could anyone tell me please why we use a Struct class instead of a dictionary directly ? I would appreciate him a lot !!

0 comments on commit 03cbd69

Please sign in to comment.