Exemplo n.º 1
0
    def create_dirs(self):
        """ Initialize a users config directory by creating the prerequisite directories.

        :return:
        :rtype:
        """
        if not exists(self.config_path):
            util.mkdirp(self.config_path)
        if not exists(self.cache_path):
            util.mkdirp(self.cache_path)
Exemplo n.º 2
0
def fetch_update(download=True, url=_db_url):
    tmp_dir = join(config.config_path, 'geoip_temp')
    util.mkdirp(tmp_dir)
    tmp_dir_file = join(tmp_dir, 'geolite2.zip')
    if download:
        data_set = net.http_request(url, json=False)
        if data_set:
            with open(tmp_dir_file, 'wb') as out:
                out.write(data_set)
    return tmp_dir_file
Exemplo n.º 3
0
    def create_dirs(self):
        """ Initialize a users config directory by creating the prerequisite directories.

        :return:
        :rtype:
        """
        if not exists(self.config_path):
            util.mkdirp(self.config_path)
        if not exists(self.cache_path):
            util.mkdirp(self.cache_path)
Exemplo n.º 4
0
 def __init__(self, directory=None):
     """
     """
     super(SimpleFileClient, self).__init__()
     directory = expanduser(directory)
     if exists(directory):
         if not isdir(directory):
             raise OSError("File output path is not a directory: {}".format(directory))
     else:
         mkdirp(directory)
     self.directory = directory
Exemplo n.º 5
0
def load_sql(download=True):
    """ Load the datasets into the database, optionally downloading the dataset before

    :param download: Download a fresh dataset?
    :type download: bool
    :return: Load status
    :rtype: bool
    """
    tmp_dir = join(config.config_path, 'imdb_temp')
    util.mkdirp(tmp_dir)
    if not download or fetch_database(tmp_dir):
        args = ['imdbpy2sql.py', '-d', tmp_dir, '-u', config.get_db_uri()]
        if 'sqlite' in config.get_db_uri():
            # SQLite is laughably slow without this flag making, Using it
            # makes it possibly the fasted to import
            args.append('--sqlite-transactions')
        log.debug("Executing: {}".format(" ".join(args)))
        ret_val = check_call(args)
        log.debug(ret_val)
Exemplo n.º 6
0
def load_sql(download=True):
    """ Load the datasets into the database, optionally downloading the dataset before

    :param download: Download a fresh dataset?
    :type download: bool
    :return: Load status
    :rtype: bool
    """
    tmp_dir = join(config.config_path, 'imdb_temp')
    util.mkdirp(tmp_dir)
    if not download or fetch_database(tmp_dir):
        args = ['imdbpy2sql.py', '-d', tmp_dir, '-u', config.get_db_uri()]
        if 'sqlite' in config.get_db_uri():
            # SQLite is laughably slow without this flag making, Using it
            # makes it possibly the fasted to import
            args.append('--sqlite-transactions')
        log.debug("Executing: {}".format(" ".join(args)))
        ret_val = check_call(args)
        log.debug(ret_val)