Commit 0ae60a1b authored by locallycompact-ct's avatar locallycompact-ct

Update code to python3

parent 4e3a725d
......@@ -13,13 +13,13 @@
# with this program. If not, see <http://www.gnu.org/licenses/>.
import app
import assembly
import cache
import defaults
import morphs
import pots
import deployment
import repos
import sandbox
import utils
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
......@@ -20,15 +20,13 @@
import os
import sys
import fcntl
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
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 sandboxlib
import yaml
......@@ -113,7 +111,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 repos import get_version
from cache import cache_key
from ybd.repos import get_version
from ybd.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
......
......@@ -20,14 +20,12 @@ import contextlib
import fcntl
import errno
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
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 datetime
from splitting import write_metadata, install_split_artifacts
from ybd.splitting import write_metadata, install_split_artifacts
def compose(dn):
......@@ -252,7 +250,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)
......@@ -271,8 +269,8 @@ def gather_integration_commands(dn):
def _gather_recursively(component, commands):
if 'system-integration' in component:
for product, it in component['system-integration'].iteritems():
for name, cmdseq in it.iteritems():
for product, it in component['system-integration'].items():
for name, cmdseq in it.items():
commands["%s-%s" % (name, product)] = cmdseq
for subcomponent in component.get('contents', []):
_gather_recursively(app.defs.get(subcomponent), commands)
......@@ -280,6 +278,6 @@ def gather_integration_commands(dn):
all_commands = {}
_gather_recursively(dn, all_commands)
result = []
for key in sorted(all_commands.keys()):
for key in sorted(list(all_commands.keys())):
result.extend(all_commands[key])
return result
......@@ -22,9 +22,8 @@ import os
import shutil
from subprocess import call
import app
from repos import get_repo_url, get_tree
import utils
from ybd import app, utils
from ybd.repos import get_repo_url, get_tree
import tempfile
import yaml
import re
......@@ -91,7 +90,7 @@ def hash_factors(dn):
hash_factors[factor] = cache_key(factor)
for factor in dn.get('contents', []):
hash_factors[factor.keys()[0]] = cache_key(factor.keys()[0])
hash_factors[list(factor.keys())[0]] = cache_key(list(factor.keys())[0])
relevant_factors = ['tree', 'submodules'] + app.defs.defaults.build_steps
if app.config.get('artifact-version', False) not in range(0, 6):
......
......@@ -15,8 +15,8 @@
# =*= License: GPL-2 =*=
import yaml
import app
from app import log, timer, defs
import ybd.app
from ybd.app import log, timer, defs
# Concourse data model:
# a 'resource' is an input line into a box
......
......@@ -25,7 +25,7 @@ These definitions shall be used if no DEFAULTS file is present.
'''
import os
import app
from ybd import app
import yaml
......
......@@ -17,9 +17,7 @@
import os
from subprocess import call
import json
import app
import cache
import sandbox
from ybd import app, cache, sandbox
def deploy(target):
......@@ -58,7 +56,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', {}).iteritems():
for name, deployment in system_spec.get('deploy', {}).items():
method = deployment.get('type') or deployment.get('upgrade-type')
method = os.path.basename(method)
if deploy_defaults:
......
......@@ -17,8 +17,8 @@
import yaml
import glob
import os
from app import chdir, config, log
from defaults import Defaults
from ybd.app import chdir, config, log
from ybd.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, exc:
except yaml.YAMLError as exc:
log('DEFINITIONS', 'Could not parse %s' % path, exc, exit=True)
if type(contents) is not dict:
......
......@@ -16,9 +16,10 @@
import os
import yaml
from app import config, log
from defaults import Defaults
from morphs import Morphs
from ybd import app
from ybd.app import config, log
from ybd.defaults import Defaults
from ybd.morphs import Morphs
# copied from http://stackoverflow.com/questions/21016220
......@@ -52,7 +53,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', dn.keys()[0]))
return self._data.get(dn.get('path', list(dn.keys())[0]))
def _save_pots(self, filename):
with open(filename, 'w') as f:
......
......@@ -17,10 +17,10 @@
import os
from subprocess import check_output
import tempfile
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
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
def do_release_note(release_note):
......
......@@ -22,8 +22,7 @@ import string
from subprocess import call, check_output
import sys
import requests
import app
import utils
from ybd import app, utils
import tempfile
......
......@@ -24,10 +24,8 @@ import stat
import tempfile
from subprocess import call, PIPE
import app
import cache
import utils
from repos import get_repo_url
from ybd import app, cache, utils
from ybd.repos import get_repo_url
# This must be set to a sandboxlib backend before the run_sandboxed() function
......@@ -154,7 +152,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('string-escape')
unused = "Some Text".encode('unicode-escape')
argv = ['sh', '-c', '-e', command]
......@@ -218,7 +216,7 @@ def run_extension(dn, deployment, step, method):
else:
envlist.append('PYTHONPATH=%s' % app.config['extsdir'])
for key, value in deployment.iteritems():
for key, value in deployment.items():
if key.isupper():
envlist.append("%s=%s" % (key, value))
......
......@@ -14,13 +14,13 @@
#
# =*= License: GPL-2 =*=
import app
from app import config, log, chdir
from cache import get_cache
from ybd import app
from ybd.app import config, log, chdir
from ybd.cache import get_cache
import os
import re
import yaml
from utils import copy_file_list
from ybd.utils import copy_file_list
def install_split_artifacts(dn):
......@@ -47,7 +47,7 @@ def install_split_artifacts(dn):
dn['contents'][index] = {stratum: artifacts}
for content in dn['contents']:
key = content.keys()[0]
key = list(content.keys())[0]
stratum = app.defs.get(key)
move_required_files(dn, stratum, content[key])
......
......@@ -23,7 +23,7 @@ import stat
from fs.osfs import OSFS
from fs.multifs import MultiFS
import calendar
import app
from ybd 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") as infh:
with open(outpath, "w") as outfh:
with open(inpath, "r", encoding='utf-8', errors='ignore') as infh:
with open(outpath, "w", encoding='utf-8', errors='ignore') as outfh:
shutil.copyfileobj(infh, outfh, 1024*1024*4)
shutil.copystat(inpath, outpath)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment