allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 01/02: py3: encoding fixes in some less common commands
Date Fri, 08 Jan 2021 20:27:04 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/py3_more_fixes
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 0f1793085a7831cbb33cbbf253e53b918b163b73
Author: Dave Brondsema <dbrondsema@slashdotmedia.com>
AuthorDate: Thu Jan 7 16:25:31 2021 -0500

    py3: encoding fixes in some less common commands
---
 Allura/allura/command/taskd_cleanup.py | 5 +++--
 ForgeChat/forgechat/command.py         | 8 +++++---
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/Allura/allura/command/taskd_cleanup.py b/Allura/allura/command/taskd_cleanup.py
index 5523410..43ee799 100644
--- a/Allura/allura/command/taskd_cleanup.py
+++ b/Allura/allura/command/taskd_cleanup.py
@@ -23,6 +23,7 @@ import signal
 import socket
 import subprocess
 from ming.orm.ormsession import ThreadLocalORMSession
+import six
 
 from allura import model as M
 from . import base
@@ -138,7 +139,7 @@ class TaskdCleanupCommand(base.Command):
         stdout, stderr = p.communicate()
         tasks = []
         if p.returncode == 0:
-            tasks = [pid for pid in stdout.split('\n') if pid != '']
+            tasks = [pid for pid in six.ensure_text(stdout).split('\n') if pid != '']
         return tasks
 
     def _taskd_status(self, pid, retry=False):
@@ -152,7 +153,7 @@ class TaskdCleanupCommand(base.Command):
             base.log.error('Can\'t read taskd status log %s' %
                            self.taskd_status_log)
             exit(1)
-        return stdout
+        return six.ensure_text(stdout)
 
     def _check_taskd_status(self, pid):
         for i in range(self.options.num_retry):
diff --git a/ForgeChat/forgechat/command.py b/ForgeChat/forgechat/command.py
index 6c9c0c8..78858b5 100644
--- a/ForgeChat/forgechat/command.py
+++ b/ForgeChat/forgechat/command.py
@@ -17,6 +17,8 @@
 
 from __future__ import unicode_literals
 from __future__ import absolute_import
+
+import six
 import time
 import logging
 import socket
@@ -79,7 +81,7 @@ class IRCBot(asynchat.async_chat):
         sock = socket.socket()
         sock.connect((host, port))
         asynchat.async_chat.__init__(self, sock)
-        self.set_terminator('\r\n')
+        self.set_terminator(b'\r\n')
         self.data = []
         self.channels = {}
         self.set_nick('000')
@@ -95,7 +97,7 @@ class IRCBot(asynchat.async_chat):
         self.say('NICK ' + nick)
 
     def collect_incoming_data(self, data):
-        self.data.append(data)
+        self.data.append(six.ensure_text(data))
 
     def found_terminator(self):
         request = ''.join(self.data)
@@ -129,7 +131,7 @@ class IRCBot(asynchat.async_chat):
     def say(self, s):
         s = s.encode('utf-8')
         self.logger.debug('SAYING %s', s)
-        self.push(s + '\r\n')
+        self.push(s + b'\r\n')
 
     def notice(self, out, message):
         self.say('NOTICE %s :%s' % (out, message))


Mime
View raw message