How to use _configure_environment method in lisa

Best Python code snippet using lisa_python

kaggle.py

Source: kaggle.py Github

copy

Full Screen

...14from .nbconvert import FileExtensions15KAGGLE_CONFIG_DIR = Path(__file__).parent.parent.parent16if os.environ.get("IN_DOCKER", False):17 KAGGLE_CONFIG_DIR = "/​autobot"18def _configure_environment() -> None:19 if "KAGGLE_CONFIG_DIR" not in os.environ:20 os.environ["KAGGLE_CONFIG_DIR"] = str(KAGGLE_CONFIG_DIR)21 elif "KAGGLE_CONFIG_DIR" in os.environ and os.environ["KAGGLE_CONFIG_DIR"] != str(22 KAGGLE_CONFIG_DIR23 ):24 tqdm.write(f"Found `KAGGLE_CONFIG_DIR = {os.environ['KAGGLE_CONFIG_DIR']}`")25def pull_kernel(meeting: Meeting) -> Union[None, Path]:26 test_existence = requests.get(27 f"https:/​/​kaggle.com/​{ KAGGLE_USERNAME }/​{ slug_kernel(meeting) }"28 )29 if test_existence.status_code != requests.codes.OK:30 return None31 _configure_environment()32 subprocess.run(33 " ".join(34 [35 "kaggle k pull",36 f"-p { paths.tmp_meeting_folder(meeting) }",37 f"{KAGGLE_USERNAME}/​{ slug_kernel(meeting) }",38 ]39 ),40 shell=True,41 stdout=subprocess.DEVNULL,42 )43 return (paths.tmp_meeting_folder(meeting) /​ slug_kernel(meeting)).with_suffix(44 FileExtensions.Workbook45 )46def local_and_remote_kernels_diff(meeting: Meeting) -> bool:47 _configure_environment()48 remote_kernel = pull_kernel(meeting)49 if not remote_kernel:50 return True51 local_kernel = repositories.local_meeting_root(meeting) /​ "".join(52 [repr(meeting), FileExtensions.Workbook]53 )54 remote_kernel_json = json.dumps(json.load(open(remote_kernel, "r"))).encode("utf-8")55 local_kernel_json = json.dumps(json.load(open(local_kernel, "r"))).encode("utf-8")56 remote_kernel_hash = sha256(bytes(remote_kernel_json)).hexdigest()57 local_kernel_hash = sha256(bytes(local_kernel_json)).hexdigest()58 remote_kernel.unlink() # clean-up after diff59 return remote_kernel_hash != local_kernel_hash60def push_kernel(meeting: Meeting) -> None:61 _configure_environment()62 if local_and_remote_kernels_diff(meeting):63 subprocess.run(64 f"kaggle k push -p {paths.repo_meeting_folder(meeting)}",65 shell=True,66 # stdout=subprocess.DEVNULL,67 )68 else:69 tqdm.write(" - Kernels are the same. Skipping.")70def slug_kernel(meeting: Meeting) -> str:71 """Generates Kaggle Kernel slugs of the form: `<group>-<semester>-<filename>`72 e.g. if looking at the Fall 2019 Computational Cognitive Neuroscience73 lecture, the slug would be: `core-fa19-ccn`."""74 return "-".join(75 [...

Full Screen

Full Screen

tuesmon_back_cli.py

Source: tuesmon_back_cli.py Github

copy

Full Screen

...6import os7import django8import click9import sys10def _configure_environment(tuesmon_back_path):11 sys.stderr = open('/​dev/​null', 'w')12 sys.path.append(tuesmon_back_path)13 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")14 django.setup()15 globals()["tuesmon"] = __import__("tuesmon")16 from django.conf import settings17 settings.EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'18@click.group()19def cli():20 pass21@cli.command()22@click.argument("tuesmon_back_path", nargs=1, type=click.STRING)23@click.argument("project", nargs=1, type=click.STRING)24@click.argument("user", nargs=1, type=click.STRING)25@click.option("--reason", type=click.STRING, help="Postal code of the customer (5 digits)")26def transfer_token(tuesmon_back_path, project, user, reason):27 """28 Generates the transfer token for the specified project and user (the reason parameter is optional).\n29 As first argument you must specify the tuesmon-path.30 """31 _configure_environment(tuesmon_back_path)32 project = tuesmon.projects.models.Project.objects.get(slug=project)33 user = tuesmon.users.models.User.objects.get(username=user)34 tuesmon.projects.services.start_project_transfer(project, user, reason)35 print(project.transfer_token)36@cli.command()37@click.argument("tuesmon_back_path", nargs=1, type=click.STRING)38@click.argument("user", nargs=1, type=click.STRING)39@click.option("--max_private_projects", type=click.STRING, help="Max number of private projects")40@click.option("--max_memberships_private_projects", type=click.STRING, help="Max number of memberships in private projects")41@click.option("--max_public_projects", type=click.STRING, help="Max number of public projects")42@click.option("--max_memberships_public_projects", type=click.STRING, help="Max number of memberships in public projects")43def update_user_limits(tuesmon_back_path, user, max_private_projects, max_memberships_private_projects, max_public_projects, max_memberships_public_projects):44 """45 Updates the user project limits for user.\n46 As first argument you must specify the tuesmon-path.47 """48 _configure_environment(tuesmon_back_path)49 user = tuesmon.users.models.User.objects.get(username=user)50 user.max_private_projects = max_private_projects51 user.max_memberships_private_projects = max_memberships_private_projects52 user.max_public_projects = max_public_projects53 user.max_memberships_public_projects = max_memberships_public_projects54 user.save()55if __name__ == "__main__":...

Full Screen

Full Screen

taiga_back_cli.py

Source: taiga_back_cli.py Github

copy

Full Screen

...6import os7import django8import click9import sys10def _configure_environment(taiga_back_path):11 sys.stderr = open('/​dev/​null', 'w')12 sys.path.append(taiga_back_path)13 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")14 django.setup()15 globals()["taiga"] = __import__("taiga")16 from django.conf import settings17 settings.EMAIL_BACKEND = 'django.core.mail.backends.dummy.EmailBackend'18@click.group()19def cli():20 pass21@cli.command()22@click.argument("taiga_back_path", nargs=1, type=click.STRING)23@click.argument("project", nargs=1, type=click.STRING)24@click.argument("user", nargs=1, type=click.STRING)25@click.option("--reason", type=click.STRING, help="Postal code of the customer (5 digits)")26def transfer_token(taiga_back_path, project, user, reason):27 """28 Generates the transfer token for the specified project and user (the reason parameter is optional).\n29 As first argument you must specify the taiga-path.30 """31 _configure_environment(taiga_back_path)32 project = taiga.projects.models.Project.objects.get(slug=project)33 user = taiga.users.models.User.objects.get(username=user)34 taiga.projects.services.start_project_transfer(project, user, reason)35 print(project.transfer_token)36@cli.command()37@click.argument("taiga_back_path", nargs=1, type=click.STRING)38@click.argument("user", nargs=1, type=click.STRING)39@click.option("--max_private_projects", type=click.STRING, help="Max number of private projects")40@click.option("--max_memberships_private_projects", type=click.STRING, help="Max number of memberships in private projects")41@click.option("--max_public_projects", type=click.STRING, help="Max number of public projects")42@click.option("--max_memberships_public_projects", type=click.STRING, help="Max number of memberships in public projects")43def update_user_limits(taiga_back_path, user, max_private_projects, max_memberships_private_projects, max_public_projects, max_memberships_public_projects):44 """45 Updates the user project limits for user.\n46 As first argument you must specify the taiga-path.47 """48 _configure_environment(taiga_back_path)49 user = taiga.users.models.User.objects.get(username=user)50 user.max_private_projects = max_private_projects51 user.max_memberships_private_projects = max_memberships_private_projects52 user.max_public_projects = max_public_projects53 user.max_memberships_public_projects = max_memberships_public_projects54 user.save()55if __name__ == "__main__":...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

How To Handle Multiple Windows In Selenium Python

Automating testing is a crucial step in the development pipeline of a software product. In an agile development environment, where there is continuous development, deployment, and maintenance of software products, automation testing ensures that the end software products delivered are error-free.

Joomla Testing Guide: How To Test Joomla Websites

Before we discuss the Joomla testing, let us understand the fundamentals of Joomla and how this content management system allows you to create and maintain web-based applications or websites without having to write and implement complex coding requirements.

Starting &#038; growing a QA Testing career

The QA testing career includes following an often long, winding road filled with fun, chaos, challenges, and complexity. Financially, the spectrum is broad and influenced by location, company type, company size, and the QA tester’s experience level. QA testing is a profitable, enjoyable, and thriving career choice.

The Art of Testing the Untestable

It’s strange to hear someone declare, “This can’t be tested.” In reply, I contend that everything can be tested. However, one must be pleased with the outcome of testing, which might include failure, financial loss, or personal injury. Could anything be tested when a claim is made with this understanding?

How To Create Custom Menus with CSS Select

When it comes to UI components, there are two versatile methods that we can use to build it for your website: either we can use prebuilt components from a well-known library or framework, or we can develop our UI components from scratch.

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 lisa 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