コード例 #1
0
ファイル: storage.py プロジェクト: keras/python-agent
    def _is_build(self, image):
        try:
            if is_str_set(image.data.fields.build, "context") or is_str_set(image.data.fields.build, "remote"):
                return True
        except (KeyError, AttributeError):
            pass

        return False
コード例 #2
0
ファイル: storage.py プロジェクト: m4ce/python-agent
    def _is_build(self, image):
        try:
            if is_str_set(image.data.fields.build, 'context') or \
                    is_str_set(image.data.fields.build, 'remote'):
                return True
        except (KeyError, AttributeError):
            pass

        return False
コード例 #3
0
ファイル: storage.py プロジェクト: dx9/python-agent
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            with closing(requests.get(opts['context'], stream=True)) as r:
                if r.status_code != 200:
                    raise Exception('Bad response {} from {}'
                                    .format(r.status_code,
                                            opts['context']))
                del opts['context']
                opts['fileobj'] = ResponseWrapper(r)
                opts['custom_context'] = True
                do_build()
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()
コード例 #4
0
ファイル: storage.py プロジェクト: m4ce/python-agent
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            opts['rm'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            with closing(requests.get(opts['context'], stream=True)) as r:
                if r.status_code != 200:
                    raise Exception('Bad response {} from {}'.format(
                        r.status_code, opts['context']))
                del opts['context']
                opts['fileobj'] = ResponseWrapper(r)
                opts['custom_context'] = True
                do_build()
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()
コード例 #5
0
ファイル: storage.py プロジェクト: keras/python-agent
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ["context", "remote"]:
                if key in opts:
                    del opts[key]
            opts["stream"] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status["stream"])
                except:
                    pass

        if is_str_set(opts, "context"):
            with closing(requests.get(opts["context"], stream=True)) as r:
                if r.status_code != 200:
                    raise Exception("Bad response {} from {}".format(r.status_code, opts["context"]))
                del opts["context"]
                opts["fileobj"] = ResponseWrapper(r)
                opts["custom_context"] = True
                do_build()
        else:
            remote = opts["remote"]
            if remote.startswith("[email protected]:"):
                remote = remote.replace("[email protected]:", "git://github.com/")
            del opts["remote"]
            opts["path"] = remote
            do_build()
コード例 #6
0
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            opts['rm'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            downloaded = None
            try:
                downloaded = download_file(opts['context'], Config.builds())
                with open(downloaded) as f:
                    del opts['context']
                    opts['fileobj'] = f
                    opts['custom_context'] = True
                    do_build()
            finally:
                if downloaded is not None:
                    os.remove(downloaded)
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()
コード例 #7
0
ファイル: storage.py プロジェクト: imikushin/python-agent
    def _image_build(self, image, progress):
        client = docker_client()
        opts = dict(image.data.fields.build)

        def do_build():
            for key in ['context', 'remote']:
                if key in opts:
                    del opts[key]
            opts['stream'] = True
            opts['rm'] = True
            marshaller = get_type(MARSHALLER)
            for status in client.build(**opts):
                try:
                    status = marshaller.from_string(status)
                    progress.update(status['stream'])
                except:
                    pass

        if is_str_set(opts, 'context'):
            downloaded = None
            try:
                downloaded = download_file(opts['context'], Config.builds())
                with open(downloaded) as f:
                    del opts['context']
                    opts['fileobj'] = f
                    opts['custom_context'] = True
                    do_build()
            finally:
                if downloaded is not None:
                    os.remove(downloaded)
        else:
            remote = opts['remote']
            if remote.startswith('[email protected]:'):
                remote = remote.replace('[email protected]:', 'git://github.com/')
            del opts['remote']
            opts['path'] = remote
            do_build()