source: trunk/packages/xen-common/xen-common/tools/misc/sxp-pretty @ 34

Last change on this file since 34 was 34, checked in by hartmans, 17 years ago

Add xen and xen-common

  • Property svn:mime-type set to text/script
File size: 1.5 KB
Line 
1#!/usr/bin/env python
2#  -*- mode: python; -*-
3#============================================================================
4# This library is free software; you can redistribute it and/or
5# modify it under the terms of version 2.1 of the GNU Lesser General Public
6# License as published by the Free Software Foundation.
7#
8# This library is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11# Lesser General Public License for more details.
12#
13# You should have received a copy of the GNU Lesser General Public
14# License along with this library; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16#============================================================================
17# Copyright (c) 2007 XenSource Inc.
18#============================================================================
19
20
21import commands
22import os.path
23import pprint
24import sys
25
26result = commands.getstatusoutput(os.path.join(os.path.dirname(sys.argv[0]),
27                                               'xen-python-path'))
28if result[0] != 0:
29    print >>sys.stderr, result[1]
30    sys.exit(1)
31
32sys.path.append(result[1])
33
34import xen.xend.sxp as sxp
35
36def main():
37    if len(sys.argv) == 1 or sys.argv[1] in ['', '-']:
38        s = sxp.parse(sys.stdin)
39    else:
40        s = sxp.parse(open(sys.argv[1]))
41
42    pprint.pprint(s)
43
44if __name__ == '__main__':
45    sys.exit(main())
Note: See TracBrowser for help on using the repository browser.