Esempio n. 1
0
def copy_database_template( source, db_path ):
    """Copy a 'clean' sqlite template database.

    From file or URL to specified path for sqlite database.
    """
    db_path_dir = os.path.dirname(db_path)
    if not os.path.exists(db_path_dir):
        os.makedirs(db_path_dir)
    if os.path.exists(source):
        shutil.copy(source, db_path)
        assert os.path.exists(db_path)
    elif source.lower().startswith(("http://", "https://", "ftp://")):
        download_to_file(source, db_path)
    else:
        raise Exception( "Failed to copy database template from source %s" % source )
Esempio n. 2
0
def copy_database_template( source, db_path ):
    """Copy a 'clean' sqlite template database.

    From file or URL to specified path for sqlite database.
    """
    db_path_dir = os.path.dirname(db_path)
    if not os.path.exists(db_path_dir):
        os.makedirs(db_path_dir)
    if os.path.exists(source):
        shutil.copy(source, db_path)
        assert os.path.exists(db_path)
    elif source.lower().startswith(("http://", "https://", "ftp://")):
        try:
            download_to_file(source, db_path)
        except Exception as e:
            # We log the exception but don't fail startup, since we can
            # do all migration steps instead of downloading a template.
            log.exception(e)
    else:
        raise Exception( "Failed to copy database template from source %s" % source )
Esempio n. 3
0
 def get_tool_source_path(self, uri_like):
     tmp_path = self._temp_path(uri_like)
     download_to_file(uri_like, tmp_path)
     return tmp_path
Esempio n. 4
0
 def get_tool_source_path(self, uri_like):
     tmp_path = self._temp_path(uri_like)
     download_to_file(uri_like, tmp_path)
     return tmp_path