mirror of
				https://github.com/mewtek/i2ME-Legacy.git
				synced 2025-06-10 05:30:00 -05:00 
			
		
		
		
	Open CurrentObservations.i2m file asynchronously
This commit is contained in:
		| @@ -59,25 +59,26 @@ async def makeDataFile(): | |||||||
|     header = '<Data type="CurrentObservations">' |     header = '<Data type="CurrentObservations">' | ||||||
|     footer = '</Data>' |     footer = '</Data>' | ||||||
|  |  | ||||||
|     with open("./.temp/CurrentObservations.i2m", 'w') as doc: |     async with aiofiles.open("./.temp/CurrentObservations.i2m", 'w') as doc: | ||||||
|         doc.write(header) |         await doc.write(header) | ||||||
|  |  | ||||||
|     for x, y in zip(tecciId, zipCodes): |     for x, y in zip(tecciId, zipCodes): | ||||||
|         getData(x, y) |         getData(x, y) | ||||||
|          |          | ||||||
|     with open("./.temp/CurrentObservations.i2m", 'a') as end: |     async with aiofiles.open("./.temp/CurrentObservations.i2m", 'a') as end: | ||||||
|         end.write(footer) |         await end.write(footer) | ||||||
|  |  | ||||||
|     dom = xml.dom.minidom.parse("./.temp/CurrentObservations.i2m") |     dom = xml.dom.minidom.parse("./.temp/CurrentObservations.i2m") | ||||||
|     pretty_xml_as_string = dom.toprettyxml(indent = "  ") |     pretty_xml_as_string = dom.toprettyxml(indent = "  ") | ||||||
|  |  | ||||||
|     with open("./.temp/CurrentObservations.i2m", "w") as g: |     async with aiofiles.open("./.temp/CurrentObservations.i2m", "w") as g: | ||||||
|         g.write(pretty_xml_as_string[23:]) |         await g.write(pretty_xml_as_string[23:]) | ||||||
|         g.close() |         await g.close() | ||||||
|  |  | ||||||
|     files = [] |     files = [] | ||||||
|     commands = [] |     commands = [] | ||||||
|  |  | ||||||
|  |     # This causes blocking but there's not really much we can do about it :( | ||||||
|     with open("./.temp/CurrentObservations.i2m", 'rb') as f_in: |     with open("./.temp/CurrentObservations.i2m", 'rb') as f_in: | ||||||
|         with gzip.open("./.temp/CurrentObservations.gz", 'wb') as f_out: |         with gzip.open("./.temp/CurrentObservations.gz", 'wb') as f_out: | ||||||
|             shutil.copyfileobj(f_in, f_out) |             shutil.copyfileobj(f_in, f_out) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user