Searches for installed packages from the package list Returns ------- Dictionary with key-value pairs: key = package name, value = command
()
| 60 | return version |
| 61 | |
| 62 | def _find_installed_windows_software(): |
| 63 | """ |
| 64 | Searches for installed packages from the package list |
| 65 | |
| 66 | Returns |
| 67 | ------- |
| 68 | Dictionary with key-value pairs: key = package name, value = command |
| 69 | """ |
| 70 | package_list = ['LTspice', 'KiCad', 'gEDA', 'NGspice'] |
| 71 | commands = {} |
| 72 | search_list = [] |
| 73 | # get list with installed apps |
| 74 | software_list = wi.get_installed_software() |
| 75 | # make a list of apps that we want to search for |
| 76 | for dct in software_list: |
| 77 | name = dct["name"] |
| 78 | if len(name) > 1: |
| 79 | name = name.split()[0] |
| 80 | if name in package_list: |
| 81 | search_list.append(name) |
| 82 | y_n = input("\nDo you have NGspice installed? [y/n] >>> ").lower()[0] |
| 83 | while y_n != 'y' and y_n != 'n': |
| 84 | y_n = input("\nPlease enter 'y' for 'yes' or 'n' for 'no' >>> ").lower()[0] |
| 85 | if y_n == 'y': |
| 86 | search_list.append('NGspice') |
| 87 | else: |
| 88 | commands['ngspice'] = '' |
| 89 | # search for the command to start each app |
| 90 | if len(search_list) > 0: |
| 91 | found_all = False |
| 92 | t_start = time() |
| 93 | time_out = False |
| 94 | print("\nSearching installed software, this will time-out after {} seconds!\n".format(str(TIMEOUT))) |
| 95 | for drive in win32api.GetLogicalDriveStrings().split('\000')[:-1]: |
| 96 | for root, dirs, files in os.walk(drive): |
| 97 | t_now = time() |
| 98 | if t_now - t_start >TIMEOUT: |
| 99 | time_out = True |
| 100 | for name in dirs: |
| 101 | for package in search_list: # Only search for installed software |
| 102 | p_name = package.lower() |
| 103 | if p_name not in commands.keys(): |
| 104 | #print("Searching for installation of:", package) |
| 105 | found = False |
| 106 | if package == 'LTspice': |
| 107 | if re.match('LT(S|s)pice*', name, flags=0): |
| 108 | if os.path.exists(os.path.join(root,name,'XVIIx64.exe')): |
| 109 | print("LTSpice command set as:", os.path.join(root,name,'XVIIx64.exe')) |
| 110 | commands[p_name] = os.path.join(root,name,'XVIIx64.exe') |
| 111 | found = True |
| 112 | elif os.path.exists(os.path.join(root,name,'LTspice.exe')): |
| 113 | print("LTSpice command set as:", os.path.join(root,name,'LTspice.exe')) |
| 114 | commands[p_name] = os.path.join(root,name,'LTspice.exe') |
| 115 | found = True |
| 116 | elif os.path.exists(os.path.join(root,name,'ltspice.exe')): |
| 117 | print("LTSpice command set as:", os.path.join(root,name,'ltspice.exe')) |
| 118 | commands[p_name] = os.path.join(root,name,'ltspice.exe') |
| 119 | found = True |
no test coverage detected