Update of /cvsroot/freevo/freevo/lib/pyepg
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15569/lib/pyepg
Modified Files:
db_sqlite.py
Log Message:
Better error handling, reporting and deal with different situations.
Index: db_sqlite.py
===================================================================
RCS file: /cvsroot/freevo/freevo/lib/pyepg/db_sqlite.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** db_sqlite.py 7 Apr 2005 11:55:27 -0000 1.4
--- db_sqlite.py 7 Apr 2005 15:59:35 -0000 1.5
***************
*** 35,38 ****
--- 35,39 ----
import os
import logging
+ import traceback
# notifier
***************
*** 53,65 ****
"""
def __init__(self, dbpath):
! if os.path.isfile(dbpath) and os.path.getsize(dbpath) == 0:
! log.error('EPG database is zero size (invalid), removing it')
! os.system('rm %s' % dbath)
if not os.path.isfile(dbpath):
! # TODO: try to find sqlite in the path, error if not
! log.warning('EPG database missing, creating it')
! scheme = os.path.join(os.path.dirname(__file__), 'epg_schema.sql')
! os.system('sqlite %s < %s 2>/dev/null >/dev/null' % \
! (dbpath, scheme))
while 1:
try:
--- 54,83 ----
"""
def __init__(self, dbpath):
! try:
! if os.path.getsize(dbpath) == 0:
! log.error('EPG database is zero size (invalid), removing it')
! os.system('rm %s' % dbath)
! except OSError:
! if os.path.isfile(dbpath):
! log.error('Problem reading %s, check permissions' % dbpath)
! traceback.print_exc()
! raise OSError
!
if not os.path.isfile(dbpath):
!
! # try to find sqlite in the path, error if not
! for dirname in os.environ['PATH'].split(':'):
! sqlite_path = os.path.join(dirname, 'sqlite')
! if os.path.exists(sqlite_path) and
os.path.isfile(sqlite_path):
! break
! else:
! log.error('sqlite not found, please check your installation')
! raise RuntimeError
!
! log.warning('EPG database missing, creating it: %s' % sqlite_path)
! schema = os.path.join(os.path.dirname(__file__), 'epg_schema.sql')
! os.system('%s %s < %s 2>/dev/null >/dev/null' % \
! (sqlite_path, dbpath, schema))
!
while 1:
try:
***************
*** 69,73 ****
--- 87,93 ----
except OperationalError, e:
notifier.step(False, False)
+
self.cursor = self.db.cursor()
+
ver = self.get_version()
log.info('EPG database version %s' % ver)
***************
*** 79,85 ****
def upgrade_db(self, ver):
- # TODO: finish this or change it
- # Here's a quick hack for the current upgrade:
-
if ver == "0.0.0" and latest_version == "0.1.1":
log.info('Upgrading EPG database from %s to %s.' % \
--- 99,102 ----
***************
*** 112,115 ****
--- 129,133 ----
return self.execute('select version from versioning where
thing="sql"')[0][0]
else:
+ log.warning('EPG database version check failed, using 0.0.0')
return "0.0.0"
-------------------------------------------------------
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://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click
_______________________________________________
Freevo-cvslog mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog