def initialize_build(self, **kwargs):
    if (not self._is_enabled):
        return
    build_resources = []
    build_resources = (self.loader.build_resources if self.loader else [])
    sha_to_build_resource = {}
    for build_resource in build_resources:
        sha_to_build_resource[build_resource.sha] = build_resource
    self._current_build = self.client.create_build(resources=build_resources, **kwargs)
    try:
        missing_resources = self._current_build['data']['relationships']['missing-resources']
        missing_resources = missing_resources.get('data', [])
        for missing_resource in missing_resources:
            sha = missing_resource['id']
            resource = sha_to_build_resource.get(sha)
            if resource:
                print('Uploading new build resource: {}'.format(resource.resource_url))
                if resource.local_path:
                    with open(resource.local_path, 'rb') as f:
                        content = f.read()
                else:
                    content = resource.content
                self.client.upload_resource(self._current_build['data']['id'], content)
    except KeyError:
        print(self._current_build)
def initialize_build(self, **kwargs):
    if (not self._is_enabled):
        return
    build_resources = []
    build_resources = (self.loader.build_resources if self.loader else [])
    sha_to_build_resource = {}
    for build_resource in build_resources:
        sha_to_build_resource[build_resource.sha] = build_resource
    self._current_build = self.client.create_build(resources=build_resources, **kwargs)
    try:
        missing_resources = self._current_build['data']['relationships']['missing-resources']
        missing_resources = missing_resources.get('data', [])
        for missing_resource in missing_resources:
            sha = missing_resource['id']
            resource = sha_to_build_resource.get(sha)
            if resource:
                print('Uploading new build resource: {}'.format(resource.resource_url))
                if resource.local_path:
                    with open(resource.local_path, 'rb') as f:
                        content = f.read()
                else:
                    content = resource.content
                self.client.upload_resource(self._current_build['data']['id'], content)
    except KeyError:
        print(self._current_build)