Esempio n. 1
0
def gotConnection(conn, authentication):
    config = process_config(read_config(settings.gitosis_config))
    QUEUE = random_queue()

    yield conn.start(authentication)
    chan = yield conn.channel(1)
    yield chan.channel_open()

    # Initialize the MQ state
    yield chan.queue_declare(queue=QUEUE, durable=False, exclusive=False, auto_delete=True)
    yield chan.exchange_declare(exchange=config['exchange'], type="fanout",
                                durable=True, auto_delete=False)
    yield chan.queue_bind(queue=QUEUE, exchange=config['exchange'])
    yield chan.basic_consume(queue=QUEUE, no_ack=True, consumer_tag="smart")

    queue = yield conn.queue("smart")
    recv_callback = callback_wrapper(config['projects_dir'],
                                     config['git_user'],
                                     config['git_server'])
    yield (queue.get().addCallback(recv_callback, chan, queue))


    # This is all about closing the connection nicely
    yield chan.basic_cancel("smart")
    yield chan.channel_close()
    chan0 = yield conn.channel(0)
    yield chan0.connection_close()

    reactor.stop()
Esempio n. 2
0
def gotConnection(conn, authentication, body):
    config = process_config(read_config(settings.gitosis_config))

    yield conn.start(authentication)
    chan = yield conn.channel(1)
    yield chan.channel_open()

    msg = Content(body)
    msg["delivery mode"] = 2
    chan.basic_publish(exchange=config['exchange'], content=msg)
    
    yield chan.channel_close()

    chan0 = yield conn.channel(0)
    yield chan0.connection_close()
    
    reactor.stop()
Esempio n. 3
0
    yield chan.channel_open()

    msg = Content(body)
    msg["delivery mode"] = 2
    chan.basic_publish(exchange=config['exchange'], content=msg)
    
    yield chan.channel_close()

    chan0 = yield conn.channel(0)
    yield chan0.connection_close()
    
    reactor.stop()
    
if __name__ == "__main__":
    import sys
    if len(sys.argv) != 3:
        print "%s path_to_spec content" % sys.argv[0]
        sys.exit(1)

    config = process_config(read_config(settings.gitosis_config))
    spec = txamqp.spec.load(sys.argv[1])
    authentication = {"LOGIN": config['user_id'], "PASSWORD": config['password']}

    delegate = TwistedDelegate()
    d = ClientCreator(reactor, AMQClient, delegate=delegate, vhost="/",
        spec=spec).connectTCP(config['host'], config['port'])

    d.addCallback(gotConnection, authentication, sys.argv[2])

    reactor.run()
def count_with_bedtools(gff, bam, param_dict):
    count_file = bam.split(".bam")[0] + "_counts.txt"
    bedtools_bin = param_dict["bin"]
    strand = param_dict["strand"]
    script = "{} coverage -a {} -b {} {}>{}".format(bedtools_bin, gff, bam,
                                                    strand, count_file)
    return script


# def count_with_bedtools_local(gff, bam, count_file, param_dict):
#
#     strand = True if param_dict["strand"] == "-s" else False
#     feat = param_dict["feat"]
#     a = pybedtools.BedTool(gff)
#     b = pybedtools.BedTool(bam)
#     counts = a.coverage(b, counts=True, s=strand)
#     with open(count_file, "w") as fo:
#         for f in counts.features():
#             if feat not in str(f):
#                 continue
#             else:
#                 identifier = str(f[-2].split("{}=".format(feat))[1].split(";")[0].strip())
#                 fo.write("{},{}\n".format(identifier, f[-1]))
#
#     return count_file

if __name__ == "__main__":
    args = get_args().parse_args()
    param_dict = helpers.process_config(args.config)["bedtools"]
    helpers.process_bedtools_count_output(args.input, args.output, param_dict)