Commit 146aa4cd authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

fall back to wget when curl is not available

parent 2f3747eb
Loading
Loading
Loading
Loading
+22 −1
Original line number Diff line number Diff line
@@ -60,8 +60,29 @@ def error(str=None):
def fullpath(path):
  return os.path.abspath(os.path.expanduser(path))

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
  else:
    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 geturl(url,fname):
  if which('curl') != None:
    cmd = 'curl -L -o "%s" %s' % (fname,url)
  elif which('wget') != None:
    cmd = 'wget -O "%s" %s' % (fname,url)
  else: error("cannot find 'wget' or 'curl' to download source code")
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  return txt

+22 −1
Original line number Diff line number Diff line
@@ -47,8 +47,29 @@ def error(str=None):
def fullpath(path):
  return os.path.abspath(os.path.expanduser(path))

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
  else:
    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 geturl(url,fname):
  if which('curl') != None:
    cmd = 'curl -L -o "%s" %s' % (fname,url)
  elif which('wget') != None:
    cmd = 'wget -O "%s" %s' % (fname,url)
  else: error("cannot find 'wget' or 'curl' to download source code")
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  return txt

+22 −1
Original line number Diff line number Diff line
@@ -47,8 +47,29 @@ def error(str=None):
def fullpath(path):
  return os.path.abspath(os.path.expanduser(path))

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
  else:
    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 geturl(url,fname):
  if which('curl') != None:
    cmd = 'curl -L -o "%s" %s' % (fname,url)
  elif which('wget') != None:
    cmd = 'wget -O "%s" %s' % (fname,url)
  else: error("cannot find 'wget' or 'curl' to download source code")
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  return txt

+22 −1
Original line number Diff line number Diff line
@@ -46,8 +46,29 @@ def error(str=None):
def fullpath(path):
  return os.path.abspath(os.path.expanduser(path))

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
  else:
    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 geturl(url,fname):
  if which('curl') != None:
    cmd = 'curl -L -o "%s" %s' % (fname,url)
  elif which('wget') != None:
    cmd = 'wget -O "%s" %s' % (fname,url)
  else: error("cannot find 'wget' or 'curl' to download source code")
  txt = subprocess.check_output(cmd,stderr=subprocess.STDOUT,shell=True)
  return txt