"Fossies" - the Fresh Open Source Software Archive

Member "buildbot-2.3.1/buildbot/test/util/dirs.py" (23 May 2019, 1425 Bytes) of package /linux/misc/buildbot-2.3.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "dirs.py": 2.0.1_vs_2.1.0.

    1 # This file is part of Buildbot.  Buildbot is free software: you can
    2 # redistribute it and/or modify it under the terms of the GNU General Public
    3 # License as published by the Free Software Foundation, version 2.
    4 #
    5 # This program is distributed in the hope that it will be useful, but WITHOUT
    6 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    7 # FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    8 # details.
    9 #
   10 # You should have received a copy of the GNU General Public License along with
   11 # this program; if not, write to the Free Software Foundation, Inc., 51
   12 # Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
   13 #
   14 # Copyright Buildbot Team Members
   15 
   16 
   17 import os
   18 import shutil
   19 
   20 from twisted.internet import defer
   21 
   22 
   23 class DirsMixin:
   24 
   25     _dirs = None
   26 
   27     def setUpDirs(self, *dirs):
   28         """Make sure C{dirs} exist and are empty, and set them up to be deleted
   29         in tearDown."""
   30         self._dirs = map(os.path.abspath, dirs)
   31         for dir in self._dirs:
   32             if os.path.exists(dir):
   33                 shutil.rmtree(dir)
   34             os.makedirs(dir)
   35         # return a deferred to make chaining easier
   36         return defer.succeed(None)
   37 
   38     def tearDownDirs(self):
   39         for dir in self._dirs:
   40             if os.path.exists(dir):
   41                 shutil.rmtree(dir)
   42         # return a deferred to make chaining easier
   43         return defer.succeed(None)