build/lib/lottie_animation_manager/__main__.py
def initialize_configuration():
	"""
		This is for "first time" usage of the Lottie Animation Manager Command line Utility.
		If the user is already configured, they will just be redirected to the main menu.
		Otherwise, they will be asked for two things:
		1) Which S3 Bucket they want to upload lottie animation assets to
		2) What their TinyPNG API key is (if they actually want to use it)
		Lottie Animation Manager uses Python's keyring library in order to store this information sort of securely.
	"""
	global bucket
	global configured_tiny_png_key
	global compression_enabled
	global bucket_name_final

	# Detect if the configuration was successfully completed in the past
	if(keyring.get_password(LOTTIE_KEYRING_SERVICE_ID, 'lottie_animation_manager_config_complete') == 'true'):
		# grab the stored configuration values
		# s3 bucket
		bucket_name = keyring.get_password(LOTTIE_KEYRING_SERVICE_ID, 's3_bucket_name')
		bucket = conn.get_bucket(bucket_name)
		bucket_name_final = bucket_name

		# configured tinypng API info (if any)
		configured_tiny_png_key = keyring.get_password(LOTTIE_KEYRING_SERVICE_ID, 'tiny_png_credentials')

		if configured_tiny_png_key == False:
			compression_enabled = False
		main_menu()
	else:
		# Clear screen
		click.clear()
		# Window Title
		click.echo(click.style(emoji.emojize('  Lottie Animation Manager Setup Wizard  '), bg='green', fg="bright_white"))
		click.echo('\n')
		# Initial instructions
		click.echo(click.style('Thanks for downloading Lottie Animation Manager!', fg="green"))
		click.echo(click.style('LAM depends on a few services:', fg="green"))
		click.echo(click.style('- Amazon Web Services S3 + Cloudfront', fg="bright_cyan"))
		click.echo(click.style('Follow the instructions in our docs on setting up these services.', fg="bright_cyan"))
		click.echo(click.style('LAM utilizes your local default AWS configuration/profile keys to upload media. You\'ll need to download the AWS CLI locally and configure it correctly.', fg="bright_cyan"))
		click.echo(click.style('- TinyPNG (optional)', fg="bright_cyan"))
		click.echo(click.style('Easily compress images in your lottie assets folder before uploading to them your CDN.  API key needed for this.', fg="bright_cyan"))

		# Please enter your bucket name 
		bucket_set = False
		while(bucket_set == False):
			bucket_name = click.prompt('Please enter the name of your AWS bucket where assets will be stored')
			try:
				bucket = conn.get_bucket(bucket_name)
				keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 's3_bucket_name', bucket_name)
				bucket_name_final = bucket_name
				bucket_set = True
			except:
				click.echo(click.style("Could not connect to '{}' bucket, please try again".format(bucket_name), fg="red"))

		# Please enter your tinyPNG stuff
		tiny_png_key = click.prompt('Please enter your TinyPNG Key or enter "skip" to disable image compression')
		if(tiny_png_key.lower() != 'skip'):
			keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 'tiny_png_credentials', tiny_png_key)
			configured_tiny_png_key = tiny_png_key
			compression_enabled = True
		else:
			compression_enabled = False
			keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 'tiny_png_credentials', "false")

		# Mark configuration as complete now
		keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 'lottie_animation_manager_config_complete', "true")
		main_menu()

		This is for "first time" usage of the Lottie Animation Manager Command line Utility.
		If the user is already configured, they will just be redirected to the main menu.
		Otherwise, they will be asked for two things:
		1) Which S3 Bucket they want to upload lottie animation assets to
		2) What their TinyPNG API key is (if they actually want to use it)
		Lottie Animation Manager uses Python's keyring library in order to store this information sort of securely.
	
This is for "first time" usage of the Lottie Animation Manager Command line Utility.
If the user is already configured, they will just be redirected to the main menu.
Otherwise, they will be asked for two things:
1) Which S3 Bucket they want to upload lottie animation assets to
2) What their TinyPNG API key is (if they actually want to use it)
Lottie Animation Manager uses Python's keyring library in order to store this information sort of securely.
This is for " first time " usage of the Lottie Animation Manager Command line Utility . If the user is already configured they will just be redirected to the main menu . Otherwise they will be asked for two things : 1 ) Which S3 Bucket they want to upload lottie animation assets to 2 ) What their TinyPNG API key is ( if they actually want to use it ) Lottie Animation Manager uses Python ' s keyring library in order to store this information sort of securely .
def initialize_configuration():
	global bucket
	global configured_tiny_png_key
	global compression_enabled
	global bucket_name_final
	if(keyring.get_password(LOTTIE_KEYRING_SERVICE_ID, 'lottie_animation_manager_config_complete') == 'true'):
		bucket_name = keyring.get_password(LOTTIE_KEYRING_SERVICE_ID, 's3_bucket_name')
		bucket = conn.get_bucket(bucket_name)
		bucket_name_final = bucket_name
		configured_tiny_png_key = keyring.get_password(LOTTIE_KEYRING_SERVICE_ID, 'tiny_png_credentials')
		if configured_tiny_png_key == False:
			compression_enabled = False
		main_menu()
	else:
		click.clear()
		click.echo(click.style(emoji.emojize('  Lottie Animation Manager Setup Wizard  '), bg='green', fg="bright_white"))
		click.echo('\n')
		click.echo(click.style('Thanks for downloading Lottie Animation Manager!', fg="green"))
		click.echo(click.style('LAM depends on a few services:', fg="green"))
		click.echo(click.style('- Amazon Web Services S3 + Cloudfront', fg="bright_cyan"))
		click.echo(click.style('Follow the instructions in our docs on setting up these services.', fg="bright_cyan"))
		click.echo(click.style('LAM utilizes your local default AWS configuration/profile keys to upload media. You\'ll need to download the AWS CLI locally and configure it correctly.', fg="bright_cyan"))
		click.echo(click.style('- TinyPNG (optional)', fg="bright_cyan"))
		click.echo(click.style('Easily compress images in your lottie assets folder before uploading to them your CDN.  API key needed for this.', fg="bright_cyan"))
		bucket_set = False
		while(bucket_set == False):
			bucket_name = click.prompt('Please enter the name of your AWS bucket where assets will be stored')
			try:
				bucket = conn.get_bucket(bucket_name)
				keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 's3_bucket_name', bucket_name)
				bucket_name_final = bucket_name
				bucket_set = True
			except:
				click.echo(click.style("Could not connect to '{}' bucket, please try again".format(bucket_name), fg="red"))
		tiny_png_key = click.prompt('Please enter your TinyPNG Key or enter "skip" to disable image compression')
		if(tiny_png_key.lower() != 'skip'):
			keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 'tiny_png_credentials', tiny_png_key)
			configured_tiny_png_key = tiny_png_key
			compression_enabled = True
		else:
			compression_enabled = False
			keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 'tiny_png_credentials', "false")
		keyring.set_password(LOTTIE_KEYRING_SERVICE_ID, 'lottie_animation_manager_config_complete', "true")
		main_menu()
def initialize_configuration ( ) : global bucket global configured_tiny_png_key global compression_enabled global bucket_name_final if ( keyring . get_password ( LOTTIE_KEYRING_SERVICE_ID , 'lottie_animation_manager_config_complete' ) == 'true' ) : bucket_name = keyring . get_password ( LOTTIE_KEYRING_SERVICE_ID , 's3_bucket_name' ) bucket = conn . get_bucket ( bucket_name ) bucket_name_final = bucket_name configured_tiny_png_key = keyring . get_password ( LOTTIE_KEYRING_SERVICE_ID , 'tiny_png_credentials' ) if configured_tiny_png_key == False : compression_enabled = False main_menu ( ) else : click . clear ( ) click . echo ( click . style ( emoji . emojize ( '  Lottie Animation Manager Setup Wizard  ' ) , bg = 'green' , fg = "bright_white" ) ) click . echo ( '\n' ) click . echo ( click . style ( 'Thanks for downloading Lottie Animation Manager!' , fg = "green" ) ) click . echo ( click . style ( 'LAM depends on a few services:' , fg = "green" ) ) click . echo ( click . style ( '- Amazon Web Services S3 + Cloudfront' , fg = "bright_cyan" ) ) click . echo ( click . style ( 'Follow the instructions in our docs on setting up these services.' , fg = "bright_cyan" ) ) click . echo ( click . style ( 'LAM utilizes your local default AWS configuration/profile keys to upload media. You\'ll need to download the AWS CLI locally and configure it correctly.' , fg = "bright_cyan" ) ) click . echo ( click . style ( '- TinyPNG (optional)' , fg = "bright_cyan" ) ) click . echo ( click . style ( 'Easily compress images in your lottie assets folder before uploading to them your CDN.  API key needed for this.' , fg = "bright_cyan" ) ) bucket_set = False while ( bucket_set == False ) : bucket_name = click . prompt ( 'Please enter the name of your AWS bucket where assets will be stored' ) try : bucket = conn . get_bucket ( bucket_name ) keyring . set_password ( LOTTIE_KEYRING_SERVICE_ID , 's3_bucket_name' , bucket_name ) bucket_name_final = bucket_name bucket_set = True except : click . echo ( click . style ( "Could not connect to '{}' bucket, please try again" . format ( bucket_name ) , fg = "red" ) ) tiny_png_key = click . prompt ( 'Please enter your TinyPNG Key or enter "skip" to disable image compression' ) if ( tiny_png_key . lower ( ) != 'skip' ) : keyring . set_password ( LOTTIE_KEYRING_SERVICE_ID , 'tiny_png_credentials' , tiny_png_key ) configured_tiny_png_key = tiny_png_key compression_enabled = True else : compression_enabled = False keyring . set_password ( LOTTIE_KEYRING_SERVICE_ID , 'tiny_png_credentials' , "false" ) keyring . set_password ( LOTTIE_KEYRING_SERVICE_ID , 'lottie_animation_manager_config_complete' , "true" ) main_menu ( )
This is for "first time" usage of the Lottie Animation Manager Command line Utility.
This is for " first time " usage of the Lottie Animation Manager Command line Utility .
"""
		This is for "first time" usage of the Lottie Animation Manager Command line Utility.
		If the user is already configured, they will just be redirected to the main menu.
		Otherwise, they will be asked for two things:
		1) Which S3 Bucket they want to upload lottie animation assets to
		2) What their TinyPNG API key is (if they actually want to use it)
		Lottie Animation Manager uses Python's keyring library in order to store this information sort of securely.
	""" # Detect if the configuration was successfully completed in the past # grab the stored configuration values # s3 bucket # configured tinypng API info (if any) # Clear screen # Window Title # Initial instructions # Please enter your bucket name  # Please enter your tinyPNG stuff # Mark configuration as complete now