diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2012-01-10 14:13:50 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-01-11 10:36:20 +0000 |
commit | 489cde8eb0e19ef6fe8078148199eaf5b52631ae (patch) | |
tree | cb85947000c8efb778362c136f1f6a0c14ed31dc /bitbake/lib/prserv/db.py | |
parent | 30a9bc6c92a8920d6e9c4a4b93b83bdbe5d48e78 (diff) | |
download | poky-489cde8eb0e19ef6fe8078148199eaf5b52631ae.tar.gz |
bitbake: Automatically start local PR service.
[YOCTO #1126]
A local PR service will be started and stopped automatically along
with the bitbake invocation/ternimation.
This local PR service will be started only and if only when the
PRSERV_HOST is set to 'localhost' and PRSERV_PORT is set to '0'.
When started, the sqlite3 database is stored at
"${PERSISTEN_DIR}/prserv.sqlite3" or "${CACHE}/prserv.sqlite3".
(Bitbake rev: 9d8f45407c67ed0d3c4f820cf646de3c385067c7)
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/prserv/db.py')
-rw-r--r-- | bitbake/lib/prserv/db.py | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/bitbake/lib/prserv/db.py b/bitbake/lib/prserv/db.py index f267daed13..9d8e9db9f2 100644 --- a/bitbake/lib/prserv/db.py +++ b/bitbake/lib/prserv/db.py | |||
@@ -8,6 +8,8 @@ try: | |||
8 | except ImportError: | 8 | except ImportError: |
9 | from pysqlite2 import dbapi2 as sqlite3 | 9 | from pysqlite2 import dbapi2 as sqlite3 |
10 | 10 | ||
11 | logger = logging.getLogger("BitBake.PRserv") | ||
12 | |||
11 | sqlversion = sqlite3.sqlite_version_info | 13 | sqlversion = sqlite3.sqlite_version_info |
12 | if sqlversion[0] < 3 or (sqlversion[0] == 3 and sqlversion[1] < 3): | 14 | if sqlversion[0] < 3 or (sqlversion[0] == 3 and sqlversion[1] < 3): |
13 | raise Exception("sqlite3 version 3.3.0 or later is required.") | 15 | raise Exception("sqlite3 version 3.3.0 or later is required.") |
@@ -55,7 +57,7 @@ class PRTable(): | |||
55 | (version,pkgarch, checksum,version, pkgarch)) | 57 | (version,pkgarch, checksum,version, pkgarch)) |
56 | self.conn.commit() | 58 | self.conn.commit() |
57 | except sqlite3.IntegrityError as exc: | 59 | except sqlite3.IntegrityError as exc: |
58 | logging.error(str(exc)) | 60 | logger.error(str(exc)) |
59 | 61 | ||
60 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | 62 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, |
61 | (version, pkgarch, checksum)) | 63 | (version, pkgarch, checksum)) |
@@ -83,7 +85,7 @@ class PRTable(): | |||
83 | (version, pkgarch, checksum, version, pkgarch)) | 85 | (version, pkgarch, checksum, version, pkgarch)) |
84 | self.conn.commit() | 86 | self.conn.commit() |
85 | except sqlite3.IntegrityError as exc: | 87 | except sqlite3.IntegrityError as exc: |
86 | logging.error(str(exc)) | 88 | logger.error(str(exc)) |
87 | self.conn.rollback() | 89 | self.conn.rollback() |
88 | 90 | ||
89 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | 91 | data=self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, |
@@ -115,7 +117,7 @@ class PRTable(): | |||
115 | (version, pkgarch, checksum, value)) | 117 | (version, pkgarch, checksum, value)) |
116 | self.conn.commit() | 118 | self.conn.commit() |
117 | except sqlite3.IntegrityError as exc: | 119 | except sqlite3.IntegrityError as exc: |
118 | logging.error(str(exc)) | 120 | logger.error(str(exc)) |
119 | 121 | ||
120 | data = self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, | 122 | data = self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=?;" % self.table, |
121 | (version, pkgarch, checksum)) | 123 | (version, pkgarch, checksum)) |
@@ -140,7 +142,7 @@ class PRTable(): | |||
140 | (value,version,pkgarch,checksum,value)) | 142 | (value,version,pkgarch,checksum,value)) |
141 | self.conn.commit() | 143 | self.conn.commit() |
142 | except sqlite3.IntegrityError as exc: | 144 | except sqlite3.IntegrityError as exc: |
143 | logging.error(str(exc)) | 145 | logger.error(str(exc)) |
144 | 146 | ||
145 | data = self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=? AND value>=?;" % self.table, | 147 | data = self._execute("SELECT value FROM %s WHERE version=? AND pkgarch=? AND checksum=? AND value>=?;" % self.table, |
146 | (version,pkgarch,checksum,value)) | 148 | (version,pkgarch,checksum,value)) |
@@ -241,5 +243,5 @@ class PRData(object): | |||
241 | def __delitem__(self, tblname): | 243 | def __delitem__(self, tblname): |
242 | if tblname in self._tables: | 244 | if tblname in self._tables: |
243 | del self._tables[tblname] | 245 | del self._tables[tblname] |
244 | logging.info("drop table %s" % (tblname)) | 246 | logger.info("drop table %s" % (tblname)) |
245 | self.connection.execute("DROP TABLE IF EXISTS %s;" % tblname) | 247 | self.connection.execute("DROP TABLE IF EXISTS %s;" % tblname) |