File: //usr/local/bin/dhwp/dhwp/core/curl.py
import re
import sys
import os
from cement import shell
from cement.utils.misc import minimal_logger
LOG = minimal_logger(__name__)
def fetch(url, dest_path):
out, err, code = shell.cmd('which curl')
if code > 0:
LOG.fatal("cannot find curl, please install it first")
sys.exit(1)
command = "curl -s -L -o %s %s" % (dest_path, url)
LOG.debug("fetch command : %s" % command)
out, err, code = shell.cmd(command)
if code > 0:
LOG.fatal("curl failed : (%s) (%s)" % (out, err))
sys.exit(1)