Changeset 86588 in vbox for trunk/src/VBox/ValidationKit/common
- Timestamp:
- Oct 15, 2020 10:50:24 AM (4 years ago)
- svn:sync-xref-src-repo-rev:
- 140952
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/ValidationKit/common/utils.py
r84568 r86588 832 832 833 833 834 def whichProgram(sName, sPath = None): 835 """ 836 Works similar to the 'which' utility on unix. 837 838 Returns path to the given program if found. 839 Returns None if not found. 840 """ 841 sHost = getHostOs(); 842 sSep = ';' if sHost in [ 'win', 'os2' ] else ':'; 843 844 if sPath is None: 845 if sHost == 'win': 846 sPath = os.environ.get('Path', None); 847 else: 848 sPath = os.environ.get('PATH', None); 849 if sPath is None: 850 return None; 851 852 for sDir in sPath.split(sSep): 853 if sDir.strip() != '': 854 sTest = os.path.abspath(os.path.join(sDir, sName)); 855 else: 856 sTest = os.path.abspath(sName); 857 if os.path.exists(sTest): 858 return sTest; 859 860 return None; 861 834 862 # 835 863 # Generic process stuff.
Note:
See TracChangeset
for help on using the changeset viewer.