Message ID | c54a80d7e9ff91df27aa37ea4fb709961bfcca0d.1584544963.git.tredaelli@redhat.com |
---|---|
State | Superseded |
Delegated to: | Ilya Maximets |
Headers | show |
Series | [ovs-dev] bugtool: Fix for Python3 | expand |
On Wed, Mar 18, 2020 at 8:23 AM Timothy Redaelli <tredaelli@redhat.com> wrote: > > Currently ovs-bugtool tool doesn't start on Python3. > This commit fixes ovs-bugtool to make it works on Python.3 > > Reported-at: https://bugzilla.redhat.com/1809241 > Reported-by: Flavio Leitner <fbl@sysclose.org> > Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> > --- Thanks for the patch. I tried to fix it before but haven't get it done yet. I run your patch and got this error, can you take a look? ovs# ./utilities/bugtool/ovs-bugtool -y -s --output=tar.gz --outfile=/var/log/bugtool-report.tgz Traceback (most recent call last): File "./utilities/bugtool/ovs-bugtool", line 1405, in <module> sys.exit(main()) File "./utilities/bugtool/ovs-bugtool", line 717, in main collect_data() File "./utilities/bugtool/ovs-bugtool", line 366, in collect_data run_procs(process_lists.values()) File "./utilities/bugtool/ovs-bugtool", line 1344, in run_procs p.read_line() File "./utilities/bugtool/ovs-bugtool", line 1313, in read_line self.inst.write(line.decode()) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position 67: invalid continuation byte Thanks William
On Wed, 18 Mar 2020 14:25:43 -0700 William Tu <u9012063@gmail.com> wrote: > On Wed, Mar 18, 2020 at 8:23 AM Timothy Redaelli <tredaelli@redhat.com> wrote: > > > > Currently ovs-bugtool tool doesn't start on Python3. > > This commit fixes ovs-bugtool to make it works on Python.3 > > > > Reported-at: https://bugzilla.redhat.com/1809241 > > Reported-by: Flavio Leitner <fbl@sysclose.org> > > Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> > > --- > > Thanks for the patch. I tried to fix it before but haven't get it done yet. > I run your patch and got this error, can you take a look? > > ovs# ./utilities/bugtool/ovs-bugtool -y -s --output=tar.gz > --outfile=/var/log/bugtool-report.tgz > Traceback (most recent call last): > File "./utilities/bugtool/ovs-bugtool", line 1405, in <module> > sys.exit(main()) > File "./utilities/bugtool/ovs-bugtool", line 717, in main > collect_data() > File "./utilities/bugtool/ovs-bugtool", line 366, in collect_data > run_procs(process_lists.values()) > File "./utilities/bugtool/ovs-bugtool", line 1344, in run_procs > p.read_line() > File "./utilities/bugtool/ovs-bugtool", line 1313, in read_line > self.inst.write(line.decode()) > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position > 67: invalid continuation byte > > Thanks > William > Thank you, I'll send a v2 as soon as possibile
On Thu, Mar 19, 2020 at 4:03 AM Timothy Redaelli <tredaelli@redhat.com> wrote: > > On Wed, 18 Mar 2020 14:25:43 -0700 > William Tu <u9012063@gmail.com> wrote: > > > On Wed, Mar 18, 2020 at 8:23 AM Timothy Redaelli <tredaelli@redhat.com> wrote: > > > > > > Currently ovs-bugtool tool doesn't start on Python3. > > > This commit fixes ovs-bugtool to make it works on Python.3 > > > > > > Reported-at: https://bugzilla.redhat.com/1809241 > > > Reported-by: Flavio Leitner <fbl@sysclose.org> > > > Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> > > > --- > > > > Thanks for the patch. I tried to fix it before but haven't get it done yet. > > I run your patch and got this error, can you take a look? > > > > ovs# ./utilities/bugtool/ovs-bugtool -y -s --output=tar.gz > > --outfile=/var/log/bugtool-report.tgz > > Traceback (most recent call last): > > File "./utilities/bugtool/ovs-bugtool", line 1405, in <module> > > sys.exit(main()) > > File "./utilities/bugtool/ovs-bugtool", line 717, in main > > collect_data() > > File "./utilities/bugtool/ovs-bugtool", line 366, in collect_data > > run_procs(process_lists.values()) > > File "./utilities/bugtool/ovs-bugtool", line 1344, in run_procs > > p.read_line() > > File "./utilities/bugtool/ovs-bugtool", line 1313, in read_line > > self.inst.write(line.decode()) > > UnicodeDecodeError: 'utf-8' codec can't decode byte 0xcb in position > > 67: invalid continuation byte > > > > Thanks > > William > > > > Thank you, > I'll send a v2 as soon as possibile > thanks! my previous patch here FYI, if it helps https://mail.openvswitch.org/pipermail/ovs-dev/2020-February/368111.html
diff --git a/utilities/bugtool/ovs-bugtool.in b/utilities/bugtool/ovs-bugtool.in index e55bfc2ed..7021305c4 100755 --- a/utilities/bugtool/ovs-bugtool.in +++ b/utilities/bugtool/ovs-bugtool.in @@ -33,8 +33,7 @@ # or func_output(). # -import StringIO -import commands +from io import StringIO import fcntl import getopt import hashlib @@ -48,7 +47,7 @@ import warnings import zipfile from select import select from signal import SIGTERM -from subprocess import PIPE, Popen +from subprocess import PIPE, Popen, check_output from xml.dom.minidom import getDOMImplementation, parse @@ -704,7 +703,7 @@ exclude those logs from the archive. # permit the user to filter out data # We cannot use iteritems, since we modify 'data' as we pass through - for (k, v) in sorted(data.items()): + for (k, v) in data.items(): cap = v['cap'] if 'filename' in v: key = k[0] @@ -782,7 +781,7 @@ def dump_scsi_hosts(cap): def module_info(cap): - output = StringIO.StringIO() + output = StringIO() modules = open(PROC_MODULES, 'r') procs = [] @@ -806,7 +805,7 @@ def multipathd_topology(cap): def dp_list(): - output = StringIO.StringIO() + output = StringIO() procs = [ProcOutput([OVS_DPCTL, 'dump-dps'], caps[CAP_NETWORK_STATUS][MAX_TIME], output)] @@ -828,7 +827,7 @@ def collect_ovsdb(): if os.path.isfile(OPENVSWITCH_COMPACT_DB): os.unlink(OPENVSWITCH_COMPACT_DB) - output = StringIO.StringIO() + output = StringIO() max_time = 5 procs = [ProcOutput(['ovsdb-tool', 'compact', OPENVSWITCH_CONF_DB, OPENVSWITCH_COMPACT_DB], @@ -871,7 +870,7 @@ def fd_usage(cap): def dump_rdac_groups(cap): - output = StringIO.StringIO() + output = StringIO() procs = [ProcOutput([MPPUTIL, '-a'], caps[cap][MAX_TIME], output)] run_procs([procs]) @@ -1095,7 +1094,7 @@ def make_inventory(inventory, subdir): s.setAttribute('date', time.strftime('%c')) s.setAttribute('hostname', platform.node()) s.setAttribute('uname', ' '.join(platform.uname())) - s.setAttribute('uptime', commands.getoutput(UPTIME)) + s.setAttribute('uptime', check_output(UPTIME).decode()) document.getElementsByTagName(INVENTORY_XML_ROOT)[0].appendChild(s) map(lambda k_v: inventory_entry(document, subdir, k_v[0], k_v[1]), @@ -1301,7 +1300,7 @@ class ProcOutput(object): line = self.proc.stdout.readline() else: line = self.proc.stdout.read(self.bufsize) - if line == '': + if line == b'': # process exited self.proc.stdout.close() self.status = self.proc.wait() @@ -1311,7 +1310,7 @@ class ProcOutput(object): if self.filter: line = self.filter(line, self.filter_state) if self.inst: - self.inst.write(line) + self.inst.write(line.decode()) def run_procs(procs): @@ -1391,13 +1390,13 @@ def get_free_disk_space(path): return s.f_frsize * s.f_bfree -class StringIOmtime(StringIO.StringIO): +class StringIOmtime(StringIO): def __init__(self, buf=''): - StringIO.StringIO.__init__(self, buf) + StringIO.__init__(self, buf) self.mtime = time.time() def write(self, s): - StringIO.StringIO.write(self, s) + StringIO.write(self, s) self.mtime = time.time()
Currently ovs-bugtool tool doesn't start on Python3. This commit fixes ovs-bugtool to make it works on Python.3 Reported-at: https://bugzilla.redhat.com/1809241 Reported-by: Flavio Leitner <fbl@sysclose.org> Signed-off-by: Timothy Redaelli <tredaelli@redhat.com> --- utilities/bugtool/ovs-bugtool.in | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-)