Update of /cvsroot/freevo/freevo/lib/pyepg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20028
Modified Files:
guide.py
Log Message:
wait when db is locked
Index: guide.py
===================================================================
RCS file: /cvsroot/freevo/freevo/lib/pyepg/guide.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** guide.py 4 Dec 2004 01:31:49 -0000 1.11
--- guide.py 5 Dec 2004 17:08:53 -0000 1.12
***************
*** 11,14 ****
--- 11,17 ----
# -----------------------------------------------------------------------
# $Log$
+ # Revision 1.12 2004/12/05 17:08:53 dischi
+ # wait when db is locked
+ #
# Revision 1.11 2004/12/04 01:31:49 rshortt
# -get_channels() roughly sorts the channels returned. We will add sorting
***************
*** 137,143 ****
print "Python SQLite not installed!"
! from sqlite import IntegrityError
class EPGDB:
"""
--- 140,174 ----
print "Python SQLite not installed!"
! from sqlite import IntegrityError, OperationalError
! import notifier
+ class _SQLite:
+ def __init__(self, dbpath):
+ while 1:
+ try:
+ self.db = sqlite.connect(dbpath, client_encoding='utf-8',
+ timeout=10)
+ break
+ except OperationalError, e:
+ notifier.step(False, False)
+ self.cursor = self.db.cursor()
+
+
+ def commit(self):
+ self.db.commit()
+
+ def close(self):
+ self.db.close()
+
+ def execute(self, query):
+ while 1:
+ try:
+ self.cursor.execute(query)
+ return self.cursor.fetchall()
+ except OperationalError, e:
+ notifier.step(False, False)
+
+
class EPGDB:
"""
***************
*** 151,157 ****
os.system('sqlite %s < %s 2>/dev/null >/dev/null' % (dbpath,
scheme))
print 'done'
!
! self.db = sqlite.connect(dbpath, client_encoding='utf-8', timeout=10)
! self.cursor = self.db.cursor()
--- 182,186 ----
os.system('sqlite %s < %s 2>/dev/null >/dev/null' % (dbpath,
scheme))
print 'done'
! self.db = _SQLite(dbpath)
***************
*** 160,164 ****
try:
! self.cursor.execute(query)
except TypeError:
traceback.print_exc()
--- 189,193 ----
try:
! result = self.db.execute(query)
except TypeError:
traceback.print_exc()
***************
*** 167,176 ****
if close:
# run a single query then close
- result = self.cursor.fetchall()
self.db.commit()
self.db.close()
return result
else:
! return self.cursor.fetchall()
--- 196,204 ----
if close:
# run a single query then close
self.db.commit()
self.db.close()
return result
else:
! return result
***************
*** 179,183 ****
self.db.close()
-
def commit(self):
self.db.commit()
--- 207,210 ----
***************
*** 188,194 ****
return False
# verify the table exists
! self.cursor.execute('select name from sqlite_master where \
! name="%s" and type="table"' % table)
! if not self.cursor.fetchone():
return None
return table
--- 215,220 ----
return False
# verify the table exists
! if not self.db.execute('select name from sqlite_master where ' + \
! 'name="%s" and type="table"' % table):
return None
return table
***************
*** 213,219 ****
def get_channels(self):
query = 'select * from channels order by access_id'
!
! rows = self.execute(query)
! return rows
--- 239,243 ----
def get_channels(self):
query = 'select * from channels order by access_id'
! return self.execute(query)
***************
*** 345,348 ****
--- 369,373 ----
rows = self.execute('select * from programs where channel_id="%s"
\
and start=%s' % (channel_id, start))
+ self.commit()
for row in rows:
print ' %s' % row
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://productguide.itmanagersjournal.com/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog