]> git.ipfire.org Git - people/jschlag/pbs.git/blame - src/scripts/pakfire-build-service
Regularly cleanup files
[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 16 self._commands = {
c660ff59
MT
17 # Run mirror check
18 "check-mirrors" : self.backend.mirrors.check,
19
0f302058
MT
20 # Cleanup files
21 "cleanup-files" : self.backend.cleanup_files,
22
ca4f2d92
MT
23 # Cleanup sessions
24 "cleanup-sessions" : self.backend.sessions.cleanup,
25
be8d5956
MT
26 # Cleanup uploads
27 "cleanup-uploads" : self.backend.uploads.cleanup,
28
c06ce6d1
MT
29 # Sends all queued messages
30 "process-message-queue" : self.backend.messages.process_queue,
76353712
MT
31
32 # Send bug updates to Bugzilla
33 "send-bug-updates" : self.backend.bugzilla.send_all,
c06ce6d1 34 }
43025dca
MT
35
36 def __call__(self, *args):
37 if not len(args) >= 2:
38 print >>sys.stderr, "Insufficient number of arguments"
39 return 2
40
41 args = list(args)
42 basename = args.pop(0)
43 command = args.pop(0)
44
45 # Get called command
46 try:
47 command = self._commands[command]
48 except KeyError:
49 print >>sys.stderr, "Command not found: %s" % command
50 return 2
51
52 # Execute command
53 r = command(*args)
54
55 # Exit with error code
56 sys.exit(r or 0)
57
58# main
59
60cli = Cli()
61cli(*sys.argv)