Rev | Line | |
---|
[976] | 1 | #!/usr/bin/python26
|
---|
| 2 | ###
|
---|
| 3 | ### backmon.commands.cat
|
---|
| 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 cat [filename]'
|
---|
| 17 |
|
---|
| 18 | parser = OptionParser(usage=usage)
|
---|
| 19 |
|
---|
| 20 | def run(args, kwargs):
|
---|
| 21 |
|
---|
| 22 | #
|
---|
| 23 | # add kwargs to local namespace
|
---|
| 24 | #
|
---|
| 25 | for key in kwargs.keys():
|
---|
| 26 |
|
---|
| 27 | if re.compile('^[A-Z][A-Z_]+$').match(key):
|
---|
| 28 | exec(key + ' = kwargs[\'' + key + '\']')
|
---|
| 29 |
|
---|
| 30 | (options, args) = parser.parse_args(args)
|
---|
| 31 |
|
---|
| 32 | if not OPTIONS.server:
|
---|
| 33 | ERROR('Please specify a server to use the cat command.')
|
---|
| 34 | sys.exit(1)
|
---|
| 35 | elif( len(args) == 0 ):
|
---|
| 36 | ERROR('No filename specified.')
|
---|
| 37 | sys.exit(1)
|
---|
| 38 | else:
|
---|
| 39 | filename = args.pop(0)
|
---|
| 40 | DEBUG('FILENAME=%s' % (filename))
|
---|
| 41 | updates = Updates(LOGGER, SERVER_PATH)
|
---|
| 42 |
|
---|
| 43 | file = updates.open(filename)
|
---|
| 44 |
|
---|
| 45 | if file is not None:
|
---|
| 46 | for line in file:
|
---|
| 47 | sys.stdout.write(line)
|
---|
| 48 | updates.close(filename)
|
---|
| 49 | else:
|
---|
| 50 | ERROR('Could not access file %s!' % (filename))
|
---|
| 51 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.