diff options
author | Daniel Firth <dan.firth@codethink.co.uk> | 2016-11-29 13:02:10 +0000 |
---|---|---|
committer | Daniel Firth <dan.firth@codethink.co.uk> | 2016-11-29 13:02:10 +0000 |
commit | 6de6526fc13493722537811c4a5c0e920cc94c0a (patch) | |
tree | 8d8afdde009265658b10dc72c80128ba579e5844 | |
parent | 77eeeea1b20b6e0f11c9903000a86d3148881853 (diff) | |
download | ybd-lc/revert-py3.4.tar.gz |
Revert "Update code to python3"lc/revert-py3.4
This reverts commit 62915d16b2d5577f937e70c3a12e67f331aa87a7.
-rw-r--r-- | ybd/__init__.py | 20 | ||||
-rwxr-xr-x | ybd/__main__.py | 18 | ||||
-rw-r--r-- | ybd/app.py | 6 | ||||
-rw-r--r-- | ybd/assembly.py | 20 | ||||
-rw-r--r-- | ybd/cache.py | 7 | ||||
-rwxr-xr-x | ybd/concourse.py | 4 | ||||
-rw-r--r-- | ybd/defaults.py | 2 | ||||
-rw-r--r-- | ybd/deployment.py | 6 | ||||
-rw-r--r-- | ybd/morphs.py | 6 | ||||
-rw-r--r-- | ybd/pots.py | 9 | ||||
-rw-r--r-- | ybd/release_note.py | 8 | ||||
-rw-r--r-- | ybd/repos.py | 3 | ||||
-rw-r--r-- | ybd/sandbox.py | 10 | ||||
-rw-r--r-- | ybd/splitting.py | 10 | ||||
-rw-r--r-- | ybd/utils.py | 10 |
15 files changed, 74 insertions, 65 deletions
diff --git a/ybd/__init__.py b/ybd/__init__.py index ed7bb46..92593fa 100644 --- a/ybd/__init__.py +++ b/ybd/__init__.py @@ -13,13 +13,13 @@ # with this program. If not, see <http://www.gnu.org/licenses/>. -import ybd.app -import ybd.assembly -import ybd.cache -import ybd.defaults -import ybd.morphs -import ybd.pots -import ybd.deployment -import ybd.repos -import ybd.sandbox -import ybd.utils +import app +import assembly +import cache +import defaults +import morphs +import pots +import deployment +import repos +import sandbox +import utils diff --git a/ybd/__main__.py b/ybd/__main__.py index 59d5f83..27a292f 100755 --- a/ybd/__main__.py +++ b/ybd/__main__.py @@ -20,13 +20,15 @@ import os import sys import fcntl -from ybd import app, cache, sandbox -from ybd.app import cleanup, config, log, RetryException, setup, spawn, timer -from ybd.assembly import compose -from ybd.deployment import deploy -from ybd.pots import Pots -from ybd.concourse import Pipeline -from ybd.release_note import do_release_note +import app +from app import cleanup, config, log, RetryException, setup, spawn, timer +from assembly import compose +from deployment import deploy +from pots import Pots +from concourse import Pipeline +import cache +from release_note import do_release_note +import sandbox import sandboxlib import yaml @@ -111,7 +113,7 @@ with timer('TOTAL'): log('REPRODUCED', 'Matched %s of' % len(config['reproduced']), config['tasks']) for match in config['reproduced']: - print(match[0], match[1]) + print match[0], match[1] if target.get('kind') == 'cluster' and config.get('fork') is None: with timer(target, 'cluster deployment'): @@ -25,8 +25,8 @@ import yaml from multiprocessing import cpu_count, Value, Lock from subprocess import call from fs.osfs import OSFS # not used here, but we import it to check install -from ybd.repos import get_version -from ybd.cache import cache_key +from repos import get_version +from cache import cache_key try: from riemann_client.transport import TCPTransport from riemann_client.client import QueuedClient @@ -238,7 +238,7 @@ def load_configs(config_files): for key, value in yaml.safe_load(text).items(): config[key.replace('_', '-')] = value msg = value if 'PASSWORD' not in key.upper() else '(hidden)' - print(' %s=%s' % (key.replace('_', '-'), msg)) + print ' %s=%s' % (key.replace('_', '-'), msg) print diff --git a/ybd/assembly.py b/ybd/assembly.py index 6dcb051..34f278a 100644 --- a/ybd/assembly.py +++ b/ybd/assembly.py @@ -20,12 +20,14 @@ import contextlib import fcntl import errno -from ybd import app, repos, sandbox -from ybd.app import config, timer, elapsed -from ybd.app import log, log_riemann, lockfile, RetryException -from ybd.cache import cache, cache_key, get_cache, get_remote +import app +from app import config, timer, elapsed +from app import log, log_riemann, lockfile, RetryException +from cache import cache, cache_key, get_cache, get_remote +import repos +import sandbox import datetime -from ybd.splitting import write_metadata, install_split_artifacts +from splitting import write_metadata, install_split_artifacts def compose(dn): @@ -250,7 +252,7 @@ def get_build_commands(dn): bs = app.defs.defaults.detect_build_system(files) if bs == 'manual' and 'install-commands' not in dn: if dn.get('kind', 'chunk') == 'chunk': - print(dn) + print dn log(dn, 'WARNING: No install-commands, manual build-system', exit=exit) log(dn, 'WARNING: Assumed build system is', bs) @@ -269,8 +271,8 @@ def gather_integration_commands(dn): def _gather_recursively(component, commands): if 'system-integration' in component: - for product, it in component['system-integration'].items(): - for name, cmdseq in it.items(): + for product, it in component['system-integration'].iteritems(): + for name, cmdseq in it.iteritems(): commands["%s-%s" % (name, product)] = cmdseq for subcomponent in component.get('contents', []): _gather_recursively(app.defs.get(subcomponent), commands) @@ -278,6 +280,6 @@ def gather_integration_commands(dn): all_commands = {} _gather_recursively(dn, all_commands) result = [] - for key in sorted(list(all_commands.keys())): + for key in sorted(all_commands.keys()): result.extend(all_commands[key]) return result diff --git a/ybd/cache.py b/ybd/cache.py index 2332440..345a8b2 100644 --- a/ybd/cache.py +++ b/ybd/cache.py @@ -22,8 +22,9 @@ import os import shutil from subprocess import call -from ybd import app, utils -from ybd.repos import get_repo_url, get_tree +import app +from repos import get_repo_url, get_tree +import utils import tempfile import yaml import re @@ -90,7 +91,7 @@ def hash_factors(dn): hash_factors[factor] = cache_key(factor) for factor in dn.get('contents', []): - hash_factors[list(factor.keys())[0]] = cache_key(list(factor.keys())[0]) + hash_factors[factor.keys()[0]] = cache_key(factor.keys()[0]) relevant_factors = ['tree', 'submodules'] + app.defs.defaults.build_steps if app.config.get('artifact-version', False) not in range(0, 6): diff --git a/ybd/concourse.py b/ybd/concourse.py index 8a230d2..4d5a201 100755 --- a/ybd/concourse.py +++ b/ybd/concourse.py @@ -15,8 +15,8 @@ # =*= License: GPL-2 =*= import yaml -import ybd.app -from ybd.app import log, timer, defs +import app +from app import log, timer, defs # Concourse data model: # a 'resource' is an input line into a box diff --git a/ybd/defaults.py b/ybd/defaults.py index 52fc16d..a8f2184 100644 --- a/ybd/defaults.py +++ b/ybd/defaults.py @@ -25,7 +25,7 @@ These definitions shall be used if no DEFAULTS file is present. ''' import os -from ybd import app +import app import yaml diff --git a/ybd/deployment.py b/ybd/deployment.py index a802be6..a13d936 100644 --- a/ybd/deployment.py +++ b/ybd/deployment.py @@ -17,7 +17,9 @@ import os from subprocess import call import json -from ybd import app, cache, sandbox +import app +import cache +import sandbox def deploy(target): @@ -56,7 +58,7 @@ def deploy_system(system_spec, parent_location=''): subsystem = dict(deploy_defaults.items() + subsystem.items()) deploy_system(subsystem, parent_location=system['sandbox']) - for name, deployment in system_spec.get('deploy', {}).items(): + for name, deployment in system_spec.get('deploy', {}).iteritems(): method = deployment.get('type') or deployment.get('upgrade-type') method = os.path.basename(method) if deploy_defaults: diff --git a/ybd/morphs.py b/ybd/morphs.py index 5c6b6cb..5796d15 100644 --- a/ybd/morphs.py +++ b/ybd/morphs.py @@ -17,8 +17,8 @@ import yaml import glob import os -from ybd.app import chdir, config, log -from ybd.defaults import Defaults +from app import chdir, config, log +from defaults import Defaults class Morphs(object): @@ -58,7 +58,7 @@ class Morphs(object): with open(path) as f: text = f.read() contents = yaml.safe_load(text) - except yaml.YAMLError as exc: + except yaml.YAMLError, exc: log('DEFINITIONS', 'Could not parse %s' % path, exc, exit=True) if type(contents) is not dict: diff --git a/ybd/pots.py b/ybd/pots.py index 2444b70..cbf494e 100644 --- a/ybd/pots.py +++ b/ybd/pots.py @@ -16,10 +16,9 @@ import os import yaml -from ybd import app -from ybd.app import config, log -from ybd.defaults import Defaults -from ybd.morphs import Morphs +from app import config, log +from defaults import Defaults +from morphs import Morphs # copied from http://stackoverflow.com/questions/21016220 @@ -53,7 +52,7 @@ class Pots(object): return self._data.get(dn) log(dn, 'Unable to find definition for', dn, exit=True) - return self._data.get(dn.get('path', list(dn.keys())[0])) + return self._data.get(dn.get('path', dn.keys()[0])) def _save_pots(self, filename): with open(filename, 'w') as f: diff --git a/ybd/release_note.py b/ybd/release_note.py index 90ee791..19c0e65 100644 --- a/ybd/release_note.py +++ b/ybd/release_note.py @@ -17,10 +17,10 @@ import os from subprocess import check_output import tempfile -from ybd import app -from ybd.app import chdir, config, log -from ybd.morphs import Morphs -from ybd.repos import explore, get_last_tag, get_repo_name, mirror, mirror_has_ref +import app +from app import chdir, config, log +from morphs import Morphs +from repos import explore, get_last_tag, get_repo_name, mirror, mirror_has_ref def do_release_note(release_note): diff --git a/ybd/repos.py b/ybd/repos.py index 746a451..c52adcc 100644 --- a/ybd/repos.py +++ b/ybd/repos.py @@ -22,7 +22,8 @@ import string from subprocess import call, check_output import sys import requests -from ybd import app, utils +import app +import utils import tempfile diff --git a/ybd/sandbox.py b/ybd/sandbox.py index 8d869c2..cfaed2d 100644 --- a/ybd/sandbox.py +++ b/ybd/sandbox.py @@ -24,8 +24,10 @@ import stat import tempfile from subprocess import call, PIPE -from ybd import app, cache, utils -from ybd.repos import get_repo_url +import app +import cache +import utils +from repos import get_repo_url # This must be set to a sandboxlib backend before the run_sandboxed() function @@ -152,7 +154,7 @@ def run_sandboxed(dn, command, env=None, allow_parallel=False): # the child process in a chroot, the required string-escape # python module is already in memory and no attempt to # lazy load it in the chroot is made. - unused = "Some Text".encode('unicode-escape') + unused = "Some Text".encode('string-escape') argv = ['sh', '-c', '-e', command] @@ -216,7 +218,7 @@ def run_extension(dn, deployment, step, method): else: envlist.append('PYTHONPATH=%s' % app.config['extsdir']) - for key, value in deployment.items(): + for key, value in deployment.iteritems(): if key.isupper(): envlist.append("%s=%s" % (key, value)) diff --git a/ybd/splitting.py b/ybd/splitting.py index 0e3bc60..38ead98 100644 --- a/ybd/splitting.py +++ b/ybd/splitting.py @@ -14,13 +14,13 @@ # # =*= License: GPL-2 =*= -from ybd import app -from ybd.app import config, log, chdir -from ybd.cache import get_cache +import app +from app import config, log, chdir +from cache import get_cache import os import re import yaml -from ybd.utils import copy_file_list +from utils import copy_file_list def install_split_artifacts(dn): @@ -33,7 +33,7 @@ def install_split_artifacts(dn): ''' for content in dn['contents']: - key = list(content.keys())[0] + key = content.keys()[0] stratum = app.defs.get(key) move_required_files(dn, stratum, content[key]) diff --git a/ybd/utils.py b/ybd/utils.py index 8fe4b30..13a61c8 100644 --- a/ybd/utils.py +++ b/ybd/utils.py @@ -23,7 +23,7 @@ import stat from fs.osfs import OSFS from fs.multifs import MultiFS import calendar -from ybd import app +import app # The magic number for timestamps: 2011-11-11 11:11:11 default_magic_timestamp = calendar.timegm([2011, 11, 11, 11, 11, 11]) @@ -150,8 +150,8 @@ def _process_tree(root, srcpath, destpath, actionfunc): except: import traceback traceback.print_exc() - print('destpath is', destpath) - print('realpath is', realpath) + print 'destpath is', destpath + print 'realpath is', realpath app.log('UTILS', 'ERROR: file operation failed', exit=True) @@ -210,8 +210,8 @@ def copy_file_list(srcpath, destpath, filelist): ''' def _copyfun(inpath, outpath): - with open(inpath, "r", encoding='utf-8', errors='ignore') as infh: - with open(outpath, "w", encoding='utf-8', errors='ignore') as outfh: + with open(inpath, "r") as infh: + with open(outpath, "w") as outfh: shutil.copyfileobj(infh, outfh, 1024*1024*4) shutil.copystat(inpath, outpath) |