MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / download_headless

Function download_headless

scripts/download_headless.py:50–76  ·  view source on GitHub ↗

Downloads the headless Binary Ninja installation binaries. :param serial: Serial number for verification :type serial: str :param output_path: path to write the binaries to, defaults to None :type output_path: str, optional :param dev: set to True if you wish to download 'dev' branch, defaults

(serial: str, output_path: str = None, dev: bool = False)

Source from the content-addressed store, hash-verified

48
49
50def download_headless(serial: str, output_path: str = None, dev: bool = False) -> str:
51 """Downloads the headless Binary Ninja installation binaries.
52
53 :param serial: Serial number for verification
54 :type serial: str
55 :param output_path: path to write the binaries to, defaults to None
56 :type output_path: str, optional
57 :param dev: set to True if you wish to download 'dev' branch, defaults to False
58 :type dev: bool, optional
59 :raises DownloadException: On failure to download the requested binaries.
60 """
61 r = requests.get(url, {'serial': serial, 'dev': str(dev).lower()})
62 results = json.loads(r.text)
63 if not results['ok']:
64 message = results.get('message', 'No additional information available.')
65 raise DownloadException(f'Download failed: {message}')
66
67 req_url = results['url']
68 content = requests.get(req_url, allow_redirects=True)
69 if len(content.content) < min_download:
70 raise DownloadException(f'Error downloading from {req_url}')
71
72 if output_path is None:
73 output_path = os.path.basename(urllib.parse.urlparse(req_url).path)
74 with open(output_path, 'wb') as f:
75 f.write(content.content)
76 return output_path
77
78
79def install_zip(zippath: str, installpath: str, clean: bool):

Callers 1

download_and_installFunction · 0.85

Calls 3

DownloadExceptionClass · 0.70
getMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected