direct-io.hg

changeset 11641:0de76117acb6

[XM] Fix error reporting for resources.py, remove duplicate try block.

Also fixed usage message to not include misspelling of the command.

Signed-off-by: Alastair Tse <atse@xensource.com>
author atse@norwich.uk.xensource.com
date Thu Sep 28 12:16:11 2006 +0100 (2006-09-28)
parents 911b7c6d03ea
children 98ba161961b5
files tools/python/xen/xm/resources.py
line diff
     1.1 --- a/tools/python/xen/xm/resources.py	Thu Sep 28 11:50:51 2006 +0100
     1.2 +++ b/tools/python/xen/xm/resources.py	Thu Sep 28 12:16:11 2006 +0100
     1.3 @@ -24,7 +24,7 @@ from xen.util import security
     1.4  from xen.xm.opts import OptionError
     1.5  
     1.6  def help():
     1.7 -    return """Usage: xm resource
     1.8 +    return """
     1.9      This program lists information for each resource in the
    1.10      global resource label file."""
    1.11  
    1.12 @@ -45,18 +45,13 @@ def main (argv):
    1.13          filename = security.res_label_filename
    1.14          access_control = dictio.dict_read("resources", filename)
    1.15      except:
    1.16 -        print "Resource file not found."
    1.17 -        return
    1.18 +        raise OptionError("Resource file not found")
    1.19  
    1.20 -        try:
    1.21 -            file = security.res_label_filename
    1.22 -            access_control = dictio.dict_read("resources", file)
    1.23 -        except:
    1.24 -            security.err("Error reading resource file.")
    1.25 -
    1.26 -        print_resource_data(access_control)
    1.27 +    print_resource_data(access_control)
    1.28  
    1.29  if __name__ == '__main__':
    1.30 -    main(sys.argv)
    1.31 -
    1.32 -
    1.33 +    try:
    1.34 +        main(sys.argv)
    1.35 +    except Exception, e:
    1.36 +        sys.stderr.write('Error: %s\n' % str(e))
    1.37 +        sys.exit(-1)