File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change @@ -350,6 +350,13 @@ def all() -> List['WarpContainer']:
350350 warpcore .BNWARPFreeContainerList (containers , count .value )
351351 return result
352352
353+ @staticmethod
354+ def by_name (name : str ) -> Optional ['WarpContainer' ]:
355+ for container in WarpContainer :
356+ if container .name == name :
357+ return container
358+ return None
359+
353360 @property
354361 def name (self ) -> str :
355362 return warpcore .BNWARPContainerGetName (self .handle )
Original file line number Diff line number Diff line change @@ -14,12 +14,15 @@ def process_binary(input_file: str, output_dir: str) -> None:
1414 if not bv :
1515 return
1616
17- # Sources exist only in containers, so we will just pull off the first available container.
18- # In the future we might make container construction available to the API.
19- container = WarpContainer .all ()[ 0 ]
17+ # For the sake of this example we are going to assume the container "User"
18+ # is available, in the future we might want to make containers constructable
19+ container = WarpContainer .by_name ( "User" )
2020 output_file = output_dir / f"{ input_path .stem } _analysis.warp"
2121 # Add the source so we can add functions to it and then commit it (write to disk)
2222 source = container .add_source (str (output_file ))
23+ if source is None :
24+ print (f"Failed to create source { str (output_file )} " )
25+ return
2326
2427 # NOTE: You probably want to pull the platform from the function, but for this example it's fine.
2528 target = WarpTarget (bv .platform )
@@ -30,6 +33,7 @@ def process_binary(input_file: str, output_dir: str) -> None:
3033 # Actually write the warp file to disk.
3134 container .commit_source (source )
3235 bv .file .close ()
36+ print (f"committed { len (functions_to_warp )} functions to { output_file } " )
3337
3438if __name__ == "__main__" :
3539 if len (sys .argv ) != 3 :
You can’t perform that action at this time.
0 commit comments