def update_blob(body_dict): date_format = '%Y-%m-%d %H:%M:%S.%f' b0 = datetime.strptime(body_dict["upload_date"], date_format) b1 = datetime.strptime(body_dict["file_last_update"], date_format) b=db_session.query(Blob).get(body_dict["file_id"]) if b == None: b = Blob(b0, b1, b1) db_session.add(b) db_session.commit() b.id = body_dict["file_id"] b.upload_date = b0 b.last_change = b1 b.last_sync = b1 db_session.commit() else: date_format = '%Y-%m-%d %H:%M:%S.%f' b.upload_date = b0 b.last_change = b1 b.last_sync = b1 db_session.commit() data = {"message_id":body_dict["message_id"], "type":body_dict["type"], "node_id":body_dict["node_id"], "node_ip":body_dict["node_ip"], "node_port":body_dict["node_port"], "file_id":body_dict["file_id"], "upload_date":body_dict["upload_date"], "file_last_update":body_dict["file_last_update"], "file_last_sync":body_dict["file_last_update"]} emit_manager(json.dumps(data))
def update_blob(body_dict): date_format = '%Y-%m-%d %H:%M:%S.%f' b0 = datetime.strptime(body_dict["upload_date"], date_format) b1 = datetime.strptime(body_dict["file_last_update"], date_format) b = db_session.query(Blob).get(body_dict["file_id"]) if b == None: b = Blob(b0, b1, b1) db_session.add(b) db_session.commit() b.id = body_dict["file_id"] b.upload_date = b0 b.last_change = b1 b.last_sync = b1 db_session.commit() else: date_format = '%Y-%m-%d %H:%M:%S.%f' b.upload_date = b0 b.last_change = b1 b.last_sync = b1 db_session.commit() data = { "message_id": body_dict["message_id"], "type": body_dict["type"], "node_id": body_dict["node_id"], "node_ip": body_dict["node_ip"], "node_port": body_dict["node_port"], "file_id": body_dict["file_id"], "upload_date": body_dict["upload_date"], "file_last_update": body_dict["file_last_update"], "file_last_sync": body_dict["file_last_update"] } emit_manager(json.dumps(data))
def add_blob(body_dict): date_format = '%Y-%m-%d %H:%M:%S.%f' b0 = datetime.strptime(body_dict["upload_date"], date_format) b1 = datetime.strptime(body_dict["file_last_update"], date_format) b=db_session.query(Blob).get(body_dict["file_id"]) if b == None: print "Blob did not exist" b = Blob(b0, b1, b1) db_session.add(b) db_session.commit() b.id = body_dict["file_id"] b.upload_date = b0 b.last_change = b1 b.last_sync = b1 db_session.commit() print "add_blob" bs=db_session.query(Blob).order_by(Blob.id) for b_ in bs: print "blob: ",b_.id data = {"message_id":body_dict["message_id"], "type":body_dict["type"], "node_id":body_dict["node_id"], "node_ip":body_dict["node_ip"], "node_port":body_dict["node_port"], "file_id":body_dict["file_id"], "upload_date":body_dict["upload_date"], "file_last_update":body_dict["file_last_update"], "file_last_sync":body_dict["file_last_update"]} emit_manager(json.dumps(data))
def add_blob(body_dict): date_format = '%Y-%m-%d %H:%M:%S.%f' b0 = datetime.strptime(body_dict["upload_date"], date_format) b1 = datetime.strptime(body_dict["file_last_update"], date_format) b = db_session.query(Blob).get(body_dict["file_id"]) if b == None: print "Blob did not exist" b = Blob(b0, b1, b1) db_session.add(b) db_session.commit() b.id = body_dict["file_id"] b.upload_date = b0 b.last_change = b1 b.last_sync = b1 db_session.commit() print "add_blob" bs = db_session.query(Blob).order_by(Blob.id) for b_ in bs: print "blob: ", b_.id data = { "message_id": body_dict["message_id"], "type": body_dict["type"], "node_id": body_dict["node_id"], "node_ip": body_dict["node_ip"], "node_port": body_dict["node_port"], "file_id": body_dict["file_id"], "upload_date": body_dict["upload_date"], "file_last_update": body_dict["file_last_update"], "file_last_sync": body_dict["file_last_update"] } emit_manager(json.dumps(data))