From cfa9966aa6f881277fbb8680d44ce30862aa233b Mon Sep 17 00:00:00 2001 From: Anthony Brodard Date: Wed, 29 Apr 2015 17:31:41 +0200 Subject: Typo fix + yapf compliance --- py3status/modules/aws_bill.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'py3status/modules/aws_bill.py') diff --git a/py3status/modules/aws_bill.py b/py3status/modules/aws_bill.py index 8ca5f42..f2dd5dc 100755 --- a/py3status/modules/aws_bill.py +++ b/py3status/modules/aws_bill.py @@ -3,23 +3,23 @@ Display the current AWS bill. ##### WARNING ##### -This module generate some costs on the AWS bill. Take care about the cache_timout 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_secret_access_key : Your AWS secret key - aws_account_id : the root ID of the AWS account. Can be find here https://console.aws.amazon.com/billing/home#/account - - 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_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 @author nawadanp """ +import boto import csv import datetime -import boto from boto.s3.connection import Key from time import time @@ -29,24 +29,24 @@ class Py3status: # available configuration parameters aws_access_key_id = '' - aws_secret_access_key = '' aws_account_id = '' - s3_bucket_name = '' + aws_secret_access_key = '' billing_file = '/tmp/.aws_billing.csv' cache_timeout = 3600 + s3_bucket_name = '' 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' + '%Y') + '-' + datetime.datetime.now().strftime('%m') + '.csv' i = 0 # Connection to s3 service try: - conn = boto.connect_s3( - self.aws_access_key_id, self.aws_secret_access_key) + conn = boto.connect_s3(self.aws_access_key_id, + self.aws_secret_access_key) except: return 'conn_error' @@ -111,10 +111,7 @@ if __name__ == "__main__": """ from time import sleep x = Py3status() - config = { - 'color_good': '#00FF00', - 'color_bad': '#FF0000', - } + config = {'color_good': '#00FF00', 'color_bad': '#FF0000', } while True: print(x.aws_bill([], config)) sleep(1) -- cgit v1.3