How to use force_link method in autotest

Best Python code snippet using autotest_python

init_zshrc.py

Source: init_zshrc.py Github

copy

Full Screen

1import os2from pathlib import Path3import re4import shutil5def link_zshrc_file(force_link=False):6 zshrc_source = Path(__file__).resolve().parent/​"rc_dotfiles"/​".zshrc"7 zshrc_destination = Path().home()/​".zshrc"8 if not zshrc_source.exists():9 raise Exception(f".zshrc source file not found")10 if zshrc_destination.exists():11 if force_link:12 old_zshrc_destination = Path().home()/​".zshrc.old"13 shutil.move(zshrc_destination, old_zshrc_destination)14 print(f"moved existing ~/​.zshrc file to {old_zshrc_destination}")15 else:16 raise Exception(f".zshrc file already exists at {zshrc_destination}")17 print(f"symlinking {zshrc_source} to {zshrc_destination}")18 os.system(f"ln -sf {zshrc_source} {zshrc_destination}")19def link_oh_my_zsh_packages():20 # symlinking oh-my-zsh packages in .setup21 source_plugins = Path(__file__).resolve().parent/​'oh-my-zsh-plugins'22 dest_plugins = Path('~/​.oh-my-zsh/​custom/​plugins')23 os.system(f"rm -r {dest_plugins}")24 os.system(f"ln -s {source_plugins} {dest_plugins}")25 # symlinking oh-my-zsh themes26 source_themes = Path(__file__).resolve().parent/​'oh-my-zsh-themes'27 dest_themes = Path("~/​.oh-my-zsh/​custom/​themes")28 os.system(f"rm -r {dest_themes}")29 os.system(f"ln -s {source_themes} {dest_themes}")30def install_oh_my_zsh():31 oh_my_zsh_install_location = os.environ.get("ZSH", False)32 if not oh_my_zsh_install_location or not Path(oh_my_zsh_install_location).exists():33 print("installing oh_my_zsh")34 os.system('sh -c "$(curl -fsSL https:/​/​raw.githubusercontent.com/​ohmyzsh/​ohmyzsh/​master/​tools/​install.sh) --unattended --keep-zshrc"')35 else:36 print("skipping oh-my-zsh install - already detected")37def link_p10krc_file(force_link=False):38 p10krc_source = Path(__file__).resolve().parent/​"rc_dotfiles"/​".p10k.zsh"39 p10krc_destination = Path().home()/​".p10k.zsh"40 if not p10krc_source.exists():41 raise Exception(f".p10k.zsh source file not found")42 if p10krc_destination.exists():43 if force_link:44 old_p10krc_destination = Path().home()/​".p10k.zsh.old"45 shutil.move(p10krc_destination, old_p10krc_destination)46 print(f"moved existing ~/​.p10k.zsh file to {old_p10krc_destination}")47 else:48 raise Exception(f".p10k.zsh file already exists at {p10krc_destination}")49 print(f"symlinking {p10krc_source} to {p10krc_destination}")50 os.system(f"ln -sf {p10krc_source} {p10krc_destination}")51def link_tmux_rc_file(force_link=True):52 tmux_rc_source = Path(__file__).resolve().parent/​"rc_dotfiles"/​".tmux.conf"53 tmux_rc_destination = Path().home()/​".tmux.conf"54 if not tmux_rc_source.exists():55 raise Exception(f".tmux.conf source file not found")56 if tmux_rc_destination.exists():57 if force_link:58 old_tmux_rc_destination = Path().home()/​".tmux.conf.old"59 shutil.move(tmux_rc_destination, old_tmux_rc_destination)60 print(f"moved existing ~/​.tmux.conf file to {old_tmux_rc_destination}")61 else:62 raise Exception(f".tmux.conf file already exists at {tmux_rc_destination}")63 print(f"symlinking {tmux_rc_source} to {tmux_rc_destination}")...

Full Screen

Full Screen

test_fs.py

Source: test_fs.py Github

