public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Brian Dolbec" <brian.dolbec@gmail.com>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/, pym/_emerge/
Date: Fri,  2 May 2014 23:13:33 +0000 (UTC)	[thread overview]
Message-ID: <1399072156.d08eefa8b3de0a39d801665ac1612a73bbc419f3.dol-sen@gentoo> (raw)

commit:     d08eefa8b3de0a39d801665ac1612a73bbc419f3
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 15 07:55:30 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri May  2 23:09:16 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d08eefa8

portage/sync: Move the Modules, SyncManager initialization code

Move it 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 3edbdbe..e375fc1 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 af85904..a71cb96 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
@@ -84,13 +83,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):


             reply	other threads:[~2014-05-02 23:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-02 23:13 Brian Dolbec [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-09-03 23:36 [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/, pym/_emerge/ Brian Dolbec
2014-06-16 22:45 Brian Dolbec
2014-06-16 15:46 Brian Dolbec
2014-04-22  2:36 Brian Dolbec
2014-03-15  8:01 Brian Dolbec

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399072156.d08eefa8b3de0a39d801665ac1612a73bbc419f3.dol-sen@gentoo \
    --to=brian.dolbec@gmail.com \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox