From ca48ac89ceafcbd2a1639ebc2b6a8caecac50bd6 Mon Sep 17 00:00:00 2001 From: apisu Date: Thu, 23 Nov 2017 17:38:32 +0100 Subject: [PATCH 1/4] #47 pass the parameter --looper to the isolate processus --- .../cohorte/forker/starters/cohorte_boot.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/python/cohorte/forker/starters/cohorte_boot.py b/python/cohorte/forker/starters/cohorte_boot.py index 2a70e48a..90887550 100644 --- a/python/cohorte/forker/starters/cohorte_boot.py +++ b/python/cohorte/forker/starters/cohorte_boot.py @@ -26,32 +26,31 @@ # Standard library -import cohorte -import cohorte.forker -import cohorte.monitor -import cohorte.utils import logging import os -from pelix.ipopo.decorators import ComponentFactory, Requires, Provides, \ - Property, Instantiate import subprocess import sys +import cohorte +import cohorte.forker import cohorte.forker.starters.common as common +import cohorte.monitor +import cohorte.utils +import cohorte.version from herald import beans import herald from herald.exceptions import HeraldException import pelix.http as http +from pelix.ipopo.decorators import ComponentFactory, Requires, Provides, \ + Property, Instantiate # Pelix framework # COHORTE modules # Herald # ------------------------------------------------------------------------------ - # Bundle version -import cohorte.version -__version__=cohorte.version.__version__ +__version__ = cohorte.version.__version__ # ------------------------------------------------------------------------------ @@ -182,6 +181,8 @@ def start(self, configuration, state_updater_url): if sys.platform == "darwin"\ and configuration['kind'] in ('java', 'osgi'): looper = 'cocoa' + elif "looper" in configuration.keys() : + looper = configuration["looper"] else: looper = None From c2ec3b87061632e7fb0b01f51cbe22648c296bc7 Mon Sep 17 00:00:00 2001 From: apisu Date: Wed, 6 Dec 2017 15:04:30 +0100 Subject: [PATCH 2/4] #48 open file with utf-8 as encoding --- python/cohorte/repositories/python/ipopo.py | 17 +++++++------- python/cohorte/repositories/python/modules.py | 22 +++++++++---------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/python/cohorte/repositories/python/ipopo.py b/python/cohorte/repositories/python/ipopo.py index fc43823a..04dad3ff 100755 --- a/python/cohorte/repositories/python/ipopo.py +++ b/python/cohorte/repositories/python/ipopo.py @@ -28,20 +28,19 @@ import logging import threading -# Pelix -from pelix.utilities import is_string +import cohorte.repositories +from cohorte.repositories.beans import Factory +import cohorte.version from pelix.ipopo.decorators import ComponentFactory, Provides, Invalidate, \ Property, Requires, Validate +from pelix.utilities import is_string -# Repository beans -import cohorte.repositories -from cohorte.repositories.beans import Factory +# Pelix +# Repository beans # ------------------------------------------------------------------------------ - # Bundle version -import cohorte.version -__version__=cohorte.version.__version__ +__version__ = cohorte.version.__version__ # ------------------------------------------------------------------------------ @@ -151,7 +150,7 @@ def _extract_module_factories(filename): """ visitor = ComponentFactoryVisitor() try: - with open(filename) as filep: + with open(filename, encoding="utf-8") as filep: source = filep.read() except (OSError, IOError) as ex: raise ValueError("Error reading {0}: {1}".format(filename, ex)) diff --git a/python/cohorte/repositories/python/modules.py b/python/cohorte/repositories/python/modules.py index 0fb6e048..0df09a8f 100755 --- a/python/cohorte/repositories/python/modules.py +++ b/python/cohorte/repositories/python/modules.py @@ -26,27 +26,25 @@ # Standard library import ast import imp +import json import logging import os -# ######### added by: Bassem D. -import json -# ######### - -# Pelix +import cohorte +import cohorte.repositories +from cohorte.repositories.beans import Artifact, Version +import cohorte.version from pelix.ipopo.decorators import ComponentFactory, Provides, Property, \ Invalidate, Validate from pelix.utilities import is_string -# Repository beans -import cohorte -import cohorte.repositories -from cohorte.repositories.beans import Artifact, Version +# ######### added by: Bassem D. +# ######### +# Pelix +# Repository beans # ------------------------------------------------------------------------------ - # Bundle version -import cohorte.version __version__=cohorte.version.__version__ # ------------------------------------------------------------------------------ @@ -187,7 +185,7 @@ def _extract_module_info(filename, module_name, is_package): :raise ValueError: Unreadable file """ try: - with open(filename) as filep: + with open(filename,="utf-8") as filep: source = filep.read() except (OSError, IOError) as ex: raise ValueError("Error reading {0}: {1}".format(filename, ex)) From f7abd88e071c385949f4530c12f4d373cec06013 Mon Sep 17 00:00:00 2001 From: apisu Date: Thu, 7 Dec 2017 13:46:51 +0100 Subject: [PATCH 3/4] fix bad remove of encoding --- python/cohorte/repositories/python/modules.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/python/cohorte/repositories/python/modules.py b/python/cohorte/repositories/python/modules.py index 0df09a8f..e1125de6 100755 --- a/python/cohorte/repositories/python/modules.py +++ b/python/cohorte/repositories/python/modules.py @@ -45,7 +45,7 @@ # Repository beans # ------------------------------------------------------------------------------ # Bundle version -__version__=cohorte.version.__version__ +__version__ = cohorte.version.__version__ # ------------------------------------------------------------------------------ @@ -185,7 +185,7 @@ def _extract_module_info(filename, module_name, is_package): :raise ValueError: Unreadable file """ try: - with open(filename,="utf-8") as filep: + with open(filename, encoding="utf-8") as filep: source = filep.read() except (OSError, IOError) as ex: raise ValueError("Error reading {0}: {1}".format(filename, ex)) @@ -293,7 +293,7 @@ def __compute_name(root, filename): # Drop extension filename = os.path.splitext(filename)[0] name_parts = filename.split(os.path.sep) - is_package = name_parts[len(name_parts)-1] == "__init__" + is_package = name_parts[len(name_parts) - 1] == "__init__" if is_package: name_parts = name_parts[:-1] return ".".join(name_parts), is_package @@ -562,7 +562,7 @@ def load_cache(self): for directory in cache["directories"]: self._directory_package[directory["dir_name"]] \ - = directory["pkg_name"] + = directory["pkg_name"] return True except (IOError, ValueError): From 74ff15b0d6bca857fb51706f02a148cad6506e83 Mon Sep 17 00:00:00 2001 From: apisu Date: Wed, 20 Dec 2017 15:39:08 +0100 Subject: [PATCH 4/4] #49 fix utf8 issue while read module in python3 and python2.7 --- python/cohorte/repositories/python/ipopo.py | 12 +++++++++--- python/cohorte/repositories/python/modules.py | 13 ++++++++++--- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/python/cohorte/repositories/python/ipopo.py b/python/cohorte/repositories/python/ipopo.py index 04dad3ff..3474072b 100755 --- a/python/cohorte/repositories/python/ipopo.py +++ b/python/cohorte/repositories/python/ipopo.py @@ -150,10 +150,16 @@ def _extract_module_factories(filename): """ visitor = ComponentFactoryVisitor() try: - with open(filename, encoding="utf-8") as filep: + with open(filename,encoding="utf8") as filep: source = filep.read() - except (OSError, IOError) as ex: - raise ValueError("Error reading {0}: {1}".format(filename, ex)) + except (OSError, IOError,TypeError) as ex: + try: + import io + with io.open(filename,encoding="utf8") as filep: + source = filep.read() + except (OSError, IOError) as ex2: + _logger.exception(ex2) + raise ValueError("Error reading {0}: {1}".format(filename, ex2)) try: module = ast.parse(source, filename, 'exec') diff --git a/python/cohorte/repositories/python/modules.py b/python/cohorte/repositories/python/modules.py index e1125de6..8820d1c9 100755 --- a/python/cohorte/repositories/python/modules.py +++ b/python/cohorte/repositories/python/modules.py @@ -185,10 +185,17 @@ def _extract_module_info(filename, module_name, is_package): :raise ValueError: Unreadable file """ try: - with open(filename, encoding="utf-8") as filep: + with open(filename,encoding="utf8") as filep: source = filep.read() - except (OSError, IOError) as ex: - raise ValueError("Error reading {0}: {1}".format(filename, ex)) + except (OSError, IOError,TypeError) as ex: + try: + import io + with io.open(filename,encoding="utf8") as filep: + source = filep.read() + except (OSError, IOError) as ex2: + _logger.exception(ex2) + raise ValueError("Error reading {0}: {1}".format(filename, ex)) + visitor = AstVisitor(module_name, is_package) try: