MCPcopy Create free account
hub / github.com/hephaest0s/usbkill / program_present

Function program_present

usbkill/usbkill.py:230–253  ·  view source on GitHub ↗
(program)

Source from the content-addressed store, hash-verified

228 return DeviceCountSet(DEVICE_RE[0].findall(subprocess.check_output("lsusb", shell=True).decode('utf-8').strip()))
229
230def 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
255def load_settings(filename):
256 # Libraries that are only needed in this function:

Callers 1

startup_checksFunction · 0.85

Calls 1

is_exeFunction · 0.85

Tested by

no test coverage detected