]> git.ipfire.org Git - people/jschlag/pbs.git/blame - src/scripts/pakfire-build-service
cli: Add command to send all emails
[people/jschlag/pbs.git] / src / scripts / pakfire-build-service
CommitLineData
43025dca
MT
1#!/usr/bin/python
2
3import sys
4
5# Use tornado's logging options
6import tornado.options
7tornado.options.parse_command_line()
8
9import pakfire.buildservice
10
11class Cli(object):
12 def __init__(self, *args, **kwargs):
13 # Initialise backend
14 self.backend = pakfire.buildservice.Backend(*args, **kwargs)
15
c06ce6d1
MT
16 self._commands = {
17 # Sends all queued messages
18 "process-message-queue" : self.backend.messages.process_queue,
19 }
43025dca
MT
20
21 def __call__(self, *args):
22 if not len(args) >= 2:
23 print >>sys.stderr, "Insufficient number of arguments"
24 return 2
25
26 args = list(args)
27 basename = args.pop(0)
28 command = args.pop(0)
29
30 # Get called command
31 try:
32 command = self._commands[command]
33 except KeyError:
34 print >>sys.stderr, "Command not found: %s" % command
35 return 2
36
37 # Execute command
38 r = command(*args)
39
40 # Exit with error code
41 sys.exit(r or 0)
42
43# main
44
45cli = Cli()
46cli(*sys.argv)