Commit 1d2c573f authored by Thuban's avatar Thuban

add unix whereis

parent 259adfb2
......@@ -703,7 +703,7 @@ class DontPanic:'/localvideo/<filename:path>')
def open_in_external_player(filename):
file_path = os.path.join(self.tmp, filename)
if sys.platform.startswith('linux'):
if which("xdg-open"):
import subprocess
subprocess.Popen(["xdg-open", file_path])
......@@ -266,6 +266,26 @@ def get_free_port():
return port
def which(program):
def is_exe(fpath):
return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
fpath, fname = os.path.split(program)
if fpath:
if is_exe(program):
return program
for path in os.environ["PATH"].split(os.pathsep):
path = path.strip('"')
exe_file = os.path.join(path, program)
if is_exe(exe_file):
return exe_file
return None
def setup_logging(verbose):
if verbose == 1:
level = logging.INFO
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment