How to use the appdirs.user_data_dir function in appdirs

To help you get started, we’ve selected a few appdirs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github U2Ft / RSS-filter / src / RSS_filter.py View on Github external
def main():
    args = docopt.docopt(__doc__)
    config_dir = appdirs.user_data_dir("RSS-filter", "U2Ft")
    config, filters = check_config(config_dir)
    logging.basicConfig(filename=os.path.join(config_dir, "RSS-filter.log"), level=logging.INFO,
                        datefmt="%Y-%m-%d %H:%M:%S", format="%(asctime)s: %(message)s")

    # silence requests.packages.urllib3's logging of every connection at level INFO
    requests_logger = logging.getLogger("requests.packages.urllib3")
    requests_logger.setLevel(logging.WARNING)

    if isinstance(filters, tuple) or args["--edit"]:
        edit_filters(filters, config_dir)
        exit(4)

    feedbin = Feedbin(config["username"], config["password"])

    if args["--list"]:
        list_feeds(feedbin)
github xeroc / piston-cli / piston / configuration.py View on Github external
def _storeConfig(self):
        data_dir = user_data_dir(appname, appauthor)
        f = os.path.join(data_dir, configFile)
        log.info("Your configuration file is located at " + f)
        self.mkdir_p(data_dir)
        with open(f, 'w') as fp:
            json.dump(self.store, fp)
github CenterForOpenScience / osf-sync / osfoffline / controller.py View on Github external
# new file if file doesnt exist.
        try:
            file = open(rel_osf_config, 'r+w')
        except:
            file = open(rel_osf_config, 'w+')

        try:
            file_content = file.read()
            self.config = json.loads(file_content)
        except ValueError:

            # todo: figure out where this should actually be
            self.config = {}
            self.config['app_name'] = self.app_name
            self.config['app_author'] = self.app_author
            self.config['db_dir'] = user_data_dir(self.app_name, self.app_author)
            self.store_configs()
        finally:
            file.close()
github scottrice / Ice / ice / paths.py View on Github external
def application_data_directory():
  # Parameters are 'App Name' and 'App Author'
  # TODO: Get these values from the same place as setup.py
  return appdirs.user_data_dir("Ice", "Scott Rice")
github matrix-org / pantalaimon / pantalaimon / main.py View on Github external
def main(context, log_level, debug_encryption, config, data_path):
    loop = asyncio.get_event_loop()

    conf_dir = user_config_dir("pantalaimon", "")
    data_dir = user_data_dir("pantalaimon", "")
    create_dirs(data_dir, conf_dir)

    config = config or os.path.join(conf_dir, "pantalaimon.conf")
    data_dir = data_path or data_dir

    if log_level:
        log_level = parse_log_level(log_level)

    pan_conf = PanConfig(config, log_level)

    try:
        pan_conf.read()
    except (OSError, PanConfigError) as e:
        context.fail(e)

    if not pan_conf.servers:
github xeroc / bitshares-pricefeed / bitshares_pricefeed / sources.py View on Github external
def getCacheFileName(self):
        cacheDir = os.path.join(
            user_data_dir("bitshares_pricefeed", "ChainSquad GmbH"),
            "cache",
            type(self).__name__
        )
        if not os.path.exists(cacheDir):
            os.makedirs(cacheDir)
        return os.path.join(cacheDir, self.today() + ".json")
github kolinger / rd-usb / utils / config.py View on Github external
import json
import os
import sys

from appdirs import user_data_dir

data_path = user_data_dir("rd-usb", False)
os.makedirs(data_path, exist_ok=True)
config_file = data_path + "/config.json"

if getattr(sys, "frozen", False):
    static_path = sys._MEIPASS + "/static"
else:
    static_path = os.path.realpath(os.path.dirname(__file__) + "/../static")


class Config:
    data = {}

    def __init__(self):
        if os.path.exists(config_file):
            with open(config_file, "r") as file:
                try:
github nodepy / nodepy / ppy_engine / config.py View on Github external
def get_default_prefix():
  """
  Returns the default prefix path of where to store ppy packages, Python
  modules, scripts, etc.
  """

  if is_virtualenv():
    # Use the virtualenv's prefix instead.
    return os.path.join(sys.prefix, 'share', 'ppy')

  return appdirs.user_data_dir('ppy', False, roaming=True)
github DankCity / dankbot / dankbot / db.py View on Github external
def __init__(self, logger, db_dir=None, create_db=False):
        self.logger = logger

        self.db_dir = db_dir or user_data_dir(APPNAME, APPAUTHOR)
        self.db_path = join(self.db_dir, DB_NAME)

        if create_db is True:
            self._create_db_and_table()
github kenfar / DataGristle / datagristle / metadata.py View on Github external
def __init__(self, db_dir=None, db_name='metadata.db'):
        """ Gets datagristle config, and creates db objects if necessary.
        """
        logging.basicConfig(filename='/tmp/datagristle_metadata.log')
        logging.getLogger('sqlalchemy.engine').setLevel(logging.DEBUG)

        if db_dir is None:
            user_data_dir = appdirs.user_data_dir('datagristle')
        else:
            user_data_dir = db_dir
        if not os.path.exists(user_data_dir):
            print('data dir (%s) missing - it will be created' % user_data_dir)
            os.makedirs(user_data_dir)

        self.fqdb_name = os.path.join(user_data_dir, db_name)
        self.engine = create_engine('sqlite:////%s' % self.fqdb_name)
        def _fk_pragma_on_connect(dbapi_con, con_record):
            """ turns foreign key enforcement on"""
            dbapi_con.execute('pragma foreign_keys=ON')

        event.listen(self.engine, 'connect', _fk_pragma_on_connect)

        self.engine.echo = False

appdirs

A small Python module for determining appropriate platform-specific dirs, e.g. a "user data dir".

MIT
Latest version published 5 years ago

Package Health Score

77 / 100
Full package analysis