| @@ 488-506 (lines=19) @@ | ||
| 485 | """ |
|
| 486 | return not (os.path.isdir(os.path.join(workingdir, file)) or file.endswith(bbconstants.SUPPS + extras)) |
|
| 487 | ||
| 488 | ||
| 489 | def verifier(ldir, kwargs=None, selective=False): |
|
| 490 | """ |
|
| 491 | For all files in a directory, perform various hash/checksum functions. |
|
| 492 | Take dict to define hashes, write output to a/individual .cksum file(s). |
|
| 493 | ||
| 494 | :param ldir: Path containing files you wish to verify. |
|
| 495 | :type ldir: str |
|
| 496 | ||
| 497 | :param kwargs: Values. Refer to `:func:verifier_config_loader`. |
|
| 498 | :type kwargs: dict |
|
| 499 | """ |
|
| 500 | if kwargs is None: |
|
| 501 | kwargs = verifier_config_loader() |
|
| 502 | exts = (".txt",) if selective else () |
|
| 503 | files = [os.path.join(ldir, file) for file in os.listdir(ldir) if filefilter(file, ldir, exts)] |
|
| 504 | with concurrent.futures.ThreadPoolExecutor(max_workers=utilities.workers(files)) as xec: |
|
| 505 | for file in files: |
|
| 506 | print("HASHING:", os.path.basename(file)) |
|
| 507 | basename = file + ".cksum" |
|
| 508 | targetname = os.path.join(ldir, basename) |
|
| 509 | try: |
|
| @@ 668-685 (lines=18) @@ | ||
| 665 | :type ldir: str |
|
| 666 | """ |
|
| 667 | if not is_windows(): |
|
| 668 | pass |
|
| 669 | else: |
|
| 670 | files = [os.path.join(ldir, file) for file in os.listdir(ldir) if not os.path.isdir(file)] |
|
| 671 | brokens = [] |
|
| 672 | for file in files: |
|
| 673 | fname = os.path.basename(file) |
|
| 674 | if fname.endswith(".exe") and fname.startswith(bbconstants.PREFIXES): |
|
| 675 | print("TESTING: {0}".format(fname)) |
|
| 676 | if not verify_loader_integrity(file): |
|
| 677 | brokens.append(fname) |
|
| 678 | return brokens |
|
| 679 | ||
| 680 | ||
| 681 | def workers(input_data): |
|
| 682 | """ |
|
| 683 | Count number of CPU workers, smaller of number of threads and length of data. |
|
| 684 | ||
| 685 | :param input_data: Input data, some iterable. |
|
| 686 | :type input_data: list |
|
| 687 | """ |
|
| 688 | runners = len(input_data) if len(input_data) < compat.enum_cpus() else compat.enum_cpus() |
|