~ubuntu-branches/ubuntu/quantal/landscape-client/quantal-201411191733

« back to all changes in this revision

Viewing changes to landscape/package/store.py

Merge 12.05 from Andreas Hasenack

Show diffs side-by-side

added added

removed removed

Lines of Context:
249
249
        cursor.execute("DELETE FROM locked")
250
250
 
251
251
    @with_cursor
252
 
    def get_package_locks(self, cursor):
253
 
        """Get all package locks."""
254
 
        cursor.execute("SELECT name, relation, version FROM package_locks")
255
 
        return [(row[0], row[1], row[2]) for row in cursor.fetchall()]
256
 
 
257
 
    @with_cursor
258
 
    def add_package_locks(self, cursor, locks):
259
 
        """Add a list of package locks to the store.
260
 
 
261
 
        @param locks: A C{list} of ternary tuples each one contains the
262
 
            name, the relation and the version of the package lock to be added.
263
 
        """
264
 
        for name, relation, version in locks:
265
 
            cursor.execute("REPLACE INTO package_locks VALUES (?, ?, ?)",
266
 
                           (name, relation or "", version or "",))
267
 
 
268
 
    @with_cursor
269
 
    def remove_package_locks(self, cursor, locks):
270
 
        """Remove a list of package locks from the store.
271
 
 
272
 
        @param locks: A C{list} of ternary tuples each one contains the name,
273
 
            the relation and the version of the package lock to be removed.
274
 
        """
275
 
        for name, relation, version in locks:
276
 
            cursor.execute("DELETE FROM package_locks WHERE name=? AND "
277
 
                           "relation=? AND version=?",
278
 
                           (name, relation or "", version or ""))
279
 
 
280
 
    @with_cursor
281
 
    def clear_package_locks(self, cursor):
282
 
        """Remove all package locks."""
283
 
        cursor.execute("DELETE FROM package_locks")
284
 
 
285
 
    @with_cursor
286
252
    def add_hash_id_request(self, cursor, hashes):
287
253
        hashes = list(hashes)
288
254
        cursor.execute("INSERT INTO hash_id_request (hashes, timestamp)"
458
424
    #       try block.
459
425
    cursor = db.cursor()
460
426
    try:
461
 
        cursor.execute("CREATE TABLE package_locks"
462
 
                       " (name TEXT NOT NULL, relation TEXT, version TEXT,"
463
 
                       " UNIQUE(name, relation, version))")
464
427
        cursor.execute("CREATE TABLE locked"
465
428
                       " (id INTEGER PRIMARY KEY)")
466
429
        cursor.execute("CREATE TABLE available"