]> git.ipfire.org Git - people/jschlag/pbs.git/blob - src/scripts/pakfire-build-service
Fix spacing
[people/jschlag/pbs.git] / src / scripts / pakfire-build-service
1 #!/usr/bin/python
2
3 import sys
4
5 # Use tornado's logging options
6 import tornado.options
7 tornado.options.parse_command_line()
8
9 import pakfire.buildservice
10
11 class Cli(object):
12 def __init__(self, *args, **kwargs):
13 # Initialise backend
14 self.backend = pakfire.buildservice.Backend(*args, **kwargs)
15
16 self._commands = {
17 # Run mirror check
18 "check-mirrors" : self.backend.mirrors.check,
19
20 # Cleanup files
21 "cleanup-files" : self.backend.cleanup_files,
22
23 # Cleanup sessions
24 "cleanup-sessions" : self.backend.sessions.cleanup,
25
26 # Cleanup uploads
27 "cleanup-uploads" : self.backend.uploads.cleanup,
28
29 # Sends all queued messages
30 "process-message-queue" : self.backend.messages.process_queue,
31
32 # Pull sources
33 "pull-sources" : self.backend.sources.pull,
34
35 # Send bug updates to Bugzilla
36 "send-bug-updates" : self.backend.bugzilla.send_all,
37 }
38
39 def __call__(self, *args):
40 if not len(args) >= 2:
41 print >>sys.stderr, "Insufficient number of arguments"
42 return 2
43
44 args = list(args)
45 basename = args.pop(0)
46 command = args.pop(0)
47
48 # Get called command
49 try:
50 command = self._commands[command]
51 except KeyError:
52 print >>sys.stderr, "Command not found: %s" % command
53 return 2
54
55 # Execute command
56 r = command(*args)
57
58 # Exit with error code
59 sys.exit(r or 0)
60
61 # main
62
63 cli = Cli()
64 cli(*sys.argv)