#!/usr/bin/python
-import moira
+import optparse
import sys
+import moira
+
cache = {}
def get_members_of_list(lst):
result = expand(lst)
print_tree([lst], result)
+def parse_args():
+ parser = optparse.OptionParser(usage='usage: %prog [--auth=yes|no|try] list')
+ parser.add_option('--auth', dest='auth', default=None, )
+ options, args = parser.parse_args()
+
+ if len(args) != 1:
+ parser.error("incorrect number of arguments")
+
+ if options.auth:
+ if options.auth == 'yes': options.auth = True
+ elif options.auth == 'try': options.auth = None
+ elif options.auth == 'no': options.auth = False
+ else:
+ parser.error("--auth takes yes, no, and try (default; auth if possible)")
+
+ return options, args
+
if __name__ == '__main__':
+ options, args = parse_args()
moira.connect()
- rblanche(sys.argv[1])
+ if options.auth:
+ moira.auth('rblnchpy')
+ elif options.auth is None:
+ try:
+ moira.auth('rblnchpy')
+ except moira.MoiraException:
+ print >>sys.stderr, "Warning: Failed to authenticate to moira"
+ rblanche(args[0])