source: people/peter.buschman/backup_monitoring/backmon/commands/feed.py@ 976

Last change on this file since 976 was 976, checked in by peter, on Dec 6, 2011 at 10:19:33 AM

Raw checkin of current NetBackup / TSM parsing code.

File size: 1.3 KB
RevLine 
[976]1#!/usr/bin/python26
2###
3### backmon.commands.feed
4###
5
6import sys
7import os
8import os.path
9import glob
10import re
11
12from optparse import OptionParser
13
14from ..lib import *
15
16usage = 'usage: %prog -s server feed [feed]'
17
18parser = OptionParser(usage=usage)
19
20parser.add_option('-l', '--lock', action='store_true', dest='lock', default=False, help='lock matching feeds')
21
22def 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.