(program)
| 228 | return DeviceCountSet(DEVICE_RE[0].findall(subprocess.check_output("lsusb", shell=True).decode('utf-8').strip())) |
| 229 | |
| 230 | def program_present(program): |
| 231 | if sys.version_info[0] == 3: |
| 232 | # Python3 |
| 233 | from shutil import which |
| 234 | return which(program) != None |
| 235 | |
| 236 | else: |
| 237 | """ |
| 238 | Test if an executable exist in Python2 |
| 239 | -> http://stackoverflow.com/a/377028 |
| 240 | """ |
| 241 | def is_exe(fpath): |
| 242 | return os.path.isfile(fpath) and os.access(fpath, os.X_OK) |
| 243 | |
| 244 | fpath, fname = os.path.split(program) |
| 245 | if fpath and is_exe(program): |
| 246 | return True |
| 247 | else: |
| 248 | for path in os.environ["PATH"].split(os.pathsep): |
| 249 | path = path.strip('"') |
| 250 | exe_file = os.path.join(path, program) |
| 251 | if is_exe(exe_file): |
| 252 | return True |
| 253 | return False |
| 254 | |
| 255 | def load_settings(filename): |
| 256 | # Libraries that are only needed in this function: |
no test coverage detected