Every line of 'how to check python path in cmd' code snippets is scanned for vulnerabilities by our powerful machine learning engine that combs millions of open source libraries, ensuring your Python code is secure.
143 def exists_in_path(cmd): 144 # Can't search the path if a directory is specified. 145 assert not os.path.dirname(cmd) 146 path = os.environ.get("PATH", "").split(os.pathsep) 147 extensions = os.environ.get("PATHEXT", "").split(os.pathsep) 148 149 # For each directory in PATH, check if it contains the specified binary. 150 for directory in path: 151 base = os.path.join(directory, cmd) 152 options = [base] + [(base + ext) for ext in extensions] 153 for filename in options: 154 if os.path.exists(filename): 155 return True 156 157 return False
67 def ExistsOnPath(cmd): 68 """Returns whether the given executable exists on PATH.""" 69 paths = os.getenv('PATH').split(os.pathsep) 70 return any(os.path.exists(os.path.join(d, cmd)) for d in paths)
45 def find_cmd(cmd): 46 """Find the full path to a .bat or .exe using the win32api module.""" 47 try: 48 import win32api 49 except ImportError: 50 raise ImportError('you need to have pywin32 installed for this to work') 51 else: 52 try: 53 (path, offest) = win32api.SearchPath(os.environ['PATH'],cmd + '.exe') 54 except: 55 (path, offset) = win32api.SearchPath(os.environ['PATH'],cmd + '.bat') 56 return path
17 def check_py(): 18 19 if os_system() == "Windows": 20 try: 21 py_ver = subprocess.check_output( 22 "py -3 -V").decode('UTF-8').splitlines()[0] 23 print("Script has detected " + py_ver + 24 " version present on the machine.") 25 except: 26 print("Script could not detect Python 3 on the machine.\n" 27 "Go to https://www.python.org/downloads/ page and download latest Python 3 version.") 28 else: 29 try: 30 py_ver = subprocess.check_output(["python3", "-V"]).decode('UTF-8').splitlines()[0] 31 print("Script detected " + py_ver + 32 " version present on the machine.") 33 except: 34 print("Script could not detect Python 3 on the machine.\n" 35 "Go to https://www.python.org/downloads/ page and download latest Python 3 version.")
17 def _checkPath(): 18 path = os.path.dirname(__file__) 19 if path in sys.path: 20 sys.path.remove(path) 21 # make the first one to search for a module 22 sys.path.insert(0, path)
14 def is_python(path): 15 '''Whether the given file is Python.''' 16 if path is not None: 17 return run(['file', path]).find('Python') >= 0 18 else: 19 return False
114 def Which(cmd): 115 """Searches for a binary in the current PATH environment variable. 116 117 Args: 118 cmd(str): the binary to search for. 119 Returns: 120 str: the first found path to a binary with the same name, or None. 121 """ 122 path_list = os.environ.get('PATH', os.defpath).split(os.pathsep) 123 for directory in path_list: 124 name = os.path.join(directory, cmd) 125 if os.path.isdir(name): 126 continue 127 if os.path.exists(name) and os.access(name, os.F_OK | os.X_OK): 128 return name 129 return None
89 def cmd(self): 90 """Return a tuple with the command line to execute.""" 91 92 command = [self.executable, '--verbose', '8'] 93 94 config = sl3_util_find_file( 95 os.path.dirname(self.filename), '.perlcriticrc' 96 ) 97 98 if config: 99 command += ['-p', config] 100 101 return command
136 def path_check(ctx): 137 # rosdeb setup can clobber local ros stuff, so try and detect this 138 path = ctx.env['PATH'] 139 idx = path.find('/usr/bin') 140 if idx < 0: 141 return 142 if os.path.exists('/usr/lib/ros/'): 143 rr_idx = path.find(ctx.ros_root) 144 if rr_idx > -1 and rr_idx > idx: 145 return True
175 def check_executable(configcp): 176 """ 177 A routine to check that the executable is accessible 178 """ 179 try: 180 print '--- Check that the executable ('+ configcp.get("main","executable") +')is present in '+path 181 f = open(configcp("main", "executable"), 'r') 182 f.close() 183 except: 184 print '### Can not find ' + configcp("main", "executable") 185 sys.exit() 186 print '... executable found. Going ahead'