Пример #1
0
 def __init__(self, time=None, notnow=True, in_sec=False):
     console.codes['bg_gray'] = '\x1b[01;40m'
     self.font = FonteZokis()
     self.timing = 5
     self.cls = self.font.cls
     if time:
         self.timing = time
         if not in_sec:
             self.timing = int(self.timing * 60)
         if notnow:
             raw_input("Press Enter")
     else:
         self.in_set_time()
Пример #2
0
    def __init__(self, time=None, notnow=True, in_sec=False, times=None):
        console.codes['bg_gray'] = '\x1b[01;40m'
        self.font = FonteZokis()
        self.timing = 5

        if times and times <= 1:
            print ('Usage: termtimer.py [options]\n' +
                    '\n' +
                    'termtimer.py: error: -x option require a value greater than 1')
            sys.exit(ERROR)
        self.times_fix = times and times - 1 or None
        self.times = self.times_fix
        self.cls = self.font.cls
        if time:
            self.timing = time
            if not in_sec:
                self.timing = int(self.timing * 60)
            if notnow:
                raw_input("Press Enter")
        else:
            self.in_set_time()
Пример #3
0
 def __init__(self, time=None, notnow=True, in_sec=False):
     console.codes['bg_gray'] = '\x1b[01;40m'
     self.font = FonteZokis()
     self.timing = 5
     self.cls = self.font.cls
     if time:
         self.timing = time
         if not in_sec:
             self.timing = int(self.timing * 60)
         if notnow:
             raw_input("Press Enter")
     else:
         self.in_set_time()
Пример #4
0
    def __init__(self, time=None, notnow=True, in_sec=False, times=None):
        console.codes["bg_gray"] = "\x1b[01;40m"
        self.font = FonteZokis()
        self.timing = 5

        if times and times <= 1:
            print (
                "Usage: termtimer.py [options]\n"
                + "\n"
                + "termtimer.py: error: -x option require a value greater than 1"
            )
            sys.exit(ERROR)
        self.times_fix = times and times - 1 or None
        self.times = self.times_fix
        self.cls = self.font.cls
        if time:
            self.timing = time
            if not in_sec:
                self.timing = int(self.timing * 60)
            if notnow:
                raw_input("Press Enter")
        else:
            self.in_set_time()
Пример #5
0
class TermTimer(object):
    def __init__(self, time=None, notnow=True, in_sec=False):
        console.codes['bg_gray'] = '\x1b[01;40m'
        self.font = FonteZokis()
        self.timing = 5
        self.cls = self.font.cls
        if time:
            self.timing = time
            if not in_sec:
                self.timing = int(self.timing * 60)
            if notnow:
                raw_input("Press Enter")
        else:
            self.in_set_time()

    def in_set_time(self):
        try:
            print(console.colorize('green', 'Enter the time for timing'))
            print(
                console.colorize('blue', '0') +
                console.colorize('green', ' to') +
                console.colorize('blue', ' exit'))
            print(
                console.colorize('green', 'nothing to ') +
                console.colorize('blue', '5 ') +
                console.colorize('green', 'minutes'))
            timing = raw_input(console.colorize('red', '>> '))
        except:
            sys.exit(ERROR)
        if timing == '0':
            sys.exit(EXIT)
        try:
            if timing:
                timing = float(timing)
            else:
                timing = 5
        except:
            sys.exit(ERROR)
        if timing < 0:
            timing *= -1
        self.timing = int(timing * 60)

    def end(self):
        str_fim = ' Time Out! ' * 5
        self.cls()
        if platform.system() == 'Linux':
            os.system("notify-send '%s'" % str_fim)
        else:
            print "%s" % str_fim
        timer.sleep(0.5)
        self.cls()
        self.restart()

    def restart(self):
        self.cls()
        print "%s" % console.reset_color()
        self.cls()

        op = raw_input(
            console.colorize('green', 'Timing again? ') +
            console.colorize('turquoise', '(y/n)') +
            console.colorize('green', ': '))
        if op in ("y", "Y"):
            self.clocking()
        elif op in ("n", "N"):
            print console.reset_color()
            self.cls()
            sys.exit(EXIT)
        else:
            self.restart()

    def get_progress_bar(self, time):
        size = 37
        try:
            rest = int(time * size / self.timing)
        except ZeroDivisionError:
            rest = 0
        progress = size - rest
        return "[%s>%s]" % ("=" * progress, "-" * rest)

    def clocking(self):
        print console.codes['bg_gray']
        for i in range(self.timing, -1, -1):
            self.cls()
            print self.font.text_renderer("%0.2d" % (i / 60) + ":" + "%0.2d" %
                                          (i % 60))
            print self.get_progress_bar(i)
            timer.sleep(1.0)
        self.end()
Пример #6
0
class TermTimer(object):
    def __init__(self, time=None, notnow=True, in_sec=False, times=None):
        console.codes["bg_gray"] = "\x1b[01;40m"
        self.font = FonteZokis()
        self.timing = 5

        if times and times <= 1:
            print (
                "Usage: termtimer.py [options]\n"
                + "\n"
                + "termtimer.py: error: -x option require a value greater than 1"
            )
            sys.exit(ERROR)
        self.times_fix = times and times - 1 or None
        self.times = self.times_fix
        self.cls = self.font.cls
        if time:
            self.timing = time
            if not in_sec:
                self.timing = int(self.timing * 60)
            if notnow:
                raw_input("Press Enter")
        else:
            self.in_set_time()

    def in_set_time(self):
        try:
            print (console.colorize("green", "Enter the time for timing"))
            print (console.colorize("blue", "0") + console.colorize("green", " to") + console.colorize("blue", " exit"))
            print (
                console.colorize("green", "nothing to ")
                + console.colorize("blue", "5 ")
                + console.colorize("green", "minutes")
            )
            timing = raw_input(console.colorize("red", ">> "))
        except:
            sys.exit(ERROR)
        if timing == "0":
            sys.exit(EXIT)
        try:
            if timing:
                timing = float(timing)
            else:
                timing = 5
        except:
            sys.exit(ERROR)
        if timing < 0:
            timing *= -1
        self.timing = int(timing * 60)

    def end(self):
        str_fim = " Time Out! " * 5
        self.cls()
        if platform.system() == "Linux":
            os.system("notify-send '%s'" % str_fim)
        else:
            print "%s" % str_fim
        timer.sleep(0.5)
        self.cls()
        if self.times <= 0:
            self.restart()
        else:
            self.times -= 1
            self.clocking()

    def restart(self):
        self.cls()
        print "%s" % console.reset_color()
        self.cls()
        op = raw_input(
            console.colorize("green", "Timing again? [the options remained the same] ")
            + console.colorize("turquoise", "(y/n)")
            + console.colorize("green", ": ")
        )
        if op in ("y", "Y"):
            if self.times_fix:
                self.times = self.times_fix
            self.clocking()
        elif op in ("n", "N"):
            print console.reset_color()
            self.cls()
            sys.exit(EXIT)
        else:
            self.restart()

    def get_progress_bar(self, time):
        size = 37
        try:
            rest = int(time * size / self.timing)
        except ZeroDivisionError:
            rest = 0
        progress = size - rest
        return "[%s>%s]" % ("=" * progress, "-" * rest)

    def clocking(self):
        print console.codes["bg_gray"]
        for i in range(self.timing, -1, -1):
            self.cls()
            print self.font.text_renderer("%0.2d" % (i / 60) + ":" + "%0.2d" % (i % 60))
            print self.get_progress_bar(i)
            timer.sleep(1.0)
        self.end()
Пример #7
0
class TermTimer(object):
    def __init__(self, time=None, notnow=True, in_sec=False):
        console.codes['bg_gray'] = '\x1b[01;40m'
        self.font = FonteZokis()
        self.timing = 5
        self.cls = self.font.cls
        if time:
            self.timing = time
            if not in_sec:
                self.timing = int(self.timing * 60)
            if notnow:
                raw_input("Press Enter")
        else:
            self.in_set_time()

    def in_set_time(self):
        try:
            print (console.colorize('green', 'Enter the time for timing'))
            print (console.colorize('blue', '0') +
                   console.colorize('green', ' to') +
                   console.colorize('blue', ' exit'))
            print (console.colorize('green', 'nothing to ') +
                   console.colorize('blue', '5 ') +
                   console.colorize('green', 'minutes'))
            timing = raw_input(console.colorize('red', '>> '))
        except:
            sys.exit(ERROR)
        if timing == '0':
            sys.exit(EXIT)
        try:
            if timing:
                timing = float(timing)
            else:
                timing = 5
        except:
            sys.exit(ERROR)
        if timing < 0:
            timing *= -1
        self.timing = int(timing * 60)

    def end(self):
        str_fim = ' Time Out! ' * 5
        self.cls()
        if platform.system() == 'Linux':
            os.system("notify-send '%s'" % str_fim)
        else:
            print "%s" % str_fim
        timer.sleep(0.5)
        self.cls()
        self.restart()

    def restart(self):
        self.cls()
        print "%s" % console.reset_color()
        self.cls()

        op = raw_input(console.colorize('green', 'Timing again? ') +
                       console.colorize('turquoise', '(y/n)') +
                       console.colorize('green', ': '))
        if op in ("y", "Y"):
            self.clocking()
        elif op in ("n", "N"):
            print console.reset_color()
            self.cls()
            sys.exit(EXIT)
        else:
            self.restart()

    def get_progress_bar(self, time):
        size = 37
        try:
            rest = int(time * size / self.timing)
        except ZeroDivisionError:
            rest = 0
        progress = size - rest
        return "[%s>%s]" % ("=" * progress, "-" * rest)

    def clocking(self):
        print console.codes['bg_gray']
        for i in range(self.timing, -1, -1):
            self.cls()
            print self.font.text_renderer("%0.2d" % (i / 60) +
                                          ":" + "%0.2d" % (i % 60))
            print self.get_progress_bar(i)
            timer.sleep(1.0)
        self.end()