~gz/juju-ci-tools/jes_no_upload

« back to all changes in this revision

Viewing changes to candidate.py

  • Committer: seman.said at canonical
  • Date: 2015-08-18 17:08:05 UTC
  • mfrom: (1063.2.1 osx-candidate)
  • Revision ID: seman.said@canonical.com-20150818170805-tzs9gfki2uemkaqj
Updated to extract the OS X client from the artifacts directory.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
import shutil
11
11
import subprocess
12
12
import sys
 
13
import tarfile
13
14
import traceback
14
15
 
15
16
from jujuci import (
24
25
from utility import (
25
26
    extract_deb,
26
27
    get_deb_arch,
 
28
    print_now,
27
29
    run_command,
28
30
    s3_cmd,
29
31
    temp_dir,
30
32
)
31
33
 
32
34
 
 
35
OSX_DIR_SUFFIX = "-osx-artifacts"
 
36
 
 
37
 
33
38
def get_build_parameters(build_data):
34
39
    parameters = {}
35
40
    action_list = build_data['actions']
62
67
 
63
68
 
64
69
def prepare_dir(dir_path, dry_run=False, verbose=False):
65
 
    """Create to clean a direcory."""
 
70
    """Create to clean a directory."""
66
71
    if os.path.isdir(dir_path):
67
72
        if verbose:
68
73
            print('Cleaning %s' % dir_path)
94
99
    get_artifacts(
95
100
        credentials, PUBLISH_REVISION, pr_number, 'juju-core*', candidate_dir,
96
101
        dry_run=dry_run, verbose=verbose)
 
102
    download_osx_client(candidate_dir, br_number)
 
103
 
 
104
 
 
105
def download_osx_client(
 
106
        candidate_dir, br_number, dry_run=False, verbose=False):
 
107
    osx_dir = candidate_dir.replace('-artifacts', OSX_DIR_SUFFIX)
 
108
    prepare_dir(osx_dir, dry_run=dry_run, verbose=verbose)
 
109
    url = ("s3://juju-qa-data/juju-ci/products/version-{}/"
 
110
           "build-osx-client".format(br_number))
 
111
    if verbose:
 
112
        print_now('Retrieving OS X client from S3: %s' % osx_dir)
 
113
    if not dry_run:
 
114
        s3_cmd(['sync', '--exclude', '*', '--include', '*.tar.gz', url,
 
115
                osx_dir])
97
116
 
98
117
 
99
118
def get_artifact_dirs(path):
132
151
        with open(buildvars_path) as bf:
133
152
            buildvars = json.load(bf)
134
153
        version = buildvars['version']
135
 
        package_path = get_package(artifacts_path, version)
136
 
        candidate_path = os.path.join(path, version)
 
154
        if artifacts_path.endswith(OSX_DIR_SUFFIX):
 
155
            package_path = subprocess.check_output(
 
156
                ['find', artifacts_path, '-name', 'juju*osx.tar.gz']).strip()
 
157
            candidate_path = os.path.join(path, "{}-osx".format(version))
 
158
        else:
 
159
            package_path = get_package(artifacts_path, version)
 
160
            candidate_path = os.path.join(path, version)
137
161
        if verbose:
138
162
            print('extracting %s to %s' % (package_path, candidate_path))
139
163
        prepare_dir(candidate_path, dry_run, verbose)
140
164
        if not dry_run:
141
 
            extract_deb(package_path, candidate_path)
 
165
            if artifacts_path.endswith(OSX_DIR_SUFFIX):
 
166
                with tarfile.open(package_path, 'r:gz') as tar_file:
 
167
                    tar_file.extractall(candidate_path)
 
168
            else:
 
169
                extract_deb(package_path, candidate_path)
142
170
        if verbose:
143
171
            print('Copying %s to %s' % (buildvars_path, candidate_path))
144
172
        if not dry_run: