Line | |
---|
1 | #!/usr/bin/python26
|
---|
2 | ###
|
---|
3 | ### backmon.commands.feed
|
---|
4 | ###
|
---|
5 |
|
---|
6 | import sys
|
---|
7 | import os
|
---|
8 | import os.path
|
---|
9 | import glob
|
---|
10 | import re
|
---|
11 |
|
---|
12 | from optparse import OptionParser
|
---|
13 |
|
---|
14 | from ..lib import *
|
---|
15 |
|
---|
16 | usage = 'usage: %prog -s server feed [feed]'
|
---|
17 |
|
---|
18 | parser = OptionParser(usage=usage)
|
---|
19 |
|
---|
20 | parser.add_option('-l', '--lock', action='store_true', dest='lock', default=False, help='lock matching feeds')
|
---|
21 |
|
---|
22 | def run(args, kwargs):
|
---|
23 |
|
---|
24 | #
|
---|
25 | # add kwargs to local namespace
|
---|
26 | #
|
---|
27 | for key in kwargs.keys():
|
---|
28 |
|
---|
29 | if re.compile('^[A-Z][A-Z_]+$').match(key):
|
---|
30 | exec(key + ' = kwargs[\'' + key + '\']')
|
---|
31 |
|
---|
32 | (options, args) = parser.parse_args(args)
|
---|
33 |
|
---|
34 | if not OPTIONS.server:
|
---|
35 | ERROR('Please specify a server to use the feed command.')
|
---|
36 | sys.exit(1)
|
---|
37 | elif( len(args) == 0 ):
|
---|
38 | ERROR('No feed specified.')
|
---|
39 | sys.exit(1)
|
---|
40 | else:
|
---|
41 | feed = args.pop(0)
|
---|
42 | DEBUG('FEED=%s' % (feed))
|
---|
43 | updates = Updates(LOGGER, SERVER_PATH)
|
---|
44 |
|
---|
45 | filename = '%s.txt' % (feed)
|
---|
46 | file = updates.open(filename)
|
---|
47 |
|
---|
48 | if file is not None:
|
---|
49 | for line in file:
|
---|
50 | sys.stdout.write(line)
|
---|
51 | updates.close(filename)
|
---|
52 | else:
|
---|
53 | ERROR('Could not access file %s!' % (filename))
|
---|
54 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.