~launchpad-pqm/launchpad/devel

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
= Update-pkgcache script =

Package cache system is better described in package-cache.txt.

'update-pkgcache.py' is supposed to run periodically in our
infrastructure and it is localised in the 'cronscripts' directory

  >>> import os
  >>> from lp.services.config import config
  >>> script = os.path.join(config.root, "cronscripts", "update-pkgcache.py")

Database sampledata has two pending modifications of package cache
contents:

  >>> from lp.registry.interfaces.distribution import IDistributionSet
  >>> ubuntu = getUtility(IDistributionSet)['ubuntu']
  >>> warty = ubuntu['warty']

'cdrkit' source and binary are published but it's not present in
cache:

  >>> ubuntu.searchSourcePackages('cdrkit').count()
  0
  >>> warty.searchPackages('cdrkit').count()
  0

'foobar' source and binary are removed but still present in cache:

  >>> ubuntu.searchSourcePackages('foobar').count()
  1
  >>> warty.searchPackages('foobar').count()
  1

Normal operation produces INFO level information about the
distribution and respective distroseriess considered in stderr.

  >>> import subprocess
  >>> import sys
  >>> process = subprocess.Popen([sys.executable, script],
  ...                            stdout=subprocess.PIPE,
  ...                            stderr=subprocess.PIPE)
  >>> stdout, stderr = process.communicate()
  >>> process.returncode
  0

  >>> print stdout

  >>> print stderr
  INFO    Creating lockfile: /var/lock/launchpad-update-cache.lock
  INFO    Updating ubuntu package counters
  INFO    Updating ubuntu main archives
  ...
  INFO    Updating ubuntu PPAs
  ...
  INFO    redhat done

Rollback the old transaction in order to get the modifications done by
the external script:

 >>> import transaction
 >>> transaction.abort()

Now, search results are up to date:

  >>> ubuntu.searchSourcePackages('cdrkit').count()
  1
  >>> warty.searchPackages('cdrkit').count()
  1

  >>> ubuntu.searchSourcePackages('foobar').count()
  0
  >>> warty.searchPackages('foobar').count()
  0