/usr/share/alljoyn/build_core/tools/scons/javastatus.py is in liballjoyn-common-dev-1604 16.04a-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | #!/usr/bin/python
# Copyright AllSeen Alliance. All rights reserved.
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#
import sys
import os
import getopt
from xml.dom import minidom
from xml.sax.saxutils import escape
if sys.version_info[:3] < (2,4,0):
from sets import Set as set
includeSet = set()
def openFile(name, type):
try:
return open(name, type)
except IOError, e:
errno, errStr = e
print "I/O Operation on %s failed" % name
print "I/O Error(%d): %s" % (errno, errStr)
raise e
def main(argv=None):
"""
make_status --code <code_file> --base <base_dir> [--deps <dep_file>] [--help]
Where:
<code_file> - Output "Java" code
<base_dir> - Root directory for xi:include directives
<dep_file> - Ouput makefile dependency file
"""
global codeOut
global depOut
global isFirst
global fileArgs
global baseDir
codeOut = None
depOut = None
isFirst = True
baseDir = ""
if argv is None:
argv = sys.argv[1:]
try:
opts, fileArgs = getopt.getopt(argv, "h", ["help", "code=", "dep=", "base="])
for o, a in opts:
if o in ("-h", "--help"):
print __doc__
return 0
if o in ("--code"):
codeOut = openFile(a, 'w')
if o in ("--dep"):
depOut = openFile(a, 'w')
if o in ("--base"):
baseDir = a
if None == codeOut:
raise Error("Must specify --code")
writeHeaders()
for arg in fileArgs:
ret = parseDocument(arg)
writeFooters()
if None != codeOut:
codeOut.close()
if None != depOut:
depOut.close()
except getopt.error, msg:
print msg
print "for help use --help"
return 1
except Exception, e:
print "ERROR: %s" % e
if None != codeOut:
os.unlink(codeOut.name)
if None != depOut:
os.unlink(depOut.name)
return 1
return 0
def writeHeaders():
global codeOut
global depOut
global fileArgs
if None != depOut:
depOut.write("%s %s %s:" % (depOut.name, codeOut.name))
for arg in fileArgs:
depOut.write(" \\\n %s" % arg)
if None != codeOut:
codeOut.write("""/* This file is auto-generated. Do not modify. */
/*
* Copyright AllSeen Alliance. All rights reserved.
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
package org.alljoyn.bus;
/**
* Standard function return codes for this package.
*/
public enum Status {
""")
def writeFooters():
global codeOut
global depOut
if None != depOut:
depOut.write("\n")
if None != codeOut:
codeOut.write(""";
/** Error Code */
private int errorCode;
/** Constructor */
private Status(int errorCode) {
this.errorCode = errorCode;
}
/** Static constructor */
private static Status create(int errorCode) {
for (Status s : Status.values()) {
if (s.getErrorCode() == errorCode) {
return s;
}
}
return NONE;
}
/**
* Gets the numeric error code.
*
* @return the numeric error code
*/
public int getErrorCode() { return errorCode; }
}
""")
def parseDocument(fileName):
dom = minidom.parse(fileName)
for child in dom.childNodes:
if child.localName == 'status_block':
parseStatusBlock(child)
elif child.localName == 'include' and child.namespaceURI == 'http://www.w3.org/2001/XInclude':
parseInclude(child)
dom.unlink()
def parseStatusBlock(blockNode):
global codeOut
global isFirst
offset = 0
for node in blockNode.childNodes:
if node.localName == 'offset':
offset = int(node.firstChild.data, 0)
elif node.localName == 'status':
if isFirst:
if None != codeOut:
codeOut.write("\n /** <b><tt>%s</tt></b> %s. */" % (escape(node.getAttribute('value')), escape(node.getAttribute('comment'))))
codeOut.write("\n %s(%s)" % (node.getAttribute('name')[3:], node.getAttribute('value')))
isFirst = False
else:
if None != codeOut:
codeOut.write(",\n /** <b><tt>%s</tt></b> %s. */" % (escape(node.getAttribute('value')), escape(node.getAttribute('comment'))))
codeOut.write("\n %s(%s)" % (node.getAttribute('name')[3:], node.getAttribute('value')))
offset += 1
elif node.localName == 'include' and node.namespaceURI == 'http://www.w3.org/2001/XInclude':
parseInclude(node)
def parseInclude(includeNode):
global baseDir
global includeSet
href = os.path.join(baseDir, includeNode.attributes['href'].nodeValue)
if href not in includeSet:
includeSet.add(href)
if None != depOut:
depOut.write(" \\\n %s" % href)
parseDocument(href)
def JavaStatus(source):
return main(['--base=%s' % os.path.abspath('..'),
'--code=%s.java' % source,
'%s.xml' % source])
if __name__ == "__main__":
sys.exit(main())
|