From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 86F7F138A1F for ; Tue, 22 Apr 2014 02:36:18 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 38FC0E0929; Tue, 22 Apr 2014 02:36:17 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 8569EE08DC for ; Tue, 22 Apr 2014 02:36:16 +0000 (UTC) Received: from spoonbill.gentoo.org (spoonbill.gentoo.org [81.93.255.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 82BC633FF49 for ; Tue, 22 Apr 2014 02:36:15 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id 4352E18746 for ; Tue, 22 Apr 2014 02:36:14 +0000 (UTC) From: "Brian Dolbec" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Brian Dolbec" Message-ID: <1396133180.91582e361306971cd1a2f96036350ebd9df67460.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/, pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/actions.py pym/portage/sync/__init__.py pym/portage/sync/controller.py X-VCS-Directories: pym/portage/sync/ pym/_emerge/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: 91582e361306971cd1a2f96036350ebd9df67460 X-VCS-Branch: plugin-sync Date: Tue, 22 Apr 2014 02:36:14 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: 5567ec32-f537-40ba-8c13-06da19a7aada X-Archives-Hash: 8b2a5171a6d42204709ddf13a6f87448 commit: 91582e361306971cd1a2f96036350ebd9df67460 Author: Brian Dolbec gentoo org> AuthorDate: Sat Mar 15 07:55:30 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Sat Mar 29 22:46:20 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=91582e36 portage/sync: Move the Modules and SyncManager initialization code to sync/__init__.py This creates a central place to store a single instance of the SyncManager. It also makes the module names available for use in repository/config.py for repos.conf checks. --- pym/_emerge/actions.py | 8 ++++---- pym/portage/sync/__init__.py | 34 ++++++++++++++++++++++++++++++++++ pym/portage/sync/controller.py | 8 +------- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index 18cc0cc..ccfe2e7 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -62,7 +62,9 @@ from portage.util._async.run_main_scheduler import run_main_scheduler from portage.util._async.SchedulerInterface import SchedulerInterface from portage.util._eventloop.global_event_loop import global_event_loop from portage._global_updates import _global_updates -from portage.sync.controller import SyncManager +from portage.sync import get_syncer +from portage.sync.getaddrinfo_validate import getaddrinfo_validate +from portage.sync.old_tree_timestamp import old_tree_timestamp_warn from portage.metadata import action_metadata from _emerge.clear_caches import clear_caches @@ -81,8 +83,6 @@ from _emerge.Scheduler import Scheduler from _emerge.search import search from _emerge.SetArg import SetArg from _emerge.show_invalid_depstring_notice import show_invalid_depstring_notice -from portage.sync.getaddrinfo_validate import getaddrinfo_validate -from portage.sync.old_tree_timestamp import old_tree_timestamp_warn from _emerge.unmerge import unmerge from _emerge.UnmergeDepPriority import UnmergeDepPriority from _emerge.UseFlagDisplay import pkg_use_display @@ -1874,7 +1874,7 @@ def action_sync(emerge_config, trees=DeprecationWarning, else: selected_repos.extend(emerge_config.target_config.settings.repositories) - sync_manager = SyncManager(emerge_config.target_config.settings, emergelog) + sync_manager = get_syncer(emerge_config.target_config.settings, emergelog) retvals = [] for repo in selected_repos: if repo.sync_type is not None: diff --git a/pym/portage/sync/__init__.py b/pym/portage/sync/__init__.py index 21a391a..65498ec 100644 --- a/pym/portage/sync/__init__.py +++ b/pym/portage/sync/__init__.py @@ -1,2 +1,36 @@ # Copyright 2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 + +import os + +from portage.emaint.module import Modules +from portage.sync.controller import SyncManager + +sync_manager = None + +path = os.path.join(os.path.dirname(__file__), "modules") +# initial development debug info +print("module path:", path) + +module_controller = Modules(path=path, namepath="portage.sync.modules") + +# initial development debug info +print(module_controller.module_names) +module_names = module_controller.module_names[:] + + +def get_syncer(settings=None, logger=None): + global sync_manager + if sync_manager and not settings and not logger: + return sync_manager + if settings is None: + from _emerge.actions import load_emerge_config + emerge_config = load_emerge_config() + settings = emerge_config.target_config.settings + if logger is None: + from _emerge.emergelog import emergelog as logger + sync_manager = SyncManager(settings, logger) + return sync_manager + + + diff --git a/pym/portage/sync/controller.py b/pym/portage/sync/controller.py index a4b2ab8..e53d173 100644 --- a/pym/portage/sync/controller.py +++ b/pym/portage/sync/controller.py @@ -10,7 +10,6 @@ import pwd import portage from portage import os -from portage.emaint.module import Modules from portage.emaint.progress import ProgressBar #from portage.emaint.defaults import DEFAULT_OPTIONS #from portage.util._argparse import ArgumentParser @@ -85,13 +84,8 @@ class SyncManager(object): # files have sane permissions. os.umask(0o22) - path = os.path.join(os.path.dirname(__file__), "modules") - print("module path:", path) - self.module_controller = Modules(path=path, - namepath="portage.sync.modules") - print(self.module_controller.module_names) + self.module_controller = portage.sync.module_controller self.module_names = self.module_controller.module_names[:] - #self.module_names.insert(0, "all") def get_modules(self, mod):