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)
| 48 | |
| 49 | |
| 50 | def 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 | |
| 79 | def install_zip(zippath: str, installpath: str, clean: bool): |
no test coverage detected