Skip to main content

Posts

Showing posts from March, 2022

Creating your own Speedtest utility in Python

It is easy to create your own speedtest utility in Python. You will require Speedtest-CLI module to build your utility. To install Speedtest-cli, run “ pip install speedtest-cli ” command Once speedtest-cli is installed, import it into your Python file. import speedtest result = speedtest . Speedtest ()   Following code will help you to find the best Speedtest server depending on your location best_server = result . get_best_server () print ( f "Checking speedtest using server located in { best_server [ 'country' ] } " )   Now, run the speed test for Download, Upload and ping result. # Running the download speed print ( "Running download speedtest..." ) dw_result = result . download () # Running the upload spped print ( "Running upload speedtest..." ) up_result = result . upload () # Running a ping test ping_result = result . results . ping   Using below code, you can covert the result in to Mbps and truncate the value to 2 decima

Python - Getting AWS account ID

Here is the Python script that helps to find out the AWS account id. # The script helps you to find out AWS account number import boto3 # Configure AWS access key and secret access key to access AWS resources access_key_id = "test-key" secret_access_key_id = "secret-key" sts = boto3 . client (     "sts" , aws_access_key_id = access_key_id , aws_secret_access_key = secret_access_key_id , ) account_id = sts .get_caller_identity()[ "Account" ] # Print account number print ( account_id ) # The following code helps you to return AWS account number when IAM role based permissions are used account_id = boto3 . client ( "sts" ).get_caller_identity()[ "Account" ] # Print account number print ( account_id ) Hope you find it useful. Disclaimer: www.TechieTalks.co.uk does not conceal the possibility of error and shortcomings due to human or technical factors. www.TechieTalks.co.uk does not bear responsibility upon any loss or da