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 D9DE81391DB for ; Mon, 16 Jun 2014 15:46:31 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DA616E0D98; Mon, 16 Jun 2014 15:46:30 +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 0F9CCE0D99 for ; Mon, 16 Jun 2014 15:46:29 +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 091CC33FFDC for ; Mon, 16 Jun 2014 15:46:29 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by spoonbill.gentoo.org (Postfix) with ESMTP id C4DD1187EB for ; Mon, 16 Jun 2014 15:46:27 +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: <1402933015.dbc25235b203110f0cffe8e94c47e9b3201759e2.dol-sen@gentoo> Subject: [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/sync/ X-VCS-Repository: proj/portage X-VCS-Files: pym/portage/sync/syncbase.py X-VCS-Directories: pym/portage/sync/ X-VCS-Committer: dol-sen X-VCS-Committer-Name: Brian Dolbec X-VCS-Revision: dbc25235b203110f0cffe8e94c47e9b3201759e2 X-VCS-Branch: plugin-sync Date: Mon, 16 Jun 2014 15:46:27 +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: 3b41aafb-928f-455b-b622-786892de43db X-Archives-Hash: 1ecfd43efc64f66025e5b0d757ae55dc commit: dbc25235b203110f0cffe8e94c47e9b3201759e2 Author: Brian Dolbec gentoo org> AuthorDate: Wed Feb 19 08:22:42 2014 +0000 Commit: Brian Dolbec gmail com> CommitDate: Mon Jun 16 15:36:55 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=dbc25235 Initial stubbing out of a common SyncBase class Add copyright Optimize bin_command handling in __init__(). --- pym/portage/sync/syncbase.py | 100 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 100 insertions(+) diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py new file mode 100644 index 0000000..2b6b8c7 --- /dev/null +++ b/pym/portage/sync/syncbase.py @@ -0,0 +1,100 @@ +# Copyright 2014 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +''' +Base class for performing sync operations. +This class contains common initialization code and functions. +''' + + +import os + +import portage +from portage.util import writemsg_level + + +class SyncBase(object): + '''Base Sync class for subclassing''' + + short_desc = "Perform sync operations on repositories" + + @staticmethod + def name(): + return "BlankSync" + + + def can_progressbar(self, func): + return False + + + def __init__(self, bin_command, bin_pkg): + self.options = None + self.settings = None + self.logger = None + self.repo = None + self.xterm_titles = None + self.spawn_kwargs = None + self.bin_command = portage.process.find_binary(bin_command) + + self.has_bin = True + if bin_command and self.bin_command is None: + msg = ["Command not found: %s" % bin_command, + "Type \"emerge %s\" to enable %s support." % (bin_pkg, bin_command)] + for l in msg: + writemsg_level("!!! %s\n" % l, + level=self.logger.ERROR, noiselevel=-1) + self.has_bin = False + + + def _kwargs(self, kwargs): + '''Sets internal variables from kwargs''' + self.options = kwargs.get('options', {}) + self.settings = self.options.get('settings', None) + self.logger = self.options.get('logger', None) + self.repo = self.options.get('repo', None) + self.xterm_titles = self.options.get('xterm_titles', False) + self.spawn_kwargs = self.options.get('spawn_kwargs', None) + + + def exists(self, **kwargs): + '''Tests whether the repo actually exists''' + if kwargs: + self._kwargs(kwargs) + elif not self.repo: + return False + + + if not os.path.exists(self.repo.location): + return False + return True + + + def sync(self, **kwargs): + '''Sync the repository''' + if kwargs: + self._kwargs(kwargs) + + if not self.has_bin: + return (1, False) + + if not self.exists(): + return self.new() + return self._sync() + + + def new(self, **kwargs): + '''Do the initial download and install of the repository''' + pass + + def _sync(self): + '''Update existing repository + ''' + pass + + def post_sync(self, portdb, location, emerge_config): + '''repo.sync_type == "Blank": + # NOTE: Do this after reloading the config, in case + # it did not exist prior to sync, so that the config + # and portdb properly account for its existence. + ''' + pass