summaryrefslogtreecommitdiffstats
path: root/py3status
diff options
context:
space:
mode:
Diffstat (limited to 'py3status')
-rwxr-xr-xpy3status/modules/aws_bill.py23
1 files changed, 10 insertions, 13 deletions
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)