From: John Admanski Subject: Re: [PATCH] Refactor of setup_modules.py Date: Mon, 5 Oct 2009 11:25:01 -0700 Message-ID: <394b34480910051125k58baba92k5ceb63e39ab62565@mail.gmail.com> References: <1254764431-11210-1-git-send-email-lmr@redhat.com> <394b34480910051120u5aa76901l58f0d7ea3928065d@mail.gmail.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary=0016e6480e088860fd0475343c4d Cc: autotest@test.kernel.org, kvm@vger.kernel.org, "Gregory P. Smith" , Martin Bligh To: Lucas Meneghel Rodrigues Return-path: Received: from smtp-out.google.com ([216.239.45.13]:9187 "EHLO smtp-out.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754273AbZJES0c (ORCPT ); Mon, 5 Oct 2009 14:26:32 -0400 Received: from zps76.corp.google.com (zps76.corp.google.com [172.25.146.76]) by smtp-out.google.com with ESMTP id n95IPO6t028489 for ; Mon, 5 Oct 2009 11:25:24 -0700 Received: from iwn42 (iwn42.prod.google.com [10.241.68.106]) by zps76.corp.google.com with ESMTP id n95IPLT0005635 for ; Mon, 5 Oct 2009 11:25:21 -0700 Received: by iwn42 with SMTP id 42so1800863iwn.28 for ; Mon, 05 Oct 2009 11:25:21 -0700 (PDT) In-Reply-To: <394b34480910051120u5aa76901l58f0d7ea3928065d@mail.gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: --0016e6480e088860fd0475343c4d Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Here's what I had in mind. -- John On Mon, Oct 5, 2009 at 11:20 AM, John Admanski wrote= : > > After some investigation and irc chat, it has become clear that this misb= ehaving chunk of code in=A0_autotest_logging_handle_error is in fact an err= or; the patch that was applied in rev=A03649 in subversion added a chunk of= the code from setup to the end of=A0_autotest_logging_handle_error, which = doesn't work very well since it references a variable local to setup. > The simpler solution would be to just delete that chunk of code. > > -- John > > On Mon, Oct 5, 2009 at 10:40 AM, Lucas Meneghel Rodrigues wrote: >> >> Currently client/setup_modules.py has an undefined variable error >> that was spot by Amos Kong , and a simple fix >> was proposed. (see http://patchwork.test.kernel.org/patch/1315/) >> >> It seems to me that in a previous refactor of setup_modules, some >> code was moved but not all references were properly fixed. >> >> Amos's fix, while fine, introduces global variables to accomplish >> the goal and didn't fix another undefined reference that was lying >> around. As in general it's advisable to avoid resorting to global >> namespacing, I propose another fix: Encapsulate the library >> namespace setup into a class, and make setup() just a delegate >> of the setup() method inside that class. This way it's possible >> to encapsulate code and use class attributes to avoid using >> global variables. >> >> Since I was there I modified the docstrings of that file to comply >> with the docstring guideline. >> >> John, please let me know what you think about this. >> >> Complexity: Medium (Code refactor, all public API preserved) >> Risk: High (Core code executed by the client). Change was tested though = :) >> >> Signed-off-by: Lucas Meneghel Rodrigues >> --- >> =A0client/setup_modules.py | =A0306 ++++++++++++++++++++++++++++--------= ---------- >> =A01 files changed, 186 insertions(+), 120 deletions(-) >> >> diff --git a/client/setup_modules.py b/client/setup_modules.py >> index dc255c4..188114c 100644 >> --- a/client/setup_modules.py >> +++ b/client/setup_modules.py >> @@ -1,4 +1,9 @@ >> -__author__ =3D "jadmanski@google.com (John Admanski)" >> +""" >> +Utility library used for autotest library namespace configuration. >> + >> +@copyright Google 2007-2009 >> +@author John Admanski >> +""" >> >> =A0import os, sys >> >> @@ -12,134 +17,195 @@ check_version.check_python_version() >> >> =A0import new, glob, traceback >> >> +class namespace_config(object): >> + =A0 =A0""" >> + =A0 =A0Class to perform namespace configuration for autotest. >> >> -def _create_module(name): >> - =A0 =A0"""Create a single top-level module""" >> - =A0 =A0module =3D new.module(name) >> - =A0 =A0sys.modules[name] =3D module >> - =A0 =A0return module >> - >> - >> -def _create_module_and_parents(name): >> - =A0 =A0"""Create a module, and all the necessary parents""" >> - =A0 =A0parts =3D name.split(".") >> - =A0 =A0# first create the top-level module >> - =A0 =A0parent =3D _create_module(parts[0]) >> - =A0 =A0created_parts =3D [parts[0]] >> - =A0 =A0parts.pop(0) >> - =A0 =A0# now, create any remaining child modules >> - =A0 =A0while parts: >> - =A0 =A0 =A0 =A0child_name =3D parts.pop(0) >> - =A0 =A0 =A0 =A0module =3D new.module(child_name) >> - =A0 =A0 =A0 =A0setattr(parent, child_name, module) >> - =A0 =A0 =A0 =A0created_parts.append(child_name) >> - =A0 =A0 =A0 =A0sys.modules[".".join(created_parts)] =3D module >> - =A0 =A0 =A0 =A0parent =3D module >> - >> - >> -def _import_children_into_module(parent_module_name, path): >> - =A0 =A0"""Import all the packages on a path into a parent module""" >> - =A0 =A0# find all the packages at 'path' >> - =A0 =A0names =3D [] >> - =A0 =A0for filename in os.listdir(path): >> - =A0 =A0 =A0 =A0full_name =3D os.path.join(path, filename) >> - =A0 =A0 =A0 =A0if not os.path.isdir(full_name): >> - =A0 =A0 =A0 =A0 =A0 =A0continue =A0 # skip files >> - =A0 =A0 =A0 =A0if "." in filename: >> - =A0 =A0 =A0 =A0 =A0 =A0continue =A0 # if "." is in the name it's not a= valid package name >> - =A0 =A0 =A0 =A0if not os.access(full_name, os.R_OK | os.X_OK): >> - =A0 =A0 =A0 =A0 =A0 =A0continue =A0 # need read + exec access to make = a dir importable >> - =A0 =A0 =A0 =A0if "__init__.py" in os.listdir(full_name): >> - =A0 =A0 =A0 =A0 =A0 =A0names.append(filename) >> - =A0 =A0# import all the packages and insert them into 'parent_module' >> - =A0 =A0sys.path.insert(0, path) >> - =A0 =A0for name in names: >> - =A0 =A0 =A0 =A0module =3D __import__(name) >> - =A0 =A0 =A0 =A0# add the package to the parent >> - =A0 =A0 =A0 =A0parent_module =3D sys.modules[parent_module_name] >> - =A0 =A0 =A0 =A0setattr(parent_module, name, module) >> - =A0 =A0 =A0 =A0full_name =3D parent_module_name + "." + name >> - =A0 =A0 =A0 =A0sys.modules[full_name] =3D module >> - =A0 =A0# restore the system path >> - =A0 =A0sys.path.pop(0) >> + =A0 =A0This is what makes possible to use statements like >> + =A0 =A0from autotest_lib.client.bin import package >> + =A0 =A0""" >> + =A0 =A0def __init__(self, base_path, root_module_name=3D""): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Perform all the necessary setup so that all the package= s at >> + =A0 =A0 =A0 =A0'base_path' can be imported via "import root_module_nam= e.package". >> + =A0 =A0 =A0 =A0If root_module_name is empty, then all the packages at = base_path >> + =A0 =A0 =A0 =A0are inserted as top-level packages. >> + >> + =A0 =A0 =A0 =A0Also, setup all the common.* aliases for modules in the= common >> + =A0 =A0 =A0 =A0library. >> + >> + =A0 =A0 =A0 =A0The setup must be different if you are running on an Au= totest server >> + =A0 =A0 =A0 =A0or on a test machine that just has the client directori= es installed. >> + >> + =A0 =A0 =A0 =A0@param base_path: Path used to compute all relative pat= hs needed for >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0the setup. >> + =A0 =A0 =A0 =A0@param root_module_name: Top level name of the 'virtual= ' library >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0namespace. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0# Hack... Any better ideas? >> + =A0 =A0 =A0 =A0if (root_module_name =3D=3D 'autotest_lib.client' and >> + =A0 =A0 =A0 =A0 =A0 =A0os.path.exists(os.path.join(os.path.dirname(__f= ile__), >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0'..', 'server'))): >> + =A0 =A0 =A0 =A0 =A0 =A0root_module_name =3D 'autotest_lib' >> + =A0 =A0 =A0 =A0 =A0 =A0base_path =3D os.path.abspath(os.path.join(base= _path, '..')) >> + =A0 =A0 =A0 =A0self.root_module_name =3D root_module_name >> + =A0 =A0 =A0 =A0self.base_path =3D base_path >> + >> + >> + =A0 =A0def _create_module(self, name): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Create a single top-level module. >> + >> + =A0 =A0 =A0 =A0@param name: Name of the module you wish to create. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0module =3D new.module(name) >> + =A0 =A0 =A0 =A0sys.modules[name] =3D module >> + =A0 =A0 =A0 =A0return module >> + >> + >> + =A0 =A0def _create_module_and_parents(self, name): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Create a module, and all the necessary parents. >> + >> + =A0 =A0 =A0 =A0@param name: Name of the module you wish to create. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0parts =3D name.split(".") >> + =A0 =A0 =A0 =A0# first create the top-level module >> + =A0 =A0 =A0 =A0parent =3D self._create_module(parts[0]) >> + =A0 =A0 =A0 =A0created_parts =3D [parts[0]] >> + =A0 =A0 =A0 =A0parts.pop(0) >> + =A0 =A0 =A0 =A0# now, create any remaining child modules >> + =A0 =A0 =A0 =A0while parts: >> + =A0 =A0 =A0 =A0 =A0 =A0child_name =3D parts.pop(0) >> + =A0 =A0 =A0 =A0 =A0 =A0module =3D new.module(child_name) >> + =A0 =A0 =A0 =A0 =A0 =A0setattr(parent, child_name, module) >> + =A0 =A0 =A0 =A0 =A0 =A0created_parts.append(child_name) >> + =A0 =A0 =A0 =A0 =A0 =A0sys.modules[".".join(created_parts)] =3D module >> + =A0 =A0 =A0 =A0 =A0 =A0parent =3D module >> + >> + >> + =A0 =A0def _import_children_into_module(self, parent_module_name, path= ): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Import all the packages on a path into a parent module. >> + >> + =A0 =A0 =A0 =A0@param parent_module_name: Name of the parent module yo= u want to use >> + =A0 =A0 =A0 =A0@param path: Path that contains a number of python pack= ages (libs) >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0# find all the packages at 'path' >> + =A0 =A0 =A0 =A0names =3D [] >> + =A0 =A0 =A0 =A0for filename in os.listdir(path): >> + =A0 =A0 =A0 =A0 =A0 =A0full_name =3D os.path.join(path, filename) >> + =A0 =A0 =A0 =A0 =A0 =A0if not os.path.isdir(full_name): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue =A0 # skip files >> + =A0 =A0 =A0 =A0 =A0 =A0if "." in filename: >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue =A0 # if "." is in the name it= 's not a valid package name >> + =A0 =A0 =A0 =A0 =A0 =A0if not os.access(full_name, os.R_OK | os.X_OK): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0continue =A0 # need read + exec access = to make a dir importable >> + =A0 =A0 =A0 =A0 =A0 =A0if "__init__.py" in os.listdir(full_name): >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0names.append(filename) >> + =A0 =A0 =A0 =A0# import all the packages and insert them into 'parent_= module' >> + =A0 =A0 =A0 =A0sys.path.insert(0, path) >> + =A0 =A0 =A0 =A0for name in names: >> + =A0 =A0 =A0 =A0 =A0 =A0module =3D __import__(name) >> + =A0 =A0 =A0 =A0 =A0 =A0# add the package to the parent >> + =A0 =A0 =A0 =A0 =A0 =A0parent_module =3D sys.modules[parent_module_nam= e] >> + =A0 =A0 =A0 =A0 =A0 =A0setattr(parent_module, name, module) >> + =A0 =A0 =A0 =A0 =A0 =A0full_name =3D parent_module_name + "." + name >> + =A0 =A0 =A0 =A0 =A0 =A0sys.modules[full_name] =3D module >> + =A0 =A0 =A0 =A0# restore the system path >> + =A0 =A0 =A0 =A0sys.path.pop(0) >> + >> + >> + =A0 =A0def _autotest_logging_handle_error(self, record): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Method to monkey patch into logging.Handler to replace = handleError. >> + >> + =A0 =A0 =A0 =A0@param record: Logging record that is going to be treat= ed. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0# The same as the default logging.Handler.handleError b= ut also prints >> + =A0 =A0 =A0 =A0# out the original record causing the error so there is= -some- idea >> + =A0 =A0 =A0 =A0# about which call caused the logging error. >> + =A0 =A0 =A0 =A0import logging >> + =A0 =A0 =A0 =A0if logging.raiseExceptions: >> + =A0 =A0 =A0 =A0 =A0 =A0# Avoid recursion as the below output can end u= p back in here when >> + =A0 =A0 =A0 =A0 =A0 =A0# something has *seriously* gone wrong in autot= est. >> + =A0 =A0 =A0 =A0 =A0 =A0logging.raiseExceptions =3D 0 >> + =A0 =A0 =A0 =A0 =A0 =A0sys.stderr.write('Exception occurred formatting= message: ' >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '%r using args= %r\n' % (record.msg, record.args)) >> + =A0 =A0 =A0 =A0 =A0 =A0traceback.print_stack() >> + =A0 =A0 =A0 =A0 =A0 =A0sys.stderr.write('Future logging formatting exc= eptions disabled.\n') >> + >> + =A0 =A0 =A0 =A0if self.root_module_name =3D=3D 'autotest_lib': >> + =A0 =A0 =A0 =A0 =A0 =A0# Allow locally installed third party packages = to be found >> + =A0 =A0 =A0 =A0 =A0 =A0# before any that are installed on the system i= tself when not. >> + =A0 =A0 =A0 =A0 =A0 =A0# running as a client. >> + =A0 =A0 =A0 =A0 =A0 =A0# This is primarily for the benefit of frontend= and tko so that they >> + =A0 =A0 =A0 =A0 =A0 =A0# may use libraries other than those available = as system packages. >> + =A0 =A0 =A0 =A0 =A0 =A0sys.path.insert(0, os.path.join(self.base_path,= "site-packages")) >> + >> + >> + =A0 =A0def _monkeypatch_logging_handle_error(self): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Hack out logging.py to introduce a custom logging error= handling >> + =A0 =A0 =A0 =A0function. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0# Hack out logging.py* >> + =A0 =A0 =A0 =A0logging_py =3D os.path.join(os.path.dirname(__file__), = "common_lib", >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"lo= gging.py*") >> + =A0 =A0 =A0 =A0if glob.glob(logging_py): >> + =A0 =A0 =A0 =A0 =A0 =A0os.system("rm -f %s" % logging_py) >> + >> + =A0 =A0 =A0 =A0# Monkey patch our own handleError into the logging mod= ule's >> + =A0 =A0 =A0 =A0# StreamHandler. A nicer way of doing this -might- be t= o have our own >> + =A0 =A0 =A0 =A0# logging module define an autotest Logger instance tha= t added our own >> + =A0 =A0 =A0 =A0# Handler subclass with this handleError method in it. = =A0But that would >> + =A0 =A0 =A0 =A0# mean modifying tons of code. >> + =A0 =A0 =A0 =A0import logging >> + =A0 =A0 =A0 =A0assert callable(logging.Handler.handleError) >> + =A0 =A0 =A0 =A0logging.Handler.handleError =3D self._autotest_logging_= handle_error >> + >> + >> + =A0 =A0def setup(self): >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0Effectively creates the autotest_lib namespace. >> + =A0 =A0 =A0 =A0""" >> + =A0 =A0 =A0 =A0# Some internal functions might need to reference those= variables. >> + =A0 =A0 =A0 =A0# It doesn't occur to me how to refactor the API in thi= s file in a clean >> + =A0 =A0 =A0 =A0# way to avoid >> + =A0 =A0 =A0 =A0self._create_module_and_parents(self.root_module_name) >> + =A0 =A0 =A0 =A0self._import_children_into_module(self.root_module_name= , self.base_path) >> + >> + =A0 =A0 =A0 =A0if self.root_module_name =3D=3D 'autotest_lib': >> + =A0 =A0 =A0 =A0 =A0 =A0# Allow locally installed third party packages = to be found >> + =A0 =A0 =A0 =A0 =A0 =A0# before any that are installed on the system i= tself when not. >> + =A0 =A0 =A0 =A0 =A0 =A0# running as a client. >> + =A0 =A0 =A0 =A0 =A0 =A0# This is primarily for the benefit of frontend= and tko so that they >> + =A0 =A0 =A0 =A0 =A0 =A0# may use libraries other than those available = as system packages. >> + =A0 =A0 =A0 =A0 =A0 =A0sys.path.insert(0, os.path.join(self.base_path,= "site-packages")) >> + >> + =A0 =A0 =A0 =A0self._monkeypatch_logging_handle_error() >> >> >> =A0def import_module(module, from_where): >> - =A0 =A0"""Equivalent to 'from from_where import module' >> - =A0 =A0Returns the corresponding module""" >> + =A0 =A0""" >> + =A0 =A0Equivalent to 'from from_where import module' >> + >> + =A0 =A0@param module: Module intended to be loaded >> + =A0 =A0@param from_where: Top level module where we want to import the= module >> + =A0 =A0@return: loaded module >> + =A0 =A0""" >> =A0 =A0 from_module =3D __import__(from_where, globals(), locals(), [mod= ule]) >> =A0 =A0 return getattr(from_module, module) >> >> >> -def _autotest_logging_handle_error(self, record): >> - =A0 =A0"""Method to monkey patch into logging.Handler to replace handl= eError.""" >> - =A0 =A0# The same as the default logging.Handler.handleError but also = prints >> - =A0 =A0# out the original record causing the error so there is -some- = idea >> - =A0 =A0# about which call caused the logging error. >> - =A0 =A0import logging >> - =A0 =A0if logging.raiseExceptions: >> - =A0 =A0 =A0 =A0# Avoid recursion as the below output can end up back i= n here when >> - =A0 =A0 =A0 =A0# something has *seriously* gone wrong in autotest. >> - =A0 =A0 =A0 =A0logging.raiseExceptions =3D 0 >> - =A0 =A0 =A0 =A0sys.stderr.write('Exception occurred formatting message= : ' >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 '%r using args %r\n' %= (record.msg, record.args)) >> - =A0 =A0 =A0 =A0traceback.print_stack() >> - =A0 =A0 =A0 =A0sys.stderr.write('Future logging formatting exceptions = disabled.\n') >> - >> - =A0 =A0if root_module_name =3D=3D 'autotest_lib': >> - =A0 =A0 =A0 =A0# Allow locally installed third party packages to be fo= und >> - =A0 =A0 =A0 =A0# before any that are installed on the system itself wh= en not. >> - =A0 =A0 =A0 =A0# running as a client. >> - =A0 =A0 =A0 =A0# This is primarily for the benefit of frontend and tko= so that they >> - =A0 =A0 =A0 =A0# may use libraries other than those available as syste= m packages. >> - =A0 =A0 =A0 =A0sys.path.insert(0, os.path.join(base_path, "site-packag= es")) >> - >> - >> -def _monkeypatch_logging_handle_error(): >> - =A0 =A0# Hack out logging.py* >> - =A0 =A0logging_py =3D os.path.join(os.path.dirname(__file__), "common_= lib", >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0"logging.py= *") >> - =A0 =A0if glob.glob(logging_py): >> - =A0 =A0 =A0 =A0os.system("rm -f %s" % logging_py) >> - >> - =A0 =A0# Monkey patch our own handleError into the logging module's St= reamHandler. >> - =A0 =A0# A nicer way of doing this -might- be to have our own logging = module define >> - =A0 =A0# an autotest Logger instance that added our own Handler subcla= ss with this >> - =A0 =A0# handleError method in it. =A0But that would mean modifying to= ns of code. >> - =A0 =A0import logging >> - =A0 =A0assert callable(logging.Handler.handleError) >> - =A0 =A0logging.Handler.handleError =3D _autotest_logging_handle_error >> - >> - >> =A0def setup(base_path, root_module_name=3D""): >> =A0 =A0 """ >> - =A0 =A0Perform all the necessary setup so that all the packages at >> - =A0 =A0'base_path' can be imported via "import root_module_name.packag= e". >> - =A0 =A0If root_module_name is empty, then all the packages at base_pat= h >> - =A0 =A0are inserted as top-level packages. >> - >> - =A0 =A0Also, setup all the common.* aliases for modules in the common >> - =A0 =A0library. >> + =A0 =A0Configures the autotest_lib namespace for use on a given autote= st >> + =A0 =A0entry point >> >> - =A0 =A0The setup must be different if you are running on an Autotest s= erver >> - =A0 =A0or on a test machine that just has the client directories insta= lled. >> + =A0 =A0@param base_path: Path used to compute all relative paths neede= d for the >> + =A0 =A0 =A0 =A0 =A0 =A0setup. >> + =A0 =A0@param root_module_name: Top level name of the 'virtual' librar= y namespace. >> =A0 =A0 """ >> - =A0 =A0# Hack... Any better ideas? >> - =A0 =A0if (root_module_name =3D=3D 'autotest_lib.client' and >> - =A0 =A0 =A0 =A0os.path.exists(os.path.join(os.path.dirname(__file__), >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0'..', 'server'))): >> - =A0 =A0 =A0 =A0root_module_name =3D 'autotest_lib' >> - =A0 =A0 =A0 =A0base_path =3D os.path.abspath(os.path.join(base_path, '= ..')) >> - >> - =A0 =A0_create_module_and_parents(root_module_name) >> - =A0 =A0_import_children_into_module(root_module_name, base_path) >> - >> - =A0 =A0if root_module_name =3D=3D 'autotest_lib': >> - =A0 =A0 =A0 =A0# Allow locally installed third party packages to be fo= und >> - =A0 =A0 =A0 =A0# before any that are installed on the system itself wh= en not. >> - =A0 =A0 =A0 =A0# running as a client. >> - =A0 =A0 =A0 =A0# This is primarily for the benefit of frontend and tko= so that they >> - =A0 =A0 =A0 =A0# may use libraries other than those available as syste= m packages. >> - =A0 =A0 =A0 =A0sys.path.insert(0, os.path.join(base_path, "site-packag= es")) >> - >> - =A0 =A0_monkeypatch_logging_handle_error() >> + =A0 =A0configurator =3D namespace_config(base_path, root_module_name) >> + =A0 =A0configurator.setup() >> -- >> 1.6.2.5 >> > --0016e6480e088860fd0475343c4d Content-Type: application/octet-stream; name=patch Content-Disposition: attachment; filename=patch Content-Transfer-Encoding: base64 X-Attachment-Id: f_g0fjwoww0 SW5kZXg6IGNsaWVudC9zZXR1cF9tb2R1bGVzLnB5Cj09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGNsaWVudC9zZXR1 cF9tb2R1bGVzLnB5CShyZXZpc2lvbiAzNzg1KQorKysgY2xpZW50L3NldHVwX21vZHVsZXMucHkJ KHdvcmtpbmcgY29weSkKQEAgLTg2LDE1ICs4Niw3IEBACiAgICAgICAgIHRyYWNlYmFjay5wcmlu dF9zdGFjaygpCiAgICAgICAgIHN5cy5zdGRlcnIud3JpdGUoJ0Z1dHVyZSBsb2dnaW5nIGZvcm1h dHRpbmcgZXhjZXB0aW9ucyBkaXNhYmxlZC5cbicpCiAKLSAgICBpZiByb290X21vZHVsZV9uYW1l ID09ICdhdXRvdGVzdF9saWInOgotICAgICAgICAjIEFsbG93IGxvY2FsbHkgaW5zdGFsbGVkIHRo aXJkIHBhcnR5IHBhY2thZ2VzIHRvIGJlIGZvdW5kCi0gICAgICAgICMgYmVmb3JlIGFueSB0aGF0 IGFyZSBpbnN0YWxsZWQgb24gdGhlIHN5c3RlbSBpdHNlbGYgd2hlbiBub3QuCi0gICAgICAgICMg cnVubmluZyBhcyBhIGNsaWVudC4KLSAgICAgICAgIyBUaGlzIGlzIHByaW1hcmlseSBmb3IgdGhl IGJlbmVmaXQgb2YgZnJvbnRlbmQgYW5kIHRrbyBzbyB0aGF0IHRoZXkKLSAgICAgICAgIyBtYXkg dXNlIGxpYnJhcmllcyBvdGhlciB0aGFuIHRob3NlIGF2YWlsYWJsZSBhcyBzeXN0ZW0gcGFja2Fn ZXMuCi0gICAgICAgIHN5cy5wYXRoLmluc2VydCgwLCBvcy5wYXRoLmpvaW4oYmFzZV9wYXRoLCAi c2l0ZS1wYWNrYWdlcyIpKQogCi0KIGRlZiBfbW9ua2V5cGF0Y2hfbG9nZ2luZ19oYW5kbGVfZXJy b3IoKToKICAgICAjIEhhY2sgb3V0IGxvZ2dpbmcucHkqCiAgICAgbG9nZ2luZ19weSA9IG9zLnBh dGguam9pbihvcy5wYXRoLmRpcm5hbWUoX19maWxlX18pLCAiY29tbW9uX2xpYiIsCg== --0016e6480e088860fd0475343c4d--