How to use the awsume.awsumepy.safe_print function in awsume

To help you get started, we’ve selected a few awsume examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github trek10inc / awsume / examplePlugin / console.py View on Github external
"""Create a properly formatted json string of the given session. Return the session and the region to use."""
        if session.get('AccessKeyId') and session.get('SecretAccessKey') and session.get('SessionToken'):
            aws_region = 'us-east-1'
            temp_credentials = {
                'sessionId': session['AccessKeyId'],
                'sessionKey': session['SecretAccessKey'],
            }
            if 'SessionToken' in session:
                temp_credentials['sessionToken'] = session['SessionToken']
            if session.get('region'):
                aws_region = session['region']

            #format the credentials into a json formatted string
            json_temp_credentials = json.dumps(temp_credentials)
            return json_temp_credentials, aws_region
        awsumepy.safe_print('Cannot use these credentials to open the AWS Console.')
        exit(0)
github trek10inc / awsume / examplePlugin / console.py View on Github external
'sessionId': auto_profile['aws_access_key_id'],
                'sessionKey': auto_profile['aws_secret_access_key'],
                'sessionToken': auto_profile['aws_session_token']
            }
            if auto_profile.get('aws_region'):
                aws_region = auto_profile.get('aws_region')
        elif os.environ.get('AWS_ACCESS_KEY_ID') and os.environ.get('AWS_SECRET_ACCESS_KEY') and os.environ.get('AWS_SESSION_TOKEN'):
            temp_credentials = {
                'sessionId': os.environ['AWS_ACCESS_KEY_ID'],
                'sessionKey': os.environ['AWS_SECRET_ACCESS_KEY'],
                'sessionToken': os.environ['AWS_SESSION_TOKEN']
            }
            if os.environ.get('AWS_REGION'):
                aws_region = os.environ['AWS_REGION']
        else:
            awsumepy.safe_print('Cannot use these credentials to open the AWS Console.')
            exit(0)
        json_temp_credentials = json.dumps(temp_credentials)
        return json_temp_credentials, aws_region
github trek10inc / awsume / examplePlugin / console.py View on Github external
def open_browser_to_url(self, url, args):
        """Open the default browser to the given url. If that fails, display the url."""
        if args.open_console_link:
            awsumepy.safe_print(url)
        else:
            try:
                webbrowser.open(url)
            except Exception:
                awsumepy.safe_print('Cannot open browser, here is the link:')
                awsumepy.safe_print(url)
github trek10inc / awsume / examplePlugin / console.py View on Github external
def open_browser_to_url(self, url, args):
        """Open the default browser to the given url. If that fails, display the url."""
        if args.open_console_link:
            awsumepy.safe_print(url)
        else:
            try:
                webbrowser.open(url)
            except Exception:
                awsumepy.safe_print('Cannot open browser, here is the link:')
                awsumepy.safe_print(url)
github trek10inc / awsume / examplePlugin / console.py View on Github external
def open_browser_to_url(self, url, args):
        """Open the default browser to the given url. If that fails, display the url."""
        if args.open_console_link:
            awsumepy.safe_print(url)
        else:
            try:
                webbrowser.open(url)
            except Exception:
                awsumepy.safe_print('Cannot open browser, here is the link:')
                awsumepy.safe_print(url)