remove freeBusyPath dead code

This commit is contained in:
petrucci4prez 2017-05-31 00:27:40 -04:00
parent 2e45edad1e
commit e801396fff
1 changed files with 0 additions and 33 deletions

View File

@ -59,39 +59,6 @@ def waitForPath(path, logger=None, timeout=30):
logger.error('Could not find %s after %s seconds', path, timeout)
raise SystemExit
# we shouldn't need this if we are disabling the usb hub globally and nuking any past connections
#~ def freeBusyPath(path, logger=None):
#~ # check if any other processes are using file path
#~ # if found, politely ask them to exit, else nuke them
#~ # NOTE: fuser sends diagnostic info (eg filenames and modes...which we
#~ # don't want) to stderr. This is weird, but let's me route to /dev/null
#~ # so I don't have to parse it later
#~ try:
#~ stdout = check_output(['fuser', path], universal_newlines=True, stderr=DEVNULL)
#~ except CalledProcessError:
#~ logger.debug('%s not in use. Execution may continue', path)
#~ else:
#~ # assume stdout is one PID first
#~ try:
#~ processes = [psutil.Process(int(stdout))]
#~ # else assume we have multiple PIDs separated by arbitrary space
#~ except ValueError:
#~ processes = [psutil.Process(int(s)) for s in stdout.split()]
#~ for p in processes:
#~ if logger:
#~ logger.warning('%s in use by PID %s. Sending SIGTERM', path, p.pid)
#~ p.terminate()
#~ dead, alive = psutil.wait_procs(processes, timeout=10)
#~ for p in alive:
#~ if logger:
#~ logger.warning('Failed to terminate PID %s. Sending SIGKILL', p.pid)
#~ p.kill()
# crude way to reset USB device, pretty rough but works
def resetUSBDevice(device):
devpath = os.path.join('/sys/bus/usb/devices/' + device + '/authorized')