Exemplo n.º 1
0
 def _get_digests(self, target, sizes=False):
     import tuf.client.updater
     updater = tuf.client.updater.Updater('updater',
                                          self._repository_mirrors)
     tgt = updater.target(target)
     updater.download_target(tgt, self._copy_targets_dir)
     with open(path.join(self._copy_targets_dir, target), 'rb') as f:
         manifest = f.read().decode('utf-8')
     return self._dxf.get_alias(manifest=manifest, sizes=sizes)
# Set the local repository directory containing the metadata files.
tuf.conf.repository_directory = "."

# Set the repository mirrors.  This dictionary is needed by the Updater
# class of updater.py.  The client will download metadata and target
# files from any one of these mirrors.
repository_mirrors = {
    "mirror1": {
        "url_prefix": "http://localhost:8001",
        "metadata_path": "metadata",
        "targets_path": "targets",
        "confined_target_dirs": [""],
    }
}

# Create the Upater object using the updater name 'tuf-example'
# and the repository mirrors defined above.
updater = tuf.client.updater.Updater("tuf-example", repository_mirrors)

# Set the local destination directory to save the target files.
destination_directory = "./targets"

# Example demonstrating an update that downloads a specific target.
# The target is signed for by a 'pypi-signed' bin.
updater.refresh()
warehouse_target = updater.target("packages/warehouse/warehouse-14.2.1.tar.gz")
updated_target = updater.updated_targets([warehouse_target], destination_directory)

for target in updated_target:
    updater.download_target(target, destination_directory)
Exemplo n.º 3
0
# Download each of these updated targets and save them locally.
for target in updated_targets:
    try:
        updater.download_target(target, destination_directory)

    except tuf.DownloadError as e:
        pass

# Remove any files from the destination directory that are no longer being
# tracked.
updater.remove_obsolete_targets(destination_directory)

# Example demonstrating an update that only downloads the targets of
# a specific role (i.e., 'targets/project')
updater.refresh()
targets_of_role1 = updater.targets_of_role('targets/project')
updated_targets = updater.updated_targets(targets_of_role1,
                                          destination_directory)

for target in updated_targets:
    updater.download_target(target, destination_directory)

# Example demonstrating an update that downloads a specific target.
updater.refresh()
target = updater.target('/file2.txt')
updated_target = updater.updated_targets([target], destination_directory)

for target in updated_target:
    updater.download_target(target, destination_directory)
Exemplo n.º 4
0
  try:
    updater.download_target(target, destination_directory)
  
  except tuf.DownloadError as e:
    pass

# Remove any files from the destination directory that are no longer being
# tracked.
updater.remove_obsolete_targets(destination_directory)



# Example demonstrating an update that only downloads the targets of
# a specific role (i.e., 'targets/project')
updater.refresh()
targets_of_role1 = updater.targets_of_role('targets/project')
updated_targets = updater.updated_targets(targets_of_role1, destination_directory)

for target in updated_targets:
  updater.download_target(target, destination_directory)



# Example demonstrating an update that downloads a specific target.
updater.refresh()
target = updater.target('/file2.txt')
updated_target = updater.updated_targets([target], destination_directory)

for target in updated_target:
  updater.download_target(target, destination_directory)
tuf.conf.repository_directory = '.'

# Set the repository mirrors.  This dictionary is needed by the Updater
# class of updater.py.  The client will download metadata and target
# files from any one of these mirrors.
repository_mirrors = {
    'mirror1': {
        'url_prefix': 'http://localhost:8001',
        'metadata_path': 'metadata',
        'targets_path': 'targets',
        'confined_target_dirs': ['']
    }
}

# Create the Upater object using the updater name 'tuf-example'
# and the repository mirrors defined above.
updater = tuf.client.updater.Updater('tuf-example', repository_mirrors)

# Set the local destination directory to save the target files.
destination_directory = './targets'

# Example demonstrating an update that downloads a specific target.
# The target is signed for by a 'pypi-signed' bin.
updater.refresh()
warehouse_target = updater.target('packages/warehouse/warehouse-14.2.1.tar.gz')
updated_target = updater.updated_targets([warehouse_target],
                                         destination_directory)

for target in updated_target:
    updater.download_target(target, destination_directory)
# Set the local repository directory containing the metadata files.
tuf.conf.repository_directory = '.'

# Set the repository mirrors.  This dictionary is needed by the Updater
# class of updater.py.  The client will download metadata and target
# files from any one of these mirrors.
repository_mirrors = {'mirror1': {'url_prefix': 'http://localhost:8001',
                                  'metadata_path': 'metadata',
                                  'targets_path': 'targets',
                                  'confined_target_dirs': ['']}}

# Create the Upater object using the updater name 'tuf-example'
# and the repository mirrors defined above.
updater = tuf.client.updater.Updater('tuf-example', repository_mirrors)

# Set the local destination directory to save the target files.
destination_directory = './targets'


# Example demonstrating an update that downloads a specific target.
# The first target is signed for by a 'pypi-signed' bin.  The second target
# is signed by the 'targets/developer-signed/requests.json' role.
updater.refresh()
warehouse_target = updater.target('packages/warehouse/warehouse-14.2.1.tar.gz')
requests_target = updater.target('packages/requests/requests-2.5.1-py2.py3-none-any.whl')
updated_target = updater.updated_targets([warehouse_target, requests_target], destination_directory)

for target in updated_target:
  updater.download_target(target, destination_directory)