Permalink
Browse files

Added directory creation for path in dockeroo:docker.save recipe.

  • Loading branch information...
giacomocariello committed Nov 11, 2016
1 parent 9eb2256 commit 8da5798828b2a9ee60d03c5d4a7ec89abd6404a0
Showing with 27 additions and 12 deletions.
  1. +6 −0 CHANGES.rst
  2. +6 −11 dockeroo/__init__.py
  3. +2 −0 dockeroo/docker/__init__.py
  4. +12 −0 dockeroo/utils.py
  5. +1 −1 setup.py
View
@@ -1,6 +1,12 @@
Changelog
=========
0.34 (11-11-2016)
-----------------
- Added directory creation for path in dockeroo:docker.save recipe.
0.33 (11-11-2016)
-----------------
View
@@ -17,7 +17,6 @@
from collections import defaultdict
import errno
from importlib import import_module
from itertools import chain
import logging
@@ -43,6 +42,7 @@
from dockeroo.utils import ExternalProcessError
from dockeroo.utils import OptionRepository, reify
from dockeroo.utils import string_as_bool, uniq
from dockeroo.utils import mkdir
FILTERS = []
@@ -420,17 +420,12 @@ def copy_tree(self, origin, destination, ignore=None):
self.logger.error('Error occurred when cleaning after error: "%s"', strerror)
raise error
def mkdir(self, *paths): # pylint: disable=no-self-use
for path in paths:
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
@staticmethod
def mkdir(*paths):
mkdir(*paths)
def rm(self, *paths): # pylint: disable=no-self-use,invalid-name
@staticmethod
def rm(*paths): # pylint: disable=invalid-name
for path in paths:
if os.path.isdir(path):
shutil.rmtree(path)
@@ -42,6 +42,7 @@
from dockeroo.docker_machine import DockerMachine
from dockeroo.utils import ExternalProcessError
from dockeroo.utils import reify, parse_datetime, random_name, listify
from dockeroo.utils import mkdir
standard_library.install_aliases()
@@ -810,6 +811,7 @@ def run_script(self, container, script, privileged=False, shell=None, user=None)
"Error running script on container \"{}\"".format(container), proc)
def save_image(self, image, path):
mkdir(os.path.dirname(path))
args = ['save', '-o', path, image]
proc = DockerProcess(self, args, stdout=FNULL)
if proc.wait() != 0:
View
@@ -18,7 +18,9 @@
from collections import defaultdict
from datetime import datetime, timedelta, tzinfo
import errno
from functools import wraps
import os
import random
import re
import string
@@ -276,3 +278,13 @@ def string_as_bool(obj):
def uniq(seq):
seen = set()
return [x for x in seq if x not in seen and not seen.add(x)]
def mkdir(*paths):
for path in paths:
try:
os.makedirs(path)
except OSError as exc:
if exc.errno == errno.EEXIST and os.path.isdir(path):
pass
else:
raise
View
@@ -24,7 +24,7 @@
here = os.path.abspath(os.path.dirname(__file__))
README = open(os.path.join(here, 'README.rst')).read()
CHANGES = open(os.path.join(here, 'CHANGES.rst')).read()
VERSION = '0.33'
VERSION = '0.34'
requires = [
'future>=0.15.2',

0 comments on commit 8da5798

Please sign in to comment.