EVOLUTION-MANAGER
Edit File: __init__.py
#-*- coding: utf-8 -*- # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program; if not, write to the Free Software Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. # # (C) 2011 - Pierre-Yves Chibon <pingou@pingoured.fr> """ Miscellaneous functions used in R2spec. """ import logging import shutil from subprocess import Popen, PIPE logging.basicConfig() LOG = logging.getLogger('R2spec') VERSION = '4.2.1' def get_logger(): """ Return the logger. """ return LOG def get_rpm_tag(tag): """" Reads the .rpmmacros and set the values accordingly Code from José Matos. :arg tag, the rpm tag to find the value of """ dirname = Popen(["rpm", "-E", '%' + tag], stdout=PIPE).stdout.read()[:-1] return dirname def get_mock_root(): """" Calls mock to retrieve the root path and return it minus the last two levels. """ dirname = Popen(["mock", "--print-root-path"], stdout=PIPE).stdout.read()[:-1] return dirname.rsplit('/', 3)[0] + '/' def move_sources(fullpath, sources): """ Copy the tarball from its current location to the sourcedir as defined by rpm. :arg fullpath, the fullpath to the sources in their current location. :arg sources, the name of the file in which the origin will be copied. """ sourcedir = get_rpm_tag('_sourcedir') dest = '%s/%s' % (sourcedir, sources) shutil.copyfile(fullpath, dest) class R2specError: """ R2specError class Template for all the error of the project """ def __init__(self, value): """ Constructor. """ self.value = value def __str__(self): """ Represent the error. """ return str(self.value) class BuildError (R2specError): """ Class used when something goes wrong during the build. """ pass class BuildDepencenciesError (R2specError): """ Class used when the build could not be completed because of dependencies. """ pass