From c641345cef92219085ac936f60dff1cbb8f57012 Mon Sep 17 00:00:00 2001 From: Ultrabug Date: Thu, 30 Apr 2015 10:21:14 +0200 Subject: QA on aws_bill module --- py3status/modules/aws_bill.py | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/py3status/modules/aws_bill.py b/py3status/modules/aws_bill.py index f2dd5dc..98643f6 100755 --- a/py3status/modules/aws_bill.py +++ b/py3status/modules/aws_bill.py @@ -3,16 +3,23 @@ Display the current AWS bill. ##### WARNING ##### -This module generate some costs on the AWS bill. Take care about the cache_timeout to limit these fees ! +This module generate some costs on the AWS bill. +Take care about the cache_timeout to limit these fees ! ##### WARNING ##### Configuration parameters: - - aws_access_key_id : Your AWS access key - - aws_account_id : the root ID of the AWS account. Can be find here https://console.aws.amazon.com/billing/home#/account - - aws_secret_access_key : Your AWS secret key - - billing_file : csv file location - - cache_timeout : how often we refresh this module in seconds - - s3_bucket_name : the bucket where billing files are sent by AWS. Follow this article to activate this feature : http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/detailed-billing-reports.html + - aws_access_key_id: Your AWS access key + - aws_account_id: the root ID of the AWS account. + Can be found here: https://console.aws.amazon.com/billing/home#/account + - aws_secret_access_key: Your AWS secret key + - billing_file: csv file location + - cache_timeout: how often we refresh this module in seconds + - s3_bucket_name: the bucket where billing files are sent by AWS. + Follow this article to activate this feature: + http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/detailed-billing-reports.html + +Requires: + - boto @author nawadanp """ @@ -26,7 +33,8 @@ from time import time class Py3status: - + """ + """ # available configuration parameters aws_access_key_id = '' aws_account_id = '' @@ -38,9 +46,9 @@ class Py3status: def _get_bill_amount(self): # Billing file name, generated by Amazon itself # Format : 123456789012-aws-billing-csv-yyyy-mm.csv - s3_file_key = self.aws_account_id + '-aws-billing-csv-' + \ - datetime.datetime.now().strftime( - '%Y') + '-' + datetime.datetime.now().strftime('%m') + '.csv' + s3_file_key = '{}-aws-billing-csv-{}-{}.csv'.format( + self.aws_account_id, datetime.datetime.now().strftime('%Y'), + datetime.datetime.now().strftime('%m')) i = 0 # Connection to s3 service @@ -111,7 +119,11 @@ if __name__ == "__main__": """ from time import sleep x = Py3status() - config = {'color_good': '#00FF00', 'color_bad': '#FF0000', } + config = { + 'color_bad': '#FF0000', + 'color_degraded': '#FFFF00', + 'color_good': '#00FF00' + } while True: print(x.aws_bill([], config)) sleep(1) -- cgit v1.3