def on_demand_process(): input_data = input("\n\n" + "="*20 + "\nThe On Demand Mode:\nType the name of the project, the version (if you have one) and if it's a Nuget Package or a dll/exe\nIf the package \ in the version exists it will be downloaded, if no version is given all versions will be downloaded\nExamples: \ project-1.1.8.nupkg - project.2.2.0.dll - project-1.3.2.exe - project\nInput:\n") start = time.time() inst = c.Library(input_data,"No Hash") needed_versions = inst.get_needed_downloads() if not needed_versions: print("This Package has no versions in Nuget") else: print(inst.clean_package_name, needed_versions) for version in needed_versions: f.download_package(inst.pure_name,version) downloaded_package_name = inst.pure_name + '.' + version if inst.is_package: # calculate the .nupkg files hash print(downloaded_package_name, f.hash_calculator(v.default_path_to + downloaded_package_name + v.package_suffix)) else: # extract and calculate + the .nupkg hash f.extract_package(downloaded_package_name + v.package_suffix) print (downloaded_package_name, f.hash_calculate_directory(downloaded_package_name), "Package Hash-" + f.hash_calculator(v.default_path_to + downloaded_package_name + v.package_suffix)) end = time.time() print('\nExecution time: ' + str(end - start)) on_demand_process()
print(message) continue # to the next iteration (file,hash) tuple for version in needed_versions: found_match_flag = False f.download_package(inst.pure_name, version) downloaded_package_name = inst.pure_name + '.' + version print("\n" + downloaded_package_name + '------ Downloaded. Hashes:') if not downloaded_package_name in hash_results: if inst.is_package: # calculate the .nupkg files hash hash_results[downloaded_package_name] = [ f.hash_calculator(v.default_path_to + downloaded_package_name + v.package_suffix) ] else: # extract and calculate f.extract_package(downloaded_package_name + v.package_suffix) hash_results[ downloaded_package_name] = f.hash_calculate_directory( downloaded_package_name) + [ f.hash_calculator(v.default_path_to + downloaded_package_name + v.package_suffix) ] print(hash_results[downloaded_package_name]) for package in hash_results: if inst.sha_1.lower() in hash_results[package]: message = "Match found in: " + package found_match_flag = True if found_match_flag: print(message) break # to the next iteration (file,hash) tuple