copy

Full Screen

...49 with open(path) as f:50 content: str = f.read()51 assert content == ("INIT=true\n" if preexisting else "") + "HELLO=world\nCHENV=testing\n"52@pytest.mark.parametrize("preexisting", [False, True])53def test_force_link(preexisting: bool) -> None:54 """Test `force_link`."""55 filename: str = ".env.source"56 side_effect: Optional[Exception] = FileNotFoundError() if preexisting else None57 with patch("os.remove", side_effect=side_effect) as remove, patch("os.symlink") as symlink:58 chenv.fs.force_link(filename)59 remove.assert_called_once_with(chenv.settings.DOTENV)60 symlink.assert_called_once_with(filename, chenv.settings.DOTENV)61@pytest.mark.parametrize("path, expected", [(_SAMPLE_FILE, ["HELLO=world", 'CHENV="testing"']), (".env.missing", [])])62def test_load_lines(path: str, expected: Optional[Dict[str, str]]) -> None:63 """Test `load_lines`."""...

Full Screen

Full Screen

setup.py

Source: setup.py Github

copy

Full Screen

1from install_scripts import install_system_packages2from zshrc_src import init_zshrc3from ssh import init_ssh, decrypt_ssh_folder4from pathlib import Path5import subprocess6import argparse7parser = argparse.ArgumentParser()8parser.add_argument('--disable-ssh', help='disable ssh install', action='store_true')9parser.add_argument('--disable-zshrc', help='disable linking zshrc', action='store_true')10parser.add_argument('--overwrite-ssh', help='deletes saved ssh/​encrypted.ssh and replaces it with existing ~/​.ssh', action='store_true')11parser.add_argument('--disable-system-installs', help='skips installing packages', action='store_true')12args = parser.parse_args()13if not args.disable_system_installs:14 install_system_packages.install_zsh()15 install_system_packages.install_curl()16 install_system_packages.install_vim()17 install_system_packages.install_ripgrep()18 install_system_packages.install_fzf()19if not args.disable_zshrc:20 init_zshrc.install_oh_my_zsh()21 init_zshrc.link_oh_my_zsh_packages()22 init_zshrc.link_zshrc_file(force_link=True)23 init_zshrc.link_p10krc_file(force_link=True)24 init_zshrc.link_tmux_rc_file(force_link=True)25if args.overwrite_ssh:26 init_ssh.overwrite_ssh()27elif not args.disable_ssh:28 decrypt_ssh_folder.decrypt_ssh_folder()...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

Scala Testing: A Comprehensive Guide

Before we discuss Scala testing, let us understand the fundamentals of Scala and how this programming language is a preferred choice for your development requirements.The popularity and usage of Scala are rapidly rising, evident by the ever-increasing open positions for Scala developers.

What Agile Testing (Actually) Is

So, now that the first installment of this two fold article has been published (hence you might have an idea of what Agile Testing is not in my opinion), I’ve started feeling the pressure to explain what Agile Testing actually means to me.

How To Choose The Right Mobile App Testing Tools

Did you know that according to Statista, the number of smartphone users will reach 18.22 billion by 2025? Let’s face it, digital transformation is skyrocketing and will continue to do so. This swamps the mobile app development market with various options and gives rise to the need for the best mobile app testing tools

A Complete Guide To CSS Houdini

As a developer, checking the cross browser compatibility of your CSS properties is of utmost importance when building your website. I have often found myself excited to use a CSS feature only to discover that it’s still not supported on all browsers. Even if it is supported, the feature might be experimental and not work consistently across all browsers. Ask any front-end developer about using a CSS feature whose support is still in the experimental phase in most prominent web browsers. ????

Appium Testing Tutorial For Mobile Applications

The count of mobile users is on a steep rise. According to the research, by 2025, it is expected to reach 7.49 billion users worldwide. 70% of all US digital media time comes from mobile apps, and to your surprise, the average smartphone owner uses ten apps per day and 30 apps each month.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run autotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful