class CountdownThread(BasicThread): def __init__(self, milliseconds): BasicThread.__init__(self) self.timer = Timer() self.milliseconds = milliseconds def run(self): global cuber_status self.timer.tick() while self.timer.get_duration() < self.milliseconds \ and super(CountdownThread, self).is_running() \ and cuber_status is Status.INSPECTION: sys.stdout.write('Inspection : %d second(s) \r' % int((self.milliseconds - self.timer.get_duration()) / 1000)) sys.stdout.flush() time.sleep(0.1)
def main(): global cuber_status, threads while True: s = scramble(axis['333'], suffixes['333'], 21) print ' '.join(s) cuber_status = Status.STOPPED get_key() cuber_status = Status.RESOLVING t = Timer() t_resolve = ResolvingThread(t) threads.append(t_resolve) t_resolve.start() get_key() cuber_status = Status.STOPPED threads.pop().join() duration = t.get_duration() print("Duration : %d,%d second(s)" % (duration / 1000, duration % 1000))