def _view_file(path):
'''
Open a file using the default application.
:param path: Path to be opened.
:type path: str
'''
try:
if sys.platform.startswith('darwin'):
r = subprocess.call(('open', path))
if r: raise RuntimeError('Subprocess failed to open')
elif os.name == 'nt':
os.startfile(path)
elif os.name == 'posix':
r = subprocess.call(('xdg-open', path))
if r: raise RuntimeError('Subprocess failed to open')
except:
# If all fails, try to use webbrowser
import webbrowser
webbrowser.open(path)
#=============================================================================
# METADATA
#=============================================================================
评论列表
文章目录