Exemplo n.º 1
0
    def run(self, test=False):
        try:
            log.info("start".center(100, '-'))
            self.before_work()

            self.init_server()
            run_server()
            self.jobs_report()

            if test:
                embed()
            else:
                interval_time = 1*60
                while not self._stop_event.is_set():
                    try:
                        self.report(status=True, force=True)
                    except Exception as e:
                        log.warning(str(e))
                    time.sleep(interval_time)

        except Exception as e:
            log.error("exit unexpect: %s" % str(traceback.format_exc()))
Exemplo n.º 2
0
                ["description for this printer", pexpect.TIMEOUT])
            if ind == 0:
                time.sleep(0.1)
                child.sendline()
            else:
                raise PrtSetupError("error when add description")

            ind = child.expect(
                ["information or notes for this printer", pexpect.TIMEOUT])
            if ind == 0:
                time.sleep(0.1)
                child.sendline()
            else:
                raise PrtSetupError("error when add information")

            ind = child.expect(["print a test page", pexpect.TIMEOUT])
            if ind == 0:
                time.sleep(0.1)
                child.sendline("y")
            else:
                raise PrtSetupError("error when choose ppd")

            child.expect([pexpect.EOF, pexpect.TIMEOUT])
        finally:
            child.logfile.close()


if __name__ == "__main__":
    prt = HpPrinter()
    embed()