From e469a0c741832f6584513f4a382d6b93f417b8d2 Mon Sep 17 00:00:00 2001 From: Dylan Deng Date: Sat, 23 Jun 2018 15:02:26 +0800 Subject: [PATCH] fix some sync error while using python3 Change-Id: I70925e48756c356d48359679d8ad1b9e33a68595 --- event_log.py | 4 +++- git_config.py | 4 +++- platform_utils.py | 7 ++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/event_log.py b/event_log.py index 45a2c268..2f1b180b 100644 --- a/event_log.py +++ b/event_log.py @@ -18,6 +18,8 @@ from __future__ import print_function import json import multiprocessing +from pyversion import is_python3 + TASK_COMMAND = 'command' TASK_SYNC_NETWORK = 'sync-network' TASK_SYNC_LOCAL = 'sync-local' @@ -71,7 +73,7 @@ class EventLog(object): A dictionary of the event added to the log. """ event = { - 'id': (kind, self._next_id.next()), + 'id': (kind, self._next_id.__next__() if is_python3() else self._next_id.next()), 'name': name, 'task_name': task_name, 'start_time': start, diff --git a/git_config.py b/git_config.py index 7bc6f77d..70b22ce1 100644 --- a/git_config.py +++ b/git_config.py @@ -306,7 +306,9 @@ class GitConfig(object): d = self._do('--null', '--list') if d is None: return c - for line in d.decode('utf-8').rstrip('\0').split('\0'): + if not is_python3(): + d = d.decode('utf-8') + for line in d.rstrip('\0').split('\0'): if '\n' in line: key, val = line.split('\n', 1) else: diff --git a/platform_utils.py b/platform_utils.py index 33cb2ec3..a3e96531 100644 --- a/platform_utils.py +++ b/platform_utils.py @@ -20,7 +20,12 @@ import select import shutil import stat -from Queue import Queue +from pyversion import is_python3 +if is_python3(): + from queue import Queue +else: + from Queue import Queue + from threading import Thread