Scan the list of paths at `location` and return the results as an iterable of JSON strings. If `deserialize` is True the iterable contains a python data instead. Each location is scanned independently.
(locations, deserialize=False, scancode_root_dir=None)
| 25 | |
| 26 | |
| 27 | def scan(locations, deserialize=False, scancode_root_dir=None): |
| 28 | """ |
| 29 | Scan the list of paths at `location` and return the results as an iterable |
| 30 | of JSON strings. If `deserialize` is True the iterable contains a python data |
| 31 | instead. |
| 32 | Each location is scanned independently. |
| 33 | """ |
| 34 | if not scancode_root_dir: |
| 35 | scancode_root_dir = abspath(normpath(__file__)) |
| 36 | scancode_root_dir = dirname(dirname(dirname(scancode_root_dir))) |
| 37 | python2 = join(scancode_root_dir, "venv", "bin", "python") |
| 38 | spec = "popen//python={python2}".format(**locals()) |
| 39 | gateway = execnet.makegateway(spec) # NOQA |
| 40 | channel = gateway.remote_exec(scanserv) |
| 41 | |
| 42 | for location in locations: |
| 43 | # build a mapping of options to use for this scan |
| 44 | scan_kwargs = dict( |
| 45 | location=location, |
| 46 | license=True, |
| 47 | license_text=True, |
| 48 | copyright=True, |
| 49 | info=True, |
| 50 | processes=0, |
| 51 | ) |
| 52 | |
| 53 | channel.send(scan_kwargs) # execute func-call remotely |
| 54 | results = channel.receive() |
| 55 | if deserialize: |
| 56 | results = json.loads(results) |
| 57 | yield results |
| 58 | |
| 59 | |
| 60 | if __name__ == "__main__": |
no test coverage detected