329 elements[:] = sorted(elements,key=lambda n: int(n.get('begin'))) |
329 elements[:] = sorted(elements,key=lambda n: int(n.get('begin'))) |
330 |
330 |
331 |
331 |
332 |
332 |
333 |
333 |
334 output_data = etree.tostring(root, encoding="utf-8", method="xml", pretty_print=True, xml_declaration=True) |
334 output_data = etree.tostring(root, encoding="utf-8", method="xml", pretty_print=False, xml_declaration=True) |
335 |
335 |
336 if content_file and content_file.find("http") == 0: |
336 if content_file and content_file.find("http") == 0: |
337 |
337 |
338 project["ldt"] = output_data |
338 project["ldt"] = output_data |
339 body = anyjson.serialize(project) |
339 body = anyjson.serialize(project) |
340 get_logger().debug("write http " + content_file) #@UndefinedVariable |
340 get_logger().debug("write http " + content_file) #@UndefinedVariable |
341 get_logger().debug("write http " + repr(body)) #@UndefinedVariable |
341 get_logger().debug("write http " + repr(body)) #@UndefinedVariable |
342 h = httplib2.Http() |
342 h = httplib2.Http() |
343 resp, content = h.request(content_file, "PUT", headers={'content-type':'application/json'}, body=body) |
343 resp, content = h.request(content_file, "PUT", headers={'content-type':'application/json'}, body=body) |
344 get_logger().debug("write http " + repr(resp) + " content " + content) #@UndefinedVariable |
344 get_logger().debug("write http " + repr(resp) + " content " + content) #@UndefinedVariable |
|
345 if resp.status != 200: |
|
346 get_logger().error("Error http " + repr(resp) + " content " + content) #@UndefinedVariable |
|
347 raise Exception("Error writing content : %d : %s"%(resp.status, resp.reason)) |
345 else: |
348 else: |
346 if content_file and os.path.exists(content_file): |
349 if content_file and os.path.exists(content_file): |
347 dest_file_name = content_file |
350 dest_file_name = content_file |
348 else: |
351 else: |
349 dest_file_name = options.filename |
352 dest_file_name = options.filename |