Best Python code snippet using localstack_python
test_uihelper.py
Source:test_uihelper.py  
...31        self.setup_with_file('etc/shinken_1r_1h_1s.cfg')32    def test_duration_print(self):33        now = time.time()34        # Got bogus return35        s = helper.print_duration(None)36        print "Res", s37        self.assert_(s == 'N/A')38        s = helper.print_duration(0)39        print "Res", s40        self.assert_(s == 'N/A')41        # Get the Now42        s = helper.print_duration(now)43        print "Res", s44        self.assert_(s == 'Now')45        # Go PAST46        # Get the 2s ago47        s = helper.print_duration(now - 2)48        print "Res", s49        self.assert_(s == '2s ago')50        # Ask only the furation string51        s = helper.print_duration(now - 2, just_duration=True)52        print "Res", s53        self.assert_(s == '2s')54        # Got 2minutes55        s = helper.print_duration(now - 120)56        print "Res", s57        self.assert_(s == '2m ago')58        # Go 2hours ago59        s = helper.print_duration(now - 3600*2)60        print "Res", s61        self.assert_(s == '2h ago')62        # Go 2 days ago63        s = helper.print_duration(now - 3600*24*2)64        print "Res", s65        self.assert_(s == '2d ago')66        # Go 2 weeks ago67        s = helper.print_duration(now - 86400*14)68        print "Res", s69        self.assert_(s == '2w ago')70        # Go 2 months ago71        s = helper.print_duration(now - 86400*56)72        print "Res", s73        self.assert_(s == '2M ago')74        # Go 1 year ago75        s = helper.print_duration(now - 86400*365*2)76        print "Res", s77        self.assert_(s == '2y ago')78        # Now a mix of all of this :)79        s = helper.print_duration(now - 2 - 120 - 3600*2 - 3600*24*2 - 86400*14 - 86400*56)80        print "Res", s81        self.assert_(s == '2M 2w 2d 2h 2m 2s ago')82        # Now with a limit, because here it's just a nightmare to read83        s = helper.print_duration(now - 2 - 120 - 3600*2 - 3600*24*2 - 86400*14 - 86400*56, x_elts=2)84        print "Res", s85        self.assert_(s == '2M 2w ago')86        # Return to the future87        # Get the 2s ago88        s = helper.print_duration(now + 2)89        print "Res", s90        self.assert_(s == 'in 2s')91        # Got 2minutes92        s = helper.print_duration(now + 120)93        print "Res", s94        self.assert_(s == 'in 2m')95        # Go 2hours ago96        s = helper.print_duration(now + 3600*2)97        print "Res", s98        self.assert_(s == 'in 2h')99        # Go 2 days ago100        s = helper.print_duration(now + 3600*24*2)101        print "Res", s102        self.assert_(s == 'in 2d')103        # Go 2 weeks ago104        s = helper.print_duration(now + 86400*14)105        print "Res", s106        self.assert_(s == 'in 2w')107        # Go 2 months ago108        s = helper.print_duration(now + 86400*56)109        print "Res", s110        self.assert_(s == 'in 2M')111        # Go 1 year ago112        s = helper.print_duration(now + 86400*365*2)113        print "Res", s114        self.assert_(s == 'in 2y')115        # Now a mix of all of this :)116        s = helper.print_duration(now + 2 + 120 + 3600*2 + 3600*24*2 + 86400*14 + 86400*56)117        print "Res", s118        self.assert_(s == 'in 2M 2w 2d 2h 2m 2s')119        # Now with a limit, because here it's just a nightmare to read120        s = helper.print_duration(now + 2 - 120 + 3600*2 + 3600*24*2 + 86400*14 + 86400*56, x_elts=2)121        print "Res", s122        self.assert_(s == 'in 2M 2w')123    def test_dep_graph(self):124        now = time.time()125        host = self.sched.hosts.find_by_name("test_host_0")126        print host.parent_dependencies127        struc = helper.get_dep_graph_struct(host)128        print struc129        j = helper.create_json_dep_graph(host)130        print j131        all_elts = helper.get_all_linked_elts(host)132        print "All elts", all_elts133    # Try the navi pages helper134    def test_navi(self):...pedigree_load_data.py
Source:pedigree_load_data.py  
...6                                          add_or_load_crosses_data)7#                                           add_or_load_plant_relationship,8#                                           add_or_load_cross_experiments,9#                                           add_or_load_plants,10def print_duration(msg, prev_time):11    now = time()12    print(msg + ': ' + str(round(now - prev_time, 2)))13    return now14class Command(BaseCommand):15    help = 'load initial data into database'16    def add_arguments(self, parser):17        parser.add_argument('dir_fpath', help='directory with pedigree files')18        parser.add_argument('-c', '--only_check', help='only check data',19                            action='store_true')20    def handle(self, *args, **options):21        dirpath = options['dir_fpath']22        only_check = options['only_check']23        prev_time = time()24        add_or_load_accessions(join(dirpath, 'varitome_passport.xlsx'))25        prev_time = print_duration('varitome_passport.xlsx', prev_time)26        add_or_load_seedlot(join(dirpath, 'SeedLots_originals.xlsx'))27        prev_time = print_duration('SeedLots_originals.xlsx', prev_time)28        add_or_load_seedlot(join(dirpath, 'SeedLots_magic.xlsx'))29        prev_time = print_duration('SeedLots_magic.xlsx', prev_time)30        add_or_load_crosses_data(join(dirpath, 'varitome_crosses_all.xlsx'),31                                 only_check=only_check)32#         add_or_load_crosses_data(join(dirpath, 'varitome_crosses_spring2018.xlsx'),33#                                  only_check=only_check)34#         return35#         add_or_load_plants(join(dirpath, 'NSF2_PA01_Sep_2016_plants.xlsx'))36#         prev_time = print_duration('NSF2_PA01_Sep_2016_plants.xlsx', prev_time)37#38#         add_or_load_plants(join(dirpath, 'NSF2_CN0X_Feb_2016_plants.xlsx'))39#         prev_time = print_duration('NSF2_CN0X_Feb_2016_plants.xlsx', prev_time)40#41#         add_or_load_plants(join(dirpath, 'NSF1_CN0X_Feb_2016_plants.xlsx'))42#         prev_time = print_duration('NSF1_CN0X_Feb_2016_plants.xlsx', prev_time)43#44#         add_or_load_plant_relationship(join(dirpath, 'NSF2_PA01_Sep_2016_plant_clones.xlsx'))45#         prev_time = print_duration('NSF2_PA01_Sep_2016_plant_clones.xlsx', prev_time)46#47#         add_or_load_plant_relationship(join(dirpath, 'NSF2_CN0X_Feb_2016_plant_clones.xlsx'))48#         prev_time = print_duration('NSF2_CN0X_Feb_2016_plant_clones.xlsx', prev_time)49#50#         add_or_load_cross_experiments(join(dirpath, 'Crosses_F16NSF2.xlsx'))51#         prev_time = print_duration('Crosses_F16NSF2.xlsx', prev_time)52#53#         add_or_load_cross_experiments(join(dirpath, 'Crosses_F16NSF3_upv.xlsx'))54#         prev_time = print_duration('Crosses_F16NSF3_upv.xlsx', prev_time)55#56#         # 2017 March57#         dirpath_2017march = join(dirpath, 'SEP_2017')58#         add_or_load_plants(join(dirpath_2017march, 'NSF2_PA01_March_2017_plants.xlsx'))59#         prev_time = print_duration('NSF2_PA01_March_2017_plants.xlsx', prev_time)60#61#         add_or_load_plants(join(dirpath_2017march, 'NSF3_AQ01_March_2017_plants.xlsx'))62#         prev_time = print_duration('NSF3_AQ01_March_2017_plants.xlsx', prev_time)63#64#         add_or_load_cross_experiments(join(dirpath_2017march, 'NSF2_PA01_March_2017_crosses.xlsx'))65#         prev_time = print_duration('NSF2_PA01_March_2017_crosses.xlsx', prev_time)66#67#         add_or_load_cross_experiments(join(dirpath_2017march, 'NSF3_AQ01_March_2017_crosses.xlsx'))68#         prev_time = print_duration('NSF3_AQ01_March_2017_crosses.xlsx', prev_time)69#70#         add_or_load_cross_experiments(join(dirpath_2017march, 'CRUCES_ESPECIFICOS-sep2017.xlsx'))...LabelMakerSelector.py
Source:LabelMakerSelector.py  
1from labelmakers.GeneralLabelMaker import GeneralLabelMaker2from labelmakers.BPIC2017LabelMaker import BPIC2017LabelMaker3from labelmakers.BPIC2014LabelMaker import BPIC2014LabelMaker4def get_label_maker(name_data_set, use_label_dict=False, activity_label="activity", print_duration=False,5                    activity_label_sep=" "):6    if name_data_set == "bpic2017":7        return BPIC2017LabelMaker(use_label_dict=use_label_dict, activity_label=activity_label,8                                  print_duration=print_duration, activity_label_sep=activity_label_sep)9    elif name_data_set == "bpic2014":10        return BPIC2014LabelMaker(activity_label=activity_label, print_duration=print_duration,11                                  activity_label_sep=activity_label_sep)12    else:13        return GeneralLabelMaker(activity_label=activity_label, print_duration=print_duration,...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!!
