2
# Copyright (c) 2009 Chris Moyer http://coredumped.org/
4
# Permission is hereby granted, free of charge, to any person obtaining a
5
# copy of this software and associated documentation files (the
6
# "Software"), to deal in the Software without restriction, including
7
# without limitation the rights to use, copy, modify, merge, publish, dis-
8
# tribute, sublicense, and/or sell copies of the Software, and to permit
9
# persons to whom the Software is furnished to do so, subject to the fol-
12
# The above copyright notice and this permission notice shall be included
13
# in all copies or substantial portions of the Software.
15
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABIL-
17
# ITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
18
# SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
23
# Task/Job Administration utility
27
usage = """%prog [options] [command]
29
list|ls List all Tasks in SDB
30
delete <id> Delete Task with id <id>
31
get <name> Get Task <name>
32
create|mk <name> <hour> <command> Create a new Task <name> with command <command> running every <hour>
36
"""List all Tasks in SDB"""
37
from boto.manage.task import Task
38
print "%-8s %-40s %s" % ("Hour", "Name", "Command")
41
print "%-8s %-40s %s" % (t.hour, t.name, t.command)
45
:param name: The name of the task to fetch
48
from boto.manage.task import Task
50
q.filter("name like", "%s%%" % name)
54
print "|%s" % ("-"*79)
55
print "| Name: ", t.name
56
print "| Hour: ", t.hour
57
print "| Command: ", t.command
59
print "| Last Run: ", t.last_executed.ctime()
60
print "| Last Status: ", t.last_status
61
print "| Last Run Log: ", t.last_output
65
from boto.manage.task import Task
66
t = Task.get_by_id(id)
67
print "Deleting task: %s" % t.name
68
if raw_input("Are you sure? ").lower() in ["y", "yes"]:
74
def create(name, hour, command):
76
:param name: Name of the task to create
78
:param hour: What hour to run it at, "*" for every hour
80
:param command: The command to execute
83
from boto.manage.task import Task
89
print "Created task: %s" % t.id
91
if __name__ == "__main__":
98
from optparse import OptionParser
99
from boto.mashups.iobject import IObject
100
parser = OptionParser(version=__version__, usage=usage)
102
(options, args) = parser.parse_args()
108
command = args[0].lower()
109
if command in ("ls", "list"):
111
elif command == "get":
113
elif command == "create":
114
create(args[1], args[2], args[3])
115
elif command == "delete":