MCPcopy
hub / github.com/saltstack/salt / init

Function init

salt/spm/pkgdb/sqlite3.py:18–71  ·  view source on GitHub ↗

Get an sqlite3 connection, and initialize the package database if necessary

()

Source from the content-addressed store, hash-verified

16
17
18def init():
19 """
20 Get an sqlite3 connection, and initialize the package database if necessary
21 """
22 if not os.path.exists(__opts__["spm_cache_dir"]):
23 log.debug("Creating SPM cache directory at %s", __opts__["spm_db"])
24 os.makedirs(__opts__["spm_cache_dir"])
25
26 if not os.path.exists(__opts__["spm_db"]):
27 log.debug("Creating new package database at %s", __opts__["spm_db"])
28
29 sqlite3.enable_callback_tracebacks(True)
30 conn = sqlite3.connect(__opts__["spm_db"], isolation_level=None)
31
32 try:
33 conn.execute("SELECT count(*) FROM packages")
34 except OperationalError:
35 conn.execute(
36 """CREATE TABLE packages (
37 package text,
38 version text,
39 release text,
40 installed text,
41 os text,
42 os_family text,
43 dependencies text,
44 os_dependencies text,
45 os_family_dependencies text,
46 summary text,
47 description text
48 )"""
49 )
50
51 try:
52 conn.execute("SELECT count(*) FROM files")
53 except OperationalError:
54 conn.execute(
55 """CREATE TABLE files (
56 package text,
57 path text,
58 size real,
59 mode text,
60 sum text,
61 major text,
62 minor text,
63 linkname text,
64 linkpath text,
65 uname text,
66 gname text,
67 mtime text
68 )"""
69 )
70
71 return conn
72
73
74def info(package, conn=None):

Callers 7

infoFunction · 0.70
list_packagesFunction · 0.70
list_filesFunction · 0.70
register_pkgFunction · 0.70
register_fileFunction · 0.70
unregister_pkgFunction · 0.70
unregister_fileFunction · 0.70

Calls 4

debugMethod · 0.80
existsMethod · 0.45
connectMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected