mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
This reverts commit a7be68a4d77791bbe02c37f7ad8ae60b02e5679e
and a subsequent commit 4617d1f6bd24c543f533f6485b42ebca6b0a8371.
There are too many issues with these patches. It's better to revert
them for now and make a separate fixed versions later if needed.
List of issues (maybe not full):
1. 'make clean' removes entire 'python' directory.
2. Fully broken Travis-CI testsuite build:
building 'ovs._json' extension
creating build/temp.linux-x86_64-2.7
error: could not create 'build/temp.linux-x86_64-2.7': \
Permission denied
https://travis-ci.org/openvswitch/ovs/jobs/440693765
3. Broken local testsuite build on Ubuntu 18.04:
running build_ext
building 'ovs._json' extension
creating build/temp.linux-x86_64-3.6
creating build/temp.linux-x86_64-3.6/ovs
<...>
/usr/bin/ld: .libs/libopenvswitch.a(util.o): \
relocation R_X86_64_TPOFF32 against `var.7749' can not be \
used when making a shared object; recompile with -fPIC
<...>
collect2: error: ld returned 1 exit status
4. Fedora build failure because of 'setuptools' ('distutils')
hard dependency on 'redhat-rpm-config' package:
building 'ovs._json' extension
<...>
gcc: error: <...>/redhat-hardened-cc1: No such file or directory
5. Looks like 'setuptools' also could download and install
unwanted python modules during package build.
Signed-off-by: Ilya Maximets <i.maximets@samsung.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
103 lines
2.7 KiB
Python
103 lines
2.7 KiB
Python
# Copyright (c) 2009, 2010 Nicira, Inc.
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
# you may not use this file except in compliance with the License.
|
|
# You may obtain a copy of the License at:
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
# See the License for the specific language governing permissions and
|
|
# limitations under the License.
|
|
|
|
from __future__ import print_function
|
|
|
|
import codecs
|
|
import getopt
|
|
import sys
|
|
|
|
import ovs.json
|
|
|
|
import six
|
|
|
|
|
|
def print_json(json):
|
|
if isinstance(json, six.string_types):
|
|
print("error: %s" % json)
|
|
return False
|
|
else:
|
|
ovs.json.to_stream(json, sys.stdout)
|
|
sys.stdout.write("\n")
|
|
return True
|
|
|
|
|
|
def parse_multiple(stream):
|
|
buf = stream.read(4096)
|
|
ok = True
|
|
parser = None
|
|
while len(buf):
|
|
if parser is None and buf[0] in " \t\r\n":
|
|
buf = buf[1:]
|
|
else:
|
|
if parser is None:
|
|
parser = ovs.json.Parser()
|
|
n = parser.feed(buf)
|
|
buf = buf[n:]
|
|
if len(buf):
|
|
if not print_json(parser.finish()):
|
|
ok = False
|
|
parser = None
|
|
if len(buf) == 0:
|
|
buf = stream.read(4096)
|
|
if parser and not print_json(parser.finish()):
|
|
ok = False
|
|
return ok
|
|
|
|
|
|
def main(argv):
|
|
argv0 = argv[0]
|
|
|
|
# When this is used with Python 3, the program produces no output.
|
|
if six.PY2:
|
|
# Make stdout and stderr UTF-8, even if they are redirected to a file.
|
|
sys.stdout = codecs.getwriter("utf-8")(sys.stdout)
|
|
sys.stderr = codecs.getwriter("utf-8")(sys.stderr)
|
|
|
|
try:
|
|
options, args = getopt.gnu_getopt(argv[1:], '', ['multiple'])
|
|
except getopt.GetoptError as geo:
|
|
sys.stderr.write("%s: %s\n" % (argv0, geo.msg))
|
|
sys.exit(1)
|
|
|
|
multiple = False
|
|
for key, value in options:
|
|
if key == '--multiple':
|
|
multiple = True
|
|
else:
|
|
sys.stderr.write("%s: unhandled option %s\n" % (argv0, key))
|
|
sys.exit(1)
|
|
|
|
if len(args) != 1:
|
|
sys.stderr.write("usage: %s [--multiple] INPUT.json\n" % argv0)
|
|
sys.exit(1)
|
|
|
|
input_file = args[0]
|
|
if input_file == "-":
|
|
stream = sys.stdin
|
|
else:
|
|
stream = open(input_file, "r")
|
|
|
|
if multiple:
|
|
ok = parse_multiple(stream)
|
|
else:
|
|
ok = print_json(ovs.json.from_stream(stream))
|
|
|
|
if not ok:
|
|
sys.exit(1)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main(sys.argv)
|