Esempio n. 1
0
 def read(self):
     prompt = self.prompt
     if input_queue:
         self._synth_input()
     else:
         clear_count = max(len(prompt) - len(self.fail_prompt), 0)
         lower = prompt[clear_count:]
         upper = prompt[:clear_count]
         if not terminal.locked:
             terminal.lock()
         if self._remove_text:
             terminal.push_lock()
         terminal.push(upper)
         while not self._read(lower):
             lower = self.fail_prompt
         if self._remove_text:
             terminal.pop_lock()
         if self._newline:
             terminal.push()
     return self.value
Esempio n. 2
0
File: tools.py Progetto: tek/pytek
def copy_progress(source, dest):
    import shutil
    import signal

    old_handler = signal.getsignal(signal.SIGINT)
    dest_file = os.path.join(dest, os.path.basename(source)) if os.path.isdir(dest) else dest
    progress = ProgressPrinter(source, dest_file)

    def interrupt(signum, frame):
        progress.stop()
        signal(signal.SIGINT, old_handler)
        msg = "Interrupted by signal {}.".format(signum)
        log.warn()
        log.warn(msg)

    signal.signal(signal.SIGINT, interrupt)
    terminal.lock()
    terminal.push_lock()
    progress.start()
    shutil.copy(source, dest)
    progress.finish()
    terminal.pop_lock()