viasegura/downloader.py
def download(self, url = None, aws_access_key=None, signature = None, expires = None):
		"""
		This function allows to dowload the corresponding packages using the route already on the created instance

		Parameters
		----------
		
		url: str
			The signed url for downloading the models

		aws_access_key: str
			The aws access key id provided by the interamerican development bank to have access to the models

		signature: str
			The aws signature provided from IDB to download the models

		expires: int
			Time in seconds provided by the IDB in which the signature will expire

		"""
		if url:
			self.models_path.mkdir(parents=True, exist_ok=True)
			temp_file_path = tempfile.NamedTemporaryFile(suffix='.tar.gz').name
			logger.info('Downloading models')
			try:
				request.urlretrieve(url, temp_file_path)
			except:
				raise TypeError('Provided signature is invalid.')

			logger.info('Uncompressing models')
			with tarfile.open(temp_file_path, mode='r:gz') as tfile:
				tfile.extractall(str(self.models_path))
			logger.info('Models are available')
			os.remove(temp_file_path)
		elif aws_access_key:
			self.models_path.mkdir(parents=True, exist_ok=True)
			params = {
				'AWSAccessKeyId': aws_access_key,
				'Signature': signature,
				'Expires': expires
			}
			composed_url = '{}?{}'.format(models_url, parse.urlencode(params))
			temp_file_path = tempfile.NamedTemporaryFile(suffix='.tar.gz').name
			logger.info('Downloading models')
			try:
				request.urlretrieve(composed_url, temp_file_path)
			except:
				raise TypeError('Provided signature is invalid.')
			logger.info('Uncompressing models')
			with tarfile.open(temp_file_path, mode='r:gz') as tfile:
				tfile.extractall(str(self.models_path))
			logger.info('Models are available')
			os.remove(temp_file_path)
		else:
			raise NameError('Must provide any valid method of download either signature or valid url, please contact IDB to obtain the proper data')

		This function allows to dowload the corresponding packages using the route already on the created instance

		Parameters
		----------
		
		url: str
			The signed url for downloading the models

		aws_access_key: str
			The aws access key id provided by the interamerican development bank to have access to the models

		signature: str
			The aws signature provided from IDB to download the models

		expires: int
			Time in seconds provided by the IDB in which the signature will expire

		
This function allows to dowload the corresponding packages using the route already on the created instance
Parameters

str
The signed url for downloading the models

str
The aws access key id provided by the interamerican development bank to have access to the models

str
The aws signature provided from IDB to download the models

int
Time in seconds provided by the IDB in which the signature will expire
This function allows to dowload the corresponding packages using the route already on the created instance Parameters str The signed url for downloading the models str The aws access key id provided by the interamerican development bank to have access to the models str The aws signature provided from IDB to download the models int Time in seconds provided by the IDB in which the signature will expire
def download(self, url = None, aws_access_key=None, signature = None, expires = None):
		if url:
			self.models_path.mkdir(parents=True, exist_ok=True)
			temp_file_path = tempfile.NamedTemporaryFile(suffix='.tar.gz').name
			logger.info('Downloading models')
			try:
				request.urlretrieve(url, temp_file_path)
			except:
				raise TypeError('Provided signature is invalid.')
			logger.info('Uncompressing models')
			with tarfile.open(temp_file_path, mode='r:gz') as tfile:
				tfile.extractall(str(self.models_path))
			logger.info('Models are available')
			os.remove(temp_file_path)
		elif aws_access_key:
			self.models_path.mkdir(parents=True, exist_ok=True)
			params = {
				'AWSAccessKeyId': aws_access_key,
				'Signature': signature,
				'Expires': expires
			}
			composed_url = '{}?{}'.format(models_url, parse.urlencode(params))
			temp_file_path = tempfile.NamedTemporaryFile(suffix='.tar.gz').name
			logger.info('Downloading models')
			try:
				request.urlretrieve(composed_url, temp_file_path)
			except:
				raise TypeError('Provided signature is invalid.')
			logger.info('Uncompressing models')
			with tarfile.open(temp_file_path, mode='r:gz') as tfile:
				tfile.extractall(str(self.models_path))
			logger.info('Models are available')
			os.remove(temp_file_path)
		else:
			raise NameError('Must provide any valid method of download either signature or valid url, please contact IDB to obtain the proper data')
def download ( self , url = None , aws_access_key = None , signature = None , expires = None ) : if url : self . models_path . mkdir ( parents = True , exist_ok = True ) temp_file_path = tempfile . NamedTemporaryFile ( suffix = '.tar.gz' ) . name logger . info ( 'Downloading models' ) try : request . urlretrieve ( url , temp_file_path ) except : raise TypeError ( 'Provided signature is invalid.' ) logger . info ( 'Uncompressing models' ) with tarfile . open ( temp_file_path , mode = 'r:gz' ) as tfile : tfile . extractall ( str ( self . models_path ) ) logger . info ( 'Models are available' ) os . remove ( temp_file_path ) elif aws_access_key : self . models_path . mkdir ( parents = True , exist_ok = True ) params = { 'AWSAccessKeyId' : aws_access_key , 'Signature' : signature , 'Expires' : expires } composed_url = '{}?{}' . format ( models_url , parse . urlencode ( params ) ) temp_file_path = tempfile . NamedTemporaryFile ( suffix = '.tar.gz' ) . name logger . info ( 'Downloading models' ) try : request . urlretrieve ( composed_url , temp_file_path ) except : raise TypeError ( 'Provided signature is invalid.' ) logger . info ( 'Uncompressing models' ) with tarfile . open ( temp_file_path , mode = 'r:gz' ) as tfile : tfile . extractall ( str ( self . models_path ) ) logger . info ( 'Models are available' ) os . remove ( temp_file_path ) else : raise NameError ( 'Must provide any valid method of download either signature or valid url, please contact IDB to obtain the proper data' )
This function allows to dowload the corresponding packages using the route already on the created instance
Parameters
This function allows to dowload the corresponding packages using the route already on the created instance Parameters
"""
		This function allows to dowload the corresponding packages using the route already on the created instance

		Parameters
		----------
		
		url: str
			The signed url for downloading the models

		aws_access_key: str
			The aws access key id provided by the interamerican development bank to have access to the models

		signature: str
			The aws signature provided from IDB to download the models

		expires: int
			Time in seconds provided by the IDB in which the signature will expire

		"""
self
url
aws_access_key
signature
expires