Exemplo n.º 1
0
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)
Exemplo n.º 2
0
	def start(self,oneShot=False):
		self.oneShot = oneShot
		
		if not checkForInternet():
			return
		
		# update refresh timerinterval now
		if config.plugins.skyrecorder.autoupdate_database.value:
			try:
				if self.refreshTimer:
					if config.plugins.skyrecorder.database_update_time and config.plugins.skyrecorder.database_update_time.value:
						alarm = setWecker(config.plugins.skyrecorder.database_update_time.value, True) # be sure we shift one day
					else:
						alarm = setWecker([6,0], True) # be sure we shift one day
					config.plugins.skyrecorder.next_update.value = alarm
					config.plugins.skyrecorder.next_update.save()
					configfile.save()
					
					interval = int(config.plugins.skyrecorder.next_update.value) - getCurrentTimestamp()
					self.refreshTimer.stop()
					self.refreshTimer.startLongTimer(interval)
			except Exception:
				sys.exc_clear()
		
		
		if self.oneShot or config.plugins.skyrecorder.autoupdate_database.value:
			msg_log = "[skyrecorder] aktualisiere Datenbank..."
			print msg_log
			self.addLog(msg_log)

			try:
				sql.cur.execute('SELECT SQLITE_VERSION()')
			except Exception:
				sys.exc_clear()
				try:
					sql.connect()
				except Exception:
					self.IS_RUNNING = False
					return
			
			# first clean up old files
			msg_log = "[skyrecorder] entferne alte Eintraege..."
			print msg_log
			self.addLog(msg_log)
			n = sql.deleteEvents(getCurrentTimestamp())
			if n == 1:
				msg_log = "[skyrecorder] {0} Eintrag geloescht".format(n)
			else:
				msg_log = "[skyrecorder] {0} Eintraege geloescht".format(n)
			print msg_log
			self.addLog(msg_log)
			
			self.IS_RUNNING = True
			
			try:
				sql.cur.execute('SELECT SQLITE_VERSION()')
			except Exception:
				sys.exc_clear()
				try:
					sql.connect()
				except Exception:
					self.IS_RUNNING = False
					return
			
			self.station_id = -1
			self.last_station_idx = 0
			self.SkyStations = self.getSkyStations()
			self.maxStationLoop = len(self.SkyStations) - 1
			# start here
			try:
				self.getCookie()
			except Exception, e:
				msg_log = "ERROR: {0}".format(e)
				print msg_log
				self.addLog(msg_log)