File: mock_dpkg_query

package info (click to toggle)
cfengine3 3.24.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,552 kB
  • sloc: ansic: 163,161; sh: 10,296; python: 2,950; makefile: 1,744; lex: 784; yacc: 633; perl: 211; pascal: 157; xml: 21; sed: 13
file content (38 lines) | stat: -rwxr-xr-x 874 bytes parent folder | download | duplicates (6)
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
#!/usr/bin/python

import sys
import os

log = open(os.environ['CFENGINE_TEST_MOCK_LOG'], "a")
log.write("dpkg-query " + (" ".join(sys.argv[1:])) + "\n")
log.close()

if sys.argv.count("${Architecture}=${Status}\n"):
    if sys.argv.count("netcat:*"):
        sys.stdout.write('''amd64=install ok installed
i386=install ok installed
should-not-be-here= not-installed
''')
else:
    # Assembled from various pieces of running dpkg-query.
    sys.stdout.write('''Status=deinstall ok config-files
Name=firefox
Version=24.5.0-1.el5.centos
Architecture=i386
Status=install ok config-files
Name=firefox
Version=24.5.0-1.el5.centos
Architecture=amd64
Status=hold ok config-files
Name=netcat
Version=1.2.3.4
Architecture=amd64
Status=hold ok installed
Name=netcat
Version=1.2.3.5
Architecture=amd64
Status=install ok installed
Name=yum
Version=3.2.29-43.el6_5
Architecture=all
''')