How to use describe_export method in localstack

Best Python code snippet using localstack_python

exportable.py

Source:exportable.py Github

copy

Full Screen

...56 self.generate_export(export_type)57 if generate or wait:58 export = self.wait_export(export_type, wait_timeout)59 else:60 export = self.describe_export(export_type)61 if export_type in TALK_EXPORT_TYPES:62 media_url = export['data_requests'][0]['url']63 else:64 media_url = export['media'][0]['src']65 response = requests.get(media_url, stream=True)66 response.csv_reader = functools.partial(67 csv.reader,68 response.iter_lines(decode_unicode=True),69 )70 response.csv_dictreader = functools.partial(71 csv.DictReader,72 response.iter_lines(decode_unicode=True),73 )74 return response75 def wait_export(76 self,77 export_type,78 timeout=None,79 ):80 """81 Blocks until an in-progress export is ready.82 - **export_type** is a string specifying which type of export to wait83 for.84 - **timeout** is the maximum number of seconds to wait.85 If ``timeout`` is given and the export is not ready by the time limit,86 :py:class:`.PanoptesAPIException` is raised.87 """88 success = False89 if timeout:90 end_time = datetime.datetime.now() + datetime.timedelta(91 seconds=timeout92 )93 while (not timeout) or (datetime.datetime.now() < end_time):94 export_description = self.describe_export(95 export_type,96 )97 if export_type in TALK_EXPORT_TYPES:98 export_metadata = export_description['data_requests'][0]99 else:100 export_metadata = export_description['media'][0]['metadata']101 if export_metadata.get('state', '') in ('ready', 'finished'):102 success = True103 break104 time.sleep(2)105 if not success:106 raise PanoptesAPIException(107 '{}_export not ready within {} seconds'.format(108 export_type,109 timeout110 )111 )112 return export_description113 def generate_export(self, export_type):114 """115 Start a new export.116 - **export_type** is a string specifying which type of export to start.117 Returns a :py:class:`dict` containing metadata for the new export.118 """119 if export_type in TALK_EXPORT_TYPES:120 return talk.post_data_request(121 'project-{}'.format(self.id),122 export_type.replace('talk_', '')123 )124 return self.http_post(125 self._export_path(export_type),126 json={"media": {"content_type": "text/csv"}},127 )[0]128 def describe_export(self, export_type):129 """130 Fetch metadata for an export.131 - **export_type** is a string specifying which type of export to look132 up.133 Returns a :py:class:`dict` containing metadata for the export.134 """135 if export_type in TALK_EXPORT_TYPES:136 return talk.get_data_request(137 'project-{}'.format(self.id),138 export_type.replace('talk_', '')139 )[0]140 return self.http_get(141 self._export_path(export_type),142 )[0]...

Full Screen

Full Screen

generate_exports.py

Source:generate_exports.py Github

copy

Full Screen

...5Panoptes.connect(username=os.environ['User_name'], password=os.environ['Password'])6project = Project.find(slug='pmason/fossiltrainer')7def generate_class(projt):8 try:9 meta_class = projt.describe_export('classifications')10 last_generated = meta_class['media'][0]['updated_at'][0:19]11 tdelta = (datetime.now() - datetime.strptime(last_generated, '%Y-%m-%dT%H:%M:%S')).total_seconds()12 if (300 + tdelta / 60) >= 24 * 60: # 300 is offset EST offset from Zulu could be 240 during EDT13 project.generate_export('classifications')14 print('Export request sent, please wait 30 seconds to verify generation has begun')15 time.sleep(30)16 meta_class = projt.describe_export('classifications')17 now_generated = meta_class['media'][0]['updated_at'][0:19]18 tdelta_now = (datetime.now() - datetime.strptime(now_generated, '%Y-%m-%dT%H:%M:%S')).total_seconds()19 if tdelta_now < 100:20 print(str(datetime.now())[0:19] + ' Classification export generated.')21 return True22 else:23 print(str(datetime.now())[0:19] + ' Classification export did not generate correctly')24 return False25 else:26 print(str(datetime.now())[0:19] + ' Too soon to generate Classification export - ' +27 str(round((tdelta / 3600 + 5), 1)) + ' hrs.')28 return False29 except:30 print(str(datetime.now())[0:19] + ' Classification export did not generate correctly')31 return False32def generate_subj(projt):33 try:34 meta_subj = projt.describe_export('subjects')35 last_generated = meta_subj['media'][0]['updated_at'][0:19]36 tdelta = (datetime.now() - datetime.strptime(last_generated, '%Y-%m-%dT%H:%M:%S')).total_seconds()37 if (300 + tdelta / 60) >= 24 * 60: # 300 is offset EST offset from Zulu could be 240 during EDT38 project.generate_export('subjects')39 print('Export request sent, please wait 30 seconds to verify generation has begun')40 time.sleep(30)41 meta_subj = projt.describe_export('classifications')42 now_generated = meta_subj['media'][0]['updated_at'][0:19]43 tdelta_now = (datetime.now() - datetime.strptime(now_generated, '%Y-%m-%dT%H:%M:%S')).total_seconds()44 if tdelta_now < 100:45 print(str(datetime.now())[0:19] + ' Subject export generated.')46 return True47 else:48 print(str(datetime.now())[0:19] + ' Subject export did not generate correctly')49 return False50 else:51 print(str(datetime.now())[0:19] + ' Too soon to generate Subject export - ' +52 str(round((tdelta / 3600 + 5), 1)) + ' hrs.')53 return False54 except:55 print(str(datetime.now())[0:19] + ' Subject export did not generate correctly')...

Full Screen

Full Screen

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