You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					60 lines
				
				1.8 KiB
			
		
		
			
		
	
	
					60 lines
				
				1.8 KiB
			| 
											2 years ago
										 | #!/usr/bin/env python3
 | ||
| 
											2 years ago
										 | import argparse
 | ||
|  | import json
 | ||
| 
											2 years ago
										 | import os
 | ||
| 
											2 years ago
										 | import pathlib
 | ||
|  | import tempfile
 | ||
| 
											2 years ago
										 | import time
 | ||
| 
											2 years ago
										 | from openpilot.common.basedir import BASEDIR
 | ||
| 
											2 years ago
										 | from openpilot.system.hardware.tici.agnos import StreamingDecompressor, unsparsify, noop, AGNOS_MANIFEST_FILE
 | ||
| 
											2 years ago
										 | from openpilot.system.updated.casync.common import create_casync_from_file
 | ||
| 
											2 years ago
										 | from release.package_casync_build import upload_casync_release
 | ||
| 
											2 years ago
										 | 
 | ||
|  | 
 | ||
|  | 
 | ||
|  | if __name__ == "__main__":
 | ||
|  |   parser = argparse.ArgumentParser(description="creates a casync release")
 | ||
|  |   parser.add_argument("--manifest", type=str, help="json manifest to create agnos release from", \
 | ||
| 
											2 years ago
										 |                         default=str(pathlib.Path(BASEDIR) / AGNOS_MANIFEST_FILE))
 | ||
| 
											2 years ago
										 |   args = parser.parse_args()
 | ||
|  | 
 | ||
| 
											2 years ago
										 |   manifest_file = pathlib.Path(args.manifest)
 | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 |   with tempfile.TemporaryDirectory() as temp_dir:
 | ||
|  |     working_dir = pathlib.Path(temp_dir)
 | ||
|  |     casync_dir = working_dir / "casync"
 | ||
|  |     casync_dir.mkdir()
 | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 |     agnos_casync_dir = casync_dir / "agnos"
 | ||
|  |     agnos_casync_dir.mkdir()
 | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 |     entry_path = working_dir / "entry"
 | ||
| 
											2 years ago
										 | 
 | ||
|  |     with open(manifest_file) as f:
 | ||
|  |       manifest = json.load(f)
 | ||
|  | 
 | ||
|  |     for entry in manifest:
 | ||
|  |       print(f"creating casync agnos build from {entry}")
 | ||
| 
											2 years ago
										 |       start = time.monotonic()
 | ||
| 
											2 years ago
										 |       downloader = StreamingDecompressor(entry['url'])
 | ||
|  | 
 | ||
| 
											2 years ago
										 |       parse_func = unsparsify if entry['sparse'] else noop
 | ||
|  | 
 | ||
|  |       parsed_chunks = parse_func(downloader)
 | ||
| 
											2 years ago
										 | 
 | ||
|  |       size = entry["size"]
 | ||
|  | 
 | ||
|  |       cur = 0
 | ||
|  |       with open(entry_path, "wb") as f:
 | ||
| 
											2 years ago
										 |         for chunk in parsed_chunks:
 | ||
|  |           f.write(chunk)
 | ||
| 
											2 years ago
										 | 
 | ||
| 
											2 years ago
										 |       print(f"downloaded in {time.monotonic() - start}")
 | ||
|  | 
 | ||
|  |       start = time.monotonic()
 | ||
| 
											2 years ago
										 |       agnos_filename = os.path.basename(entry["url"]).split(".")[0]
 | ||
| 
											2 years ago
										 |       create_casync_from_file(entry_path, agnos_casync_dir, agnos_filename)
 | ||
| 
											2 years ago
										 |       print(f"created casnc in {time.monotonic() - start}")
 | ||
| 
											2 years ago
										 | 
 | ||
|  |     upload_casync_release(casync_dir)
 |