1
Publishing Meta-Data Custom Files
2
=================================
4
Meta-data custom files are published, unmodified, to a special area
5
outside the actual archive directory. This is so that the files can be
6
seen even when the archive is private, and allows commercial customers
7
to browse contents for potential later purchase.
9
We can demonstrate this publishing behaviour by creating a
10
PackageUploadCustom object for a meta-data upload:
12
>>> from canonical.launchpad.interfaces.librarian import (
13
... ILibraryFileAliasSet)
14
>>> from cStringIO import StringIO
15
>>> from lp.services.log.logger import FakeLogger
16
>>> from lp.registry.interfaces.distribution import IDistributionSet
17
>>> from lp.soyuz.enums import PackageUploadCustomFormat
18
>>> from lp.soyuz.interfaces.publishing import PackagePublishingPocket
19
>>> from lp.soyuz.model.queue import PackageUploadCustom
21
>>> bat = getUtility(IDistributionSet)['ubuntutest']['breezy-autotest']
22
>>> ppa = factory.makeArchive(distribution=bat.distribution)
23
>>> package_upload = bat.createQueueEntry(
24
... pocket=PackagePublishingPocket.RELEASE, changesfilename="test",
25
... changesfilecontent="test",
28
>>> test_file = getUtility(
29
... ILibraryFileAliasSet).create(
30
... "testmeta", len(content), StringIO(content), "text/plain")
31
>>> custom_upload = PackageUploadCustom()
32
>>> custom_upload.customformat = PackageUploadCustomFormat.META_DATA
33
>>> custom_upload.packageupload = package_upload
34
>>> custom_upload.libraryfilealias = test_file
35
>>> # commit so that the file is put in the librarian.
36
>>> import transaction
37
>>> transaction.commit()
39
Now we can publish the custom upload:
41
>>> custom_upload.publish(logger=FakeLogger())
42
DEBUG Publishing custom testmeta to ubuntutest/breezy-autotest
44
The custom file is just called "testmeta" with the contents "test". It will
45
be published in a location of the scheme:
47
/<person_name>/meta/<ppa_name>/<filename>
50
>>> from lp.archivepublisher.config import getPubConfig
51
>>> pub_config = getPubConfig(ppa)
52
>>> ppa_root = pub_config.distroroot
53
>>> final_destination = os.path.join(
54
... ppa_root, ppa.owner.name, "meta", ppa.name)
55
>>> published_file = os.path.join(
56
... final_destination, "testmeta")
58
>>> os.path.exists(published_file)
61
>>> with open(published_file, 'rb') as fp:
62
... content = fp.read()