upload_files.py
def post_file_to_s3(self, filepath, post, retry_period=10, retry_duration=7200):
        """Uploads a single file to AWS S3. If the post is unsuccessful
        it will retry every 10 seconds for 2 hours

        Args:
            filepath (str): filepath
            post (dict): post dictionary from S3 {url: (str), fields: dict}
            retry_period: number of seconds to wait before each rety
            retry_duration: total length of time to keep retrying (in seconds)

        Raises:
            ConnectionError
        """

        # Parse fields
        url = post['url']
        fields = post['fields']

        # Open file io
        files = {'file': open(filepath, 'rb')}

        # Attempt to upload file bytes
        for attempt in range(retry_duration):
            try:
                r_s3 = requests.post(url, data=fields, files=files)
            except:
                print('...Trying to get to S3...')
                time.sleep(retry_period)
            else:
                break
        else:
            # Loop never hit break, i.e the request never went
            # through
            raise ConnectionError('ERROR: Skipping file: %s' % (f))
Uploads a single file to AWS S3. If the post is unsuccessful
        it will retry every 10 seconds for 2 hours

        Args:
            filepath (str): filepath
            post (dict): post dictionary from S3 {url: (str), fields: dict}
            retry_period: number of seconds to wait before each rety
            retry_duration: total length of time to keep retrying (in seconds)

        Raises:
            ConnectionError
        
Uploads a single file to AWS S3. If the post is unsuccessful
it will retry every 10 seconds for 2 hours




Uploads a single file to AWS S3 . If the post is unsuccessful it will retry every 10 seconds for 2 hours
def post_file_to_s3(self, filepath, post, retry_period=10, retry_duration=7200):
        url = post['url']
        fields = post['fields']
        files = {'file': open(filepath, 'rb')}
        for attempt in range(retry_duration):
            try:
                r_s3 = requests.post(url, data=fields, files=files)
            except:
                print('...Trying to get to S3...')
                time.sleep(retry_period)
            else:
                break
        else:
            raise ConnectionError('ERROR: Skipping file: %s' % (f))
def post_file_to_s3 ( self , filepath , post , retry_period = 10 , retry_duration = 7200 ) : url = post [ 'url' ] fields = post [ 'fields' ] files = { 'file' : open ( filepath , 'rb' ) } for attempt in range ( retry_duration ) : try : r_s3 = requests . post ( url , data = fields , files = files ) except : print ( '...Trying to get to S3...' ) time . sleep ( retry_period ) else : break else : raise ConnectionError ( 'ERROR: Skipping file: %s' % ( f ) )
Uploads a single file to AWS S3.
Uploads a single file to AWS S3 .
"""Uploads a single file to AWS S3. If the post is unsuccessful
        it will retry every 10 seconds for 2 hours

        Args:
            filepath (str): filepath
            post (dict): post dictionary from S3 {url: (str), fields: dict}
            retry_period: number of seconds to wait before each rety
            retry_duration: total length of time to keep retrying (in seconds)

        Raises:
            ConnectionError
        """ # Parse fields # Open file io # Attempt to upload file bytes # Loop never hit break, i.e the request never went # through
self
filepath
post
retry_period
retry_duration