Skip to content

Commit

Permalink
Merge branch 'feature/pycompat' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
abg committed Jan 19, 2015
2 parents 0596851 + 0391dac commit bc274a0
Show file tree
Hide file tree
Showing 11 changed files with 537 additions and 148 deletions.
4 changes: 2 additions & 2 deletions dbsake/core/mysql/mycnf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import difflib
import os

from dbsake.util import pathutil
from dbsake import pycompat

from . import parser

Expand Down Expand Up @@ -41,7 +41,7 @@ def upgrade(config, target, patch):
for cfg_path, orig, modified in parser.upgrade_config(config, rewriter):
if patch:
# make patch file names pretty
from_file = pathutil.relpath(os.path.abspath(cfg_path), '/')
from_file = pycompat.relpath(os.path.abspath(cfg_path), '/')
to_file = os.path.join('b', from_file)
from_file = os.path.join('a', from_file)
return ''.join(difflib.unified_diff(orig, modified,
Expand Down
3 changes: 2 additions & 1 deletion dbsake/core/mysql/sandbox/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import os
import time

from dbsake import pycompat
from dbsake.util import format_filesize
from dbsake.util import pathutil

Expand All @@ -32,7 +33,7 @@ def create(**options):
sbopts = common.check_options(**options)

# a basic sanity check: make sure there's at least 1GB free (or 5%)
usage = pathutil.disk_usage(sbopts.basedir)
usage = pycompat.disk_usage(pathutil.resolve_mountpoint(sbopts.basedir))

if usage.free < 1024**3:
raise SandboxError(("Only {0} of {1} (<{2:.2%}) available on {3}. "
Expand Down
4 changes: 2 additions & 2 deletions dbsake/core/mysql/sandbox/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import string
import time

from dbsake.util import pathutil
from dbsake import pycompat
from dbsake.util import cmd
from dbsake.util import template

Expand Down Expand Up @@ -164,7 +164,7 @@ def prepare_sandbox_paths(sbopts):
start = time.time()
for path in (sbopts.datadir, os.path.join(sbopts.basedir, 'tmp')):
try:
if pathutil.makedirs(path, exist_ok=True):
if pycompat.makedirs(path, exist_ok=True):
info(" - Created %s", path)
except OSError as exc:
raise SandboxError("%s" % exc)
Expand Down
4 changes: 2 additions & 2 deletions dbsake/core/mysql/sandbox/datasource.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
import tarfile
import time

from dbsake import pycompat
from dbsake.util import cmd
from dbsake.util import compression
from dbsake.util import pathutil

from dbsake.core.mysql.frm import tablename

Expand Down Expand Up @@ -65,7 +65,7 @@ def _is_sqldump(path):


def prepare_datadir(datadir, options):
innobackupex = pathutil.which('innobackupex')
innobackupex = pycompat.which('innobackupex')
if not innobackupex:
raise common.SandboxError("innobackupex not found in path. Aborting.")

Expand Down
20 changes: 10 additions & 10 deletions dbsake/core/mysql/sandbox/distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
import sys
import tempfile

from dbsake import pycompat
from dbsake.util import cmd
from dbsake.util import pathutil

from . import common
from . import util
Expand Down Expand Up @@ -194,9 +194,9 @@ def distribution_from_system(options):
envpath = os.pathsep.join(['/usr/libexec',
'/usr/sbin',
os.environ['PATH']])
mysqld = pathutil.which('mysqld', path=envpath)
mysql = pathutil.which('mysql', path=envpath)
mysqld_safe = pathutil.which('mysqld_safe', path=envpath)
mysqld = pycompat.which('mysqld', path=envpath)
mysql = pycompat.which('mysql', path=envpath)
mysqld_safe = pycompat.which('mysqld_safe', path=envpath)

if None in (mysqld, mysql, mysqld_safe):
raise common.SandboxError("Unable to find MySQL binaries")
Expand Down Expand Up @@ -239,7 +239,7 @@ def distribution_from_system(options):
# now copy mysqld, mysql, mysqld_safe to sandbox_dir/bin
# then return an appropriate MySQLDistribution instance
bindir = os.path.join(options.basedir, 'bin')
pathutil.makedirs(bindir, 0o0770, exist_ok=True)
pycompat.makedirs(bindir, 0o0770, exist_ok=True)
for name in [mysqld]:
shutil.copy2(name, bindir)
debug(" # Copied minimal MySQL commands to %s", bindir)
Expand Down Expand Up @@ -576,7 +576,7 @@ def cache_download(name):
:param name: path to write a cached download ot
"""
pathutil.makedirs(os.path.dirname(name), exist_ok=True)
pycompat.makedirs(os.path.dirname(name), exist_ok=True)
with open(name, 'wb') as fileobj:
yield fileobj

Expand Down Expand Up @@ -622,7 +622,7 @@ def download_tarball_asc(options):
raise common.SandboxError("GPG signature not found for %s" % version)

asc_path = discover_cache_path(cdn.name + '.asc')
pathutil.makedirs(os.path.dirname(asc_path), exist_ok=True)
pycompat.makedirs(os.path.dirname(asc_path), exist_ok=True)
with open(asc_path, 'wb') as fileobj:
fileobj.write(stream.read())
debug(" # Wrote %s", fileobj.name)
Expand All @@ -631,8 +631,8 @@ def download_tarball_asc(options):

def initialize_gpg():
gpghome = os.path.expanduser('~/.dbsake/gpg')
pathutil.makedirs(gpghome, mode=0o0700, exist_ok=True)
gpg = pathutil.which('gpg') or pathutil.which('gpg2')
pycompat.makedirs(gpghome, mode=0o0700, exist_ok=True)
gpg = pycompat.which('gpg') or pycompat.which('gpg2')
if not gpg:
raise common.SandboxError("Failed to find gpg")
gpg_cmd = cmd.shell_format('{0} -k 5072E1F5', gpg)
Expand Down Expand Up @@ -660,7 +660,7 @@ def initialize_gpg():
@contextlib.contextmanager
def gpg_verify_stream(signature):
gpghome = os.path.expanduser('~/.dbsake/gpg')
gpg = pathutil.which('gpg') or pathutil.which('gpg2')
gpg = pycompat.which('gpg') or pycompat.which('gpg2')
verify_cmd = cmd.shell_format('{0} --verify {1} -', gpg, signature)
info(" - Verifying gpg signature via: %s", verify_cmd)
try:
Expand Down
4 changes: 2 additions & 2 deletions dbsake/core/mysql/sieve/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

import collections

from dbsake import pycompat
from dbsake.util import compression
from dbsake.util import dotdict
from dbsake.util import pathutil

from . import exc
from . import parser
Expand Down Expand Up @@ -48,7 +48,7 @@ def open_stream(options):

def sieve(options):
if options.output_format == 'directory':
pathutil.makedirs(options.directory, exist_ok=True)
pycompat.makedirs(options.directory, exist_ok=True)

if not options.table_schema:
options.exclude_section('tablestructure')
Expand Down

0 comments on commit bc274a0

Please sign in to comment.