Ejemplo n.º 1
0
def main():
    args = parse_args()
    log = logging.getLogger("nuget-meta")
    logging.basicConfig(level=logging.INFO)
    host, port = args.beanstalkd.split(":")
    client = BeanstalkClient(host, int(port), auto_decode=True)
    try:
        with open(args.output, "a") as fout:
            for job in client.reserve_iter():
                try:
                    execute_job(job.job_data, args.extractor, args.tmp, fout,
                                log)
                except Exception:
                    log.exception(job)
                    try:
                        client.bury_job(job.job_id)
                    except Exception as e:
                        log.error("bury %s: %s: %s", job.job_data,
                                  type(e).__name__, e)
                    continue
                try:
                    client.delete_job(job.job_id)
                except Exception as e:
                    log.error("delete %s: %s: %s", job.job_data,
                              type(e).__name__, e)
    finally:
        shutil.rmtree(os.path.join(args.tmp, str(os.getpid())),
                      ignore_errors=True)
Ejemplo n.º 2
0
def delete_ready(server, port, tube, jobCounter):
    client = BeanstalkClient(server, port)
    client.watch(tube)
    client.use(tube)

    while True:
        try:
            for job in client.reserve_iter():
                client.delete_job(job.job_id)
                jobCounter.increment_ready()
            processed = jobCounter.abs()
            time.sleep(1)
            if processed == jobCounter.abs():
                break
        except BeanstalkError:
            break
        except KeyboardInterrupt:
            break
Ejemplo n.º 3
0
                                                  "@", "_").replace(".", "_")


def run_ssh_command(command):
    print("    - running " + command, end="", flush=True)
    stdin, stdout, stderr = ssh.exec_command(command)
    for line in stdout:
        print(" - " + line.strip('\n'))
    for line in stderr:
        print(" - ERR " + line.strip('\n'))


print("Starting main loop")

while True:
    for job in queue.reserve_iter():
        content = json.loads(job.job_data)

        operation = content["operation"]
        args = content["args"]

        # if operation == "refresh_single_zone":
        #     print("refreshing " + args["zone"])
        #
        #     zone = db["zones"].find_one({"zone": args["zone"]})
        #
        #     if not args or not args.get("node"):
        #         _query = {}
        #     else:
        #         if args["node"] == "all":
        #             _query = {}