Skip to content

rightlag/timely

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

timely Travis PEP8

timely 0.2.0

Released: 2-Sep-2015

Introduction

timely is a Python package that allows users to manage the uptime of their Amazon Web Services EC2 containers by providing times at which the containers should be running for any day of the week.

Requirements

timely requires an AWS_ACCESS_KEY_ID and an AWS_SECRET_ACCESS_KEY. These can be configured by either exporting environment variables or creating a ~/.boto configuration file.

All commits are tested with Travis CI and also require the AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY environment variables to be set.

Code Samples

Fetch all containers and their times

>>> from timely import Timely
>>> timely = Timely()
>>> print(timely.all())
{u'i-6dc5bc92': [Time(weekday='Monday', start_time=datetime.time(9, 0, tzinfo=<DstTzInfo 'US/Eastern' LMT-1 day, 19:04:00 STD>), end_time=datetime.time(17, 0, tzinfo=<DstTzInfo 'US/Eastern' LMT-1 day, 19:04:00 STD>))]}

Set times for all containers during certain days of the week

>>> from timely import Timely
>>> from datetime import time
>>> timely = Timely()
>>> t1 = time(9, 0)
>>> t2 = time(17, 0)
>>> timely.set(t1, t2, weekdays=['Monday'])

Check if containers should be running

>>> from timely import Timely
>>> timely = Timely(verbose=True)
>>> timely.check()
starting instance: i-6dc5bc92

Using timezones

By default, timely sets the default timezone to US/Eastern. However, this can be changed upon instantiation of the timely class or via the set_tz method. For example:

>>> from timely import Timely
>>> timely = Timely(tz='US/Pacific')
>>> timely.tz = 'US/Mountain'
>>> print(timely.tz)
US/Mountain

If the timezone specified does not exist, then UTC is used.

When assigning the timezone, the set method will create a tag tz for EC2 containers with the timezone that was specified. Whenever the check method is called, the tz tag that is assigned to the EC2 container is used to determine whether or not it should be running.

About

Manage the uptime of AWS EC2 containers

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages