cbg-ethz / shorah

Repo for the software suite ShoRAH (Short Reads Assembly into Haplotypes)
GNU General Public License v3.0
41 stars 14 forks source link

Search for executables in PATH #51

Closed ozagordi closed 6 years ago

ozagordi commented 6 years ago

Added a mechanism in python code that searches for executables in the whole PATH locations, if they are not in src/shorah/bin. This works for installations obtained with pip install, and should also work with autotools.

Minor modifications include proper logging arguments and use of double quotes in docstrings (not yet PEP257 compliant).

DrYak commented 6 years ago

Your handcrafted code does seem correct, but I would have gone for something more relying on standard stuff.

The python 3.3+ standard library does provides shutil.which which seems to replicate the shell's which which exactly does that - find from where this command could be executed, had it been typed on the command line. (Inspired by this stackoverflow )

The point being trying to not get blown in the face, because the user is running this on their desktop/workstation, on a Mac OS X machine (which tend to use the user's fullname as $HOME, so be ready for full Unicode paths) with some weird locale.

(I'm of Bulgarian origin, my language is written in Cyrillic. Half of my life has been fighting failed Windows-1251 <=> ISO/IEC_8859-5 <=> UTF-8 <=> Latin-1 (Wait, whaa....?!?) conversions on badly implemented webforms just to get the correct delivery address to mail stuff to my family)

ozagordi commented 6 years ago

Ok, let me rewrite with shutil.which. (I don't usually stop at the first solution, especially when it's old, but the most recent comments did not point to the newer solution below).

DrYak commented 6 years ago

Here's my suggestion. Fill free to pick it up.

DrYak commented 6 years ago

Looks okay to me, feel free to merge if it passes your testing.