MCPcopy Index your code
hub / github.com/Bitmessage/PyBitmessage / check_sqlite

Function check_sqlite

src/depends.py:42–80  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

40 return True
41
42def check_sqlite():
43 if sys.hexversion < 0x020500F0:
44 logger.error('The sqlite3 module is not included in this version of Python.')
45 if sys.platform.startswith('freebsd'):
46 logger.error('On FreeBSD, try running "pkg install py27-sqlite3" as root.')
47 return False
48 try:
49 import sqlite3
50 except ImportError:
51 logger.error('The sqlite3 module is not available')
52 return False
53
54 logger.info('sqlite3 Module Version: ' + sqlite3.version)
55 logger.info('SQLite Library Version: ' + sqlite3.sqlite_version)
56 #sqlite_version_number formula: https://sqlite.org/c3ref/c_source_id.html
57 sqlite_version_number = sqlite3.sqlite_version_info[0] * 1000000 + sqlite3.sqlite_version_info[1] * 1000 + sqlite3.sqlite_version_info[2]
58
59 conn = None
60 try:
61 try:
62 conn = sqlite3.connect(':memory:')
63 if sqlite_version_number >= 3006018:
64 sqlite_source_id = conn.execute('SELECT sqlite_source_id();').fetchone()[0]
65 logger.info('SQLite Library Source ID: ' + sqlite_source_id)
66 if sqlite_version_number >= 3006023:
67 compile_options = ', '.join(map(lambda row: row[0], conn.execute('PRAGMA compile_options;')))
68 logger.info('SQLite Library Compile Options: ' + compile_options)
69 #There is no specific version requirement as yet, so we just use the
70 #first version that was included with Python.
71 if sqlite_version_number < 3000008:
72 logger.error('This version of SQLite is too old. PyBitmessage requires SQLite 3.0.8 or later')
73 return False
74 return True
75 except sqlite3.Error:
76 logger.exception('An exception occured while checking sqlite.')
77 return False
78 finally:
79 if conn:
80 conn.close()
81
82def check_openssl():
83 try:

Callers

nothing calls this directly

Calls 3

executeMethod · 0.80
connectMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected