How to use the pathlib.Path.home function in pathlib

To help you get started, we’ve selected a few pathlib 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 kayagoban / shadowlands / shadowlands / dapp_browser.py View on Github external
def _dapp_thread(self):
        dapp_name = self._listbox_value()

        if dapp_name in sys.modules.keys() and 'site-packages' in sys.modules[dapp_name].__path__[0]:
            self.dapp.add_message_dialog("Module name '{}' conflicts with an installed module.".format(dapp_name))
            return


        # Install pip dependencies
        requirements_file = Path(self.dapp.config.sl_dapp_path).joinpath(dapp_name).joinpath('requirements.txt')

        if requirements_file.exists():
            requirements = open(str(requirements_file)).read().split()
            pipbin = Path.home().joinpath('.shadowlands').joinpath('bin').joinpath('pip')
            call([str(pipbin), 'install'] + requirements, stderr=DEVNULL, stdout=DEVNULL)

        dapp_module = importlib.import_module(dapp_name)

        # we force a reload (twice) in case they just made a change.
        self.reload_package(dapp_module)
        self.reload_package(dapp_module)

        try:
            Dapp = getattr(dapp_module, 'Dapp')
        except AttributeError:
            self.dapp.add_message_dialog("Possible module name conflict.")
            return

        self.dapp.hide_wait_frame()
github jotyGill / privacy-fighter / privacyfighter / pf.py View on Github external
def get_firefox_ini_path(detected_os):
    if detected_os == "linux":
        firefox_ini_path = os.path.join(str(Path.home()), ".mozilla/firefox/profiles.ini")
    elif detected_os == "win32":
        firefox_ini_path = os.path.join(os.getenv("APPDATA"), "Mozilla\Firefox\profiles.ini")
    elif detected_os == "darwin":
        firefox_ini_path = os.path.join(str(Path.home()), "Library/Application Support/Firefox/profiles.ini")

    return firefox_ini_path
github venthur / snakerunner / snakerunner / snakerunner.py View on Github external
def config_directory():
    directory = Path.home() / '.config' / 'Snakerunner'
    if not os.path.exists(directory):
        os.makedirs(directory)
    return directory
github spacemanspiff2007 / HABApp / HABApp / __main__.py View on Github external
def find_config_folder(arg_config_path: typing.Optional[Path]) -> Path:

    if arg_config_path is None:
        # Nothing is specified, we try to find the config automatically
        check_path = []
        try:
            working_dir = Path(os.getcwd())
            check_path.append( working_dir / 'HABApp')
            check_path.append( working_dir.with_name('HABApp'))
            check_path.append( working_dir.parent.with_name('HABApp'))
        except ValueError:
            # the ValueError gets raised if the working_dir or its parent is empty (e.g. c:\ or /)
            pass

        check_path.append(Path.home() / 'HABApp')   # User home

        # if we run in a venv check the venv, too
        v_env = os.environ.get('VIRTUAL_ENV', '')
        if v_env:
            check_path.append(Path(v_env) / 'HABApp')  # Virtual env dir
    else:
        # in case the user specifies the config.yml we automatically switch to the parent folder
        if arg_config_path.name.lower() == 'config.yml' and arg_config_path.is_file():
            arg_config_path = arg_config_path.parent

        # Override automatic config detection if something is specified through command line
        check_path = [arg_config_path]

    for config_folder in check_path:
        config_folder = config_folder.resolve()
        if not config_folder.is_dir():
github at16k / at16k / at16k / core / model.py View on Github external
def _get_model_dir(name):
        if 'AT16K_RESOURCES_DIR' in os.environ:
            base_dir = os.environ['AT16K_RESOURCES_DIR']
        else:
            sys_home_dir = str(Path.home())
            base_dir = os.path.join(sys_home_dir, '.at16k')
        model_dir = os.path.join(base_dir, name)
        assert os.path.exists(model_dir), ('%s model does not exist at %s' % (name, model_dir))
        return model_dir
github TylerGubala / blenderpy / bpy-optix / setup.py View on Github external
self.announce("Configuring cmake project "
                          "and building binaries "
                          "(this will take a while)", level=3)

        self.announce("Configuring cmake project "
                      "and building binaries", level=3)

        optix_root = None

        if SYSTEM_OS_NAME == "Windows":

            optix_root = r"C:\ProgramData\NVIDIA Corporation\OptiX SDK 7.0.0\SDK"

        else:

            optix_root = os.path.join(pathlib.Path.home(), f"NVIDIA-OptiX-SDK-7.0.0-{SYSTEM_OS_NAME.lower()}{str(BITNESS)}/SDK")

        if optix_root is None:

            raise Exception("Could not guess where Optix SDK is.")
                      
        for command in bpybuild.make.get_make_commands(source_location= blender_path,
                                                       build_location= build_path, 
                                                       with_cuda=True,
                                                       with_optix=True,
                                                       optix_sdk_path= optix_root):

            self.spawn(command)

        # Build finished, now copy the files into the copy directory
        # The copy directory is the parent directory of the extension (.pyd)
github LazoCoder / Pokemon-Terminal / pokemonterminal / wallpaper / adapters / feh.py View on Github external
def change_wallpaper(path: str):
        command = ["feh", "--bg-fill", path]
        if not (Path.home() / ".fehbg").is_file():
            command.insert(1, "--no-fehbg")
        subprocess.run(command, check=True)
github manga-py / manga-py / helpers / 1.py View on Github external
def __init__(self):
        self.__config_path = path.join(str(Path.home()), 'AppData', 'Roaming', 'PyMangaDownloader', 'config.json')
        if not path.isfile(self.__config_path):
            self.__make_default_config()
        else:
            self.__load_config()
        self.__load_lang(self.__storage['lang'])
github fastai / imagenet-fast / aws / aws_setup.py View on Github external
def connect_to_instance(instance, keypath=f'{Path.home()}/.ssh/aws-key-fast-ai.pem', username='ubuntu', timeout=10):
    print('Connecting to SSH...')
    
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    retries = 20
    while retries > 0:
        try:
            client.connect(instance.public_ip_address, username=username, key_filename=keypath, timeout=timeout)
            print('Connected!')
            break
        except Exception as e:
            print(f'Exception: {e} Retrying...')
            retries = retries - 1
            time.sleep(10)
    return client
github DonJayamanne / pythonVSCode / pvsc-dev-ext.py View on Github external
def checkout_directory(install_type, dir_name="vscode-python"):
    return pathlib.Path.home() / install_type.value / "extensions" / dir_name