def gotSkydbFolder(self, res): # check if we have to create the database from scratch retval = None if res is not None: try: currentdb = config.plugins.skyrecorder.skydb.value except Exception: sys.exc_clear() currentdb = getPluginPath() + "/skydb.db" new_db = res + "skydb.db" retval = True if os.path.exists(currentdb): try: shutil.copy2(currentdb, new_db) except Exception: sys.exc_clear() from SkyCreateDatabase import buildSkydb retval = buildSkydb(target=new_db,rebuild=True,backup=False) else: from SkyCreateDatabase import buildSkydb retval = buildSkydb(target=new_db,rebuild=True,backup=False) if retval: config.plugins.skyrecorder.skydb.value = new_db config.plugins.skyrecorder.skydb.save() self.changedEntry()
def main(session, **kwargs): # let us try to import sqlite3 to see if we have the extension installed try: import sqlite3 ver = sqlite3.sqlite_version print "ok, found sqlite3 with version number {0}".format(ver) del(sqlite3) except Exception: sys.exc_clear() from Screens.MessageBox import MessageBox message = session.open(MessageBox, _("""Konnte SkyRecorder nicht starten.\nBitte 'python-sqlite3' bzw. 'sqlite3' installieren.\n\nBefehle zum Installieren:\nopkg update\nopkg install python-sqlite3\nopkg install sqlite3"""), MessageBox.TYPE_ERROR, timeout=-1) # and so we die return False # check if we have to create the database from scratch res = True try: if config.plugins.skyrecorder.skydb.value: try: sizeb = os.path.getsize(config.plugins.skyrecorder.skydb.value) except Exception: sys.exc_clear() sizeb = 0 if not os.path.exists(config.plugins.skyrecorder.skydb.value) or sizeb == 0: from SkyCreateDatabase import buildSkydb res = buildSkydb(config.plugins.skyrecorder.skydb.value,rebuild=True,backup=False) except Exception: sys.exc_clear() from SkyCreateDatabase import buildSkydb res = buildSkydb(rebuild=True,backup=False) if res: session.open(SkyRecorderMainScreen)
def gotSkydbFolder(self, res): # check if we have to create the database from scratch retval = None can_delete = True if res is not None: if not os.path.exists(res): return try: currentdb = config.plugins.skyrecorder.skydb.value except Exception: sys.exc_clear() currentdb = getPluginPath() + "/skydb.db" new_db = res + "skydb.db" if os.path.exists(new_db): can_delete = self.askOverwriteSkydb(res) retval = True if can_delete: if os.path.exists(currentdb): try: shutil.copy2(currentdb, new_db) except Exception: sys.exc_clear() from SkyCreateDatabase import buildSkydb retval = buildSkydb(target=new_db, rebuild=True, backup=False) else: from SkyCreateDatabase import buildSkydb retval = buildSkydb(target=new_db, rebuild=True, backup=False) if retval: config.plugins.skyrecorder.skydb.value = new_db config.plugins.skyrecorder.skydb.save() config.save() configfile.save() try: sql.disconnect() sql.connect() except Exception: sys.exc_clear() return self.changedEntry()
def autostart(reason, **kwargs): if reason == 0 and (config.plugins.skyrecorder.autoupdate_database and config.plugins.skyrecorder.autoupdate_database.value): if "session" in kwargs: try: import sqlite3 ver = sqlite3.sqlite_version print "ok, found sqlite3 with version number {0}".format(ver) del(sqlite3) except Exception: sys.exc_clear() print "[SkyRecorder] ERROR: could not import sqlite3. Please run: 'opkg update; opkg install python-sqlite3; opkg install sqlite3'" return False # check if we have to create the database from scratch res = True try: if config.plugins.skyrecorder.skydb.value: try: sizeb = os.path.getsize(config.plugins.skyrecorder.skydb.value) except Exception: sys.exc_clear() sizeb = 0 if not os.path.exists(config.plugins.skyrecorder.skydb.value) or sizeb == 0: from SkyCreateDatabase import buildSkydb res = buildSkydb(config.plugins.skyrecorder.skydb.value,rebuild=True,backup=False) except Exception: sys.exc_clear() from SkyCreateDatabase import buildSkydb res = buildSkydb(rebuild=True,backup=False) if res: if not checkForInternet(): return session = kwargs["session"] SkyGetTvGuide(session, True)
def connect(self): try: self.my_db_path = config.plugins.skyrecorder.skydb.value except: self.my_db_path = "{0}/skydb.db".format(getPluginPath()) try: sizeb = os.path.getsize(self.my_db_path) except: sizeb = 0 if not os.path.exists(self.my_db_path) or sizeb == 0: from SkyCreateDatabase import buildSkydb res = buildSkydb(self.my_db_path,rebuild=True,backup=False) self.con = sqlite3.connect(self.my_db_path) self.con.text_factory = str # we need utf-8 strings self.cur = self.con.cursor() self.cur.execute('SELECT SQLITE_VERSION()') data = self.cur.fetchone() if data: return True else: return False