?? executable.py
字號:
## executable.py -- Utilities for dealing with external executables#import os, stringdef exists(file): """Is this an executable file?""" return os.path.isfile(file) and os.access(file, os.X_OK)def find(file, dirs=None): """Search for an executable in a given list of directories. If no directories are given, search according to the PATH environment variable.""" if not dirs: dirs = string.split(os.environ["PATH"], os.pathsep) for path in dirs: if is_executable(os.path.join(path, file)): return os.path.join(path, file) elif is_executable(os.path.join(path, "%s.exe" % file)): return os.path.join(path, "%s.exe" % file) return Nonedef output(cmd, strip=None): """Run a command and collect all output""" try: # Python 2.x stdin, stdout = os.popen4(cmd) assert(not stdin.close()) except AttributeError: try: # Python 1.x on Unix import posix stdout = posix.popen('%s 2>&1' % cmd) except ImportError: # Python 1.x on Windows (no cygwin) # There's no easy way to collect output from stderr, so we'll # just collect stdout. stdout = os.popen(cmd) output = stdout.read() assert(not stdout.close()) if strip: return string.strip(output) else: return outputdef run(cmd): """Run a command""" exit_code = os.system(cmd) assert(not exit_code)
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -