Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def create_directory(dir_name):
"""Create directories on the local machine."""
if os.path.isdir(dir_name) is False:
try:
os.mkdir(dir_name)
except OSError as error:
logging.error("Cannot continue creating directory \'{}\': {}".format(
settings.config_dir, error.strerror))
sys.exit(1)
def update_configuration(okta_file, profile):
"""Update okta configuration file on local system.
:param okta_file: Default configuration system file
:param profile: profile of the okta user
:return:
"""
logging.debug("Update okta configuration file on local system.")
config = configparser.RawConfigParser()
create_directory(settings.config_dir)
if os.path.isfile(okta_file):
logging.debug("Read Okta config [{} {}]".format(okta_file, profile))
config.read(okta_file, encoding=settings.encoding)
if not config.has_section(profile):
config.add_section(profile)
logging.debug("Add section to Okta config [{}]".format(profile))
(app_url, username) = user_configuration_input()
url = urlparse(app_url.strip())
okta_username = username.strip()
okta_aws_app_url = '{}://{}{}'.format(url.scheme, url.netloc, url.path)
config.set(profile, 'okta_aws_app_url', okta_aws_app_url)