Ejemplo n.º 1
0
def download_server(server_name):
    logger.info("streamondemand.core.updater download_server('" + server_name + "')")

    import servertools
    remote_server_url, remote_version_url = servertools.get_server_remote_url(server_name)
    local_server_path, local_version_path, local_compiled_path = servertools.get_server_local_path(server_name)

    # Descarga el canal
    try:
        updated_server_data = scrapertools.cachePage(remote_server_url)
        outfile = open(local_server_path, "wb")
        outfile.write(updated_server_data)
        outfile.flush()
        outfile.close()
        logger.info("streamondemand.core.updater Grabado a " + local_server_path)
    except:
        import traceback
        logger.info(traceback.format_exc())

    # Descarga la version (puede no estar)
    try:
        updated_version_data = scrapertools.cachePage(remote_version_url)
        outfile = open(local_version_path, "w")
        outfile.write(updated_version_data)
        outfile.flush()
        outfile.close()
        logger.info("streamondemand.core.updater Grabado a " + local_version_path)
    except:
        import traceback
        logger.info(traceback.format_exc())

    if os.path.exists(local_compiled_path):
        os.remove(local_compiled_path)
Ejemplo n.º 2
0
def download_server(server_name):
    logger.info("Stefano.core.updater download_server('" + server_name + "')")

    import servertools
    remote_server_url, remote_version_url = servertools.get_server_remote_url(
        server_name)
    local_server_path, local_version_path, local_compiled_path = servertools.get_server_local_path(
        server_name)

    # Descarga el canal
    try:
        updated_server_data = scrapertools.cachePage(remote_server_url)
        outfile = open(local_server_path, "wb")
        outfile.write(updated_server_data)
        outfile.flush()
        outfile.close()
        logger.info("Stefano.core.updater Grabado a " + local_server_path)
    except:
        import traceback
        logger.info(traceback.format_exc())

    # Descarga la version (puede no estar)
    try:
        updated_version_data = scrapertools.cachePage(remote_version_url)
        outfile = open(local_version_path, "w")
        outfile.write(updated_version_data)
        outfile.flush()
        outfile.close()
        logger.info("Stefano.core.updater Grabado a " + local_version_path)
    except:
        import traceback
        logger.info(traceback.format_exc())

    if os.path.exists(local_compiled_path):
        os.remove(local_compiled_path)
Ejemplo n.º 3
0
def update_server(server_name):
    logger.info("streamondemand.core.updater updateserver('" + server_name +
                "')")

    import servertools
    remote_server_url, remote_version_url = servertools.get_server_remote_url(
        server_name)
    local_server_path, local_version_path, local_compiled_path = servertools.get_server_local_path(
        server_name)

    # Version remota
    try:
        data = scrapertools.cachePage(remote_version_url)
        logger.info("streamondemand.core.updater remote_data=" + data)
        remote_version = int(
            scrapertools.find_single_match(data, '<version>([^<]+)</version>'))
    except:
        remote_version = 0

    logger.info("streamondemand.core.updater remote_version=%d" %
                remote_version)

    # Version local
    local_version = 0
    if os.path.exists(local_version_path):
        try:
            infile = open(local_version_path)
            data = infile.read()
            infile.close()
            logger.info("streamondemand.core.updater local_data=" + data)
            local_version = int(
                scrapertools.find_single_match(data,
                                               '<version>([^<]+)</version>'))
        except:
            pass

    logger.info("streamondemand.core.updater local_version=%d" % local_version)

    # Comprueba si ha cambiado
    updated = remote_version > local_version

    if updated:
        logger.info("streamondemand.core.updater updated")
        download_server(server_name)

    return updated
Ejemplo n.º 4
0
def update_server(server_name):
    logger.info("streamondemand.core.updater updateserver('" + server_name + "')")

    import servertools
    remote_server_url, remote_version_url = servertools.get_server_remote_url(server_name)
    local_server_path, local_version_path, local_compiled_path = servertools.get_server_local_path(server_name)

    # Version remota
    try:
        data = scrapertools.cachePage(remote_version_url)
        logger.info("streamondemand.core.updater remote_data=" + data)
        remote_version = int(scrapertools.find_single_match(data, '<version>([^<]+)</version>'))
    except:
        remote_version = 0

    logger.info("streamondemand.core.updater remote_version=%d" % remote_version)

    # Version local
    local_version = 0
    if os.path.exists(local_version_path):
        try:
            infile = open(local_version_path)
            data = infile.read()
            infile.close()
            logger.info("streamondemand.core.updater local_data=" + data)
            local_version = int(scrapertools.find_single_match(data, '<version>([^<]+)</version>'))
        except:
            pass

    logger.info("streamondemand.core.updater local_version=%d" % local_version)

    # Comprueba si ha cambiado
    updated = remote_version > local_version

    if updated:
        logger.info("streamondemand.core.updater updated")
        download_server(server_name)

    return updated