Best Python code snippet using prospector_python
main.py
Source:main.py
1import sys2import subprocess3from datetime import datetime, timedelta4from module import client5from monitor import rds6from monitor import ecs7from monitor import efs8from monitor import fsx9if __name__ == "__main__":10 arguments = sys.argv11 if len(arguments) == 1:12 exit("Please Enter your ProfileName")13 profile_name = arguments[1]14 '''15 ì
ë ¥í profileì ë±ë¡ì¬ë¶ë¥¼ íì¸íê³ ë¯¸ë±ë¡ì¼ ê²½ì° ì¢
ë£í©ëë¤.16 '''17 list_profiles = subprocess.run(18 ["aws", "configure", "list-profiles"], capture_output=True).stdout.decode("utf-8").split("\n")19 for idx, profile in enumerate(list_profiles):20 list_profiles[idx] = profile.replace("\r", "")21 if profile_name not in list_profiles:22 exit("The profile you entered does not exist. Please Check your entered profile again.")23 '''24 ì
ë ¥í profile ì 보를 기ë°ì¼ë¡ boto3 client ê°ì²´ë¥¼ ìì±í©ëë¤.25 '''26 27 auth_dict = {"profile": profile_name}28 29 cw_client = client.get_client(auth_dict=auth_dict, client_name='cloudwatch')30 rds_client = client.get_client(auth_dict=auth_dict, client_name="rds")31 ecs_client = client.get_client(auth_dict=auth_dict, client_name="ecs")32 efs_client = client.get_client(auth_dict=auth_dict, client_name="efs")33 fsx_client = client.get_client(auth_dict=auth_dict, client_name="fsx")34 35 '''36 cloudwatchìì ì¬ì©íë 기ì¤ìê°ì¸ UTC(KST - 9:00) ìê°ì ì¬ì©í©ëë¤.37 ë°ë¼ì UTC ê¸°ì¤ íì¬ìê° -5ë¶ ~ íì¬ìê°ê¹ì§ë¥¼ 모ëí°ë§í©ëë¤.38 '''39 now_date = datetime.now() - timedelta(hours=9) - timedelta(minutes=5)40 # 모ëí°ë§ ê²°ê³¼ ë©ì¸ì§ 리ì¤í¸.41 result_messages = []42 43 '''44 RDS CloudWatch ì§íì ëí 모ëí°ë§ ê²°ê³¼ê°ì ë°íí©ëë¤.45 - monitor/rds.py ì check functionì ì¬ì©í©ëë¤.46 '''47 rds_result = rds.check(cw_client=cw_client,48 rds_client=rds_client,49 now_date=now_date)50 result_messages.extend(rds_result)51 52 53 '''54 ECS CloudWatch ì§íì ëí 모ëí°ë§ ê²°ê³¼ê°ì ë°íí©ëë¤.55 - monitor/ecs.py ì check functionì ì¬ì©í©ëë¤.56 '''57 ecs_result = ecs.check(cw_client=cw_client,58 ecs_client=ecs_client,59 now_date=now_date)60 result_messages.extend(ecs_result)61 62 63 '''64 EFS CloudWatch ì§íì ëí 모ëí°ë§ ê²°ê³¼ê°ì ë°íí©ëë¤.65 - monitor/efs.py ì check functionì ì¬ì©í©ëë¤.66 '''67 efs_result = efs.check(cw_client=cw_client,68 efs_client=efs_client,69 now_date=now_date)70 result_messages.extend(efs_result)71 72 73 '''74 FSX CloudWatch ì§íì ëí 모ëí°ë§ ê²°ê³¼ê°ì ë°íí©ëë¤.75 - monitor/fsx.py ì check functionì ì¬ì©í©ëë¤.76 '''77 fsx_result = fsx.check(cw_client=cw_client,78 fsx_client=fsx_client,79 now_date=now_date)80 81 result_messages.extend(fsx_result)82 ...
tests-postgres.py
Source:tests-postgres.py
...16 f.write('select * from "Artist";')17 df = self.db.query_from_file("db/tests/testscript.sql")18 self.assertEqual(len(df), 244)19 def test_add_profile(self):20 profiles = list_profiles()21 self.db.save_credentials(profile="test_profile")22 self.assertEqual(len(profiles)+1, len(list_profiles()))23 remove_profile("test_profile")24 def test_remove_profile(self):25 profiles = list_profiles()26 self.db.save_credentials(profile="test_profile")27 self.assertEqual(len(profiles)+1, len(list_profiles()))28 remove_profile("test_profile")29 def test_list_profiles(self):30 self.db.save_credentials(profile="test_profile")31 self.assertTrue(len(list_profiles()) > 0)32 remove_profile("test_profile")33 def test_table_head(self):34 self.assertEqual(len(self.db.tables.Artist.head()), 6)35 def test_table_all(self):36 self.assertEqual(len(self.db.tables.Artist.all()), 244)37 def test_table_select(self):38 df = self.db.tables.Artist.select("ArtistId", "Name")39 self.assertEqual(df.shape, (244, 2))40 def test_table_sample(self):41 df = self.db.tables.Artist.sample(n=10)42 self.assertEqual(len(df), 10)43 def test_table_uniqe(self):44 df = self.db.tables.Track.unique("GenreId", "MediaTypeId")45 self.assertEqual(len(df), 33)...
profiles.py
Source:profiles.py
1import pytest2from src.domain.profiles import Profiles3from src.infra.repositories.profiles_repository import ProfilesRepository4from src.utils.enums.profiles import ProfilesEnum5@pytest.fixture(scope='function')6def profiles():7 list = [profile.value for profile in ProfilesEnum]8 list_profiles = []9 repository = ProfilesRepository()10 for name in list:11 profile = Profiles(name=name)12 profile = repository.create(profile)13 list_profiles.append(profile)14 yield15 for item in list_profiles:16 try:17 repository.delete(item.id)18 except Exception:19 continue20@pytest.fixture(scope='session')21def profile_admin():22 list = ['ADMIN']23 list_profiles = []24 repository = ProfilesRepository()25 for name in list:26 profile = Profiles(name=name)27 profile = repository.create(profile)28 list_profiles.append(profile)29 yield30 for item in list_profiles:31 try:32 item.delete()33 except Exception:...
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!