def downloadFile(url, name, config, path=None):
    """
    Download a file according to the url and saved it at the path+name
    """
    logger = create_logger(__name__, config)

    if path is None:
        pathTest = "/tmp/"
    else:
        pathTest = path

    if not os.path.exists(path):
        os.makedirs(path)

    pathTest += name

    logger.debug("URL : " + str(url))
    logger.debug("Download path : " + str(pathTest))

    try:
        u = urllib2.urlopen(url)
        file_md5 = make_url_md5(url)

    except urllib2.HTTPError, e:
        logger.error("HTTP error : " + str(e.code))
        return False
Beispiel #2
0
def downloadFile(url, name, config, path=None):
    """
    Download a file according to the url and saved it at the path+name
    """
    logger = create_logger(__name__, config)

    if path is None:
        pathTest = "/tmp/"
    else:
        pathTest = path

    if not os.path.exists(path):
        os.makedirs(path)

    pathTest += name

    logger.debug("URL : "+str(url))
    logger.debug("Download path : "+str(pathTest))

    try:
        u = urllib2.urlopen(url)
        file_md5 = make_url_md5(url)

    except urllib2.HTTPError, e:
        logger.error("HTTP error : "+str(e.code))
        return False
def checkInternetAccess(config):
    """
    Function which instanciate an internet connection and return True if it is established
    """
    logger = create_logger(__name__, config)

    try:
        adress = "https://www.google.com"
        urllib2.urlopen(adress)
        logger.debug("Internet access available")
        return True
    except urllib2.URLError, e:
        logger.warning("Internet connection unavailable")
        logger.warning(e)
        return False
Beispiel #4
0
def checkInternetAccess(config):
    """
    Function which instanciate an internet connection and return True if it is established
    """
    logger = create_logger(__name__, config)

    try:
        adress = "https://www.google.com"
        urllib2.urlopen(adress)
        logger.debug("Internet access available")
        return True
    except urllib2.URLError, e:
        logger.warning("Internet connection unavailable")
        logger.warning(e)
        return False