Skip to content

Commit

Permalink
Added scheduler for updating game lists
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dlesk committed Jan 10, 2012
1 parent dad2bd7 commit 5456be9
Show file tree
Hide file tree
Showing 52 changed files with 33 additions and 7 deletions.
Binary file modified Gamez.db
Binary file not shown.
2 changes: 1 addition & 1 deletion Gamez.ini
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ port = 8081

[Scheduler]
download_interval = 60
game_list_update_interval = 86400

[SystemGenerated]
is_to_ignore_update = 0
ignored_version =
api_key = "ikzFRzA1Y8I1UajNJAOQ803TbTYk1vLB64A9SxrAxAw"

[Notifications]
prowl__api =
prowl_api = ""

24 changes: 21 additions & 3 deletions Gamez.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import cherrypy.process.plugins
from cherrypy.process.plugins import Daemonizer
from lib.ConfigFunctions import CheckConfigForAllKeys
from lib.DBFunctions import ValidateDB
from lib.DBFunctions import ValidateDB,AddWiiGamesIfMissing,AddXbox360GamesIfMissing
from lib.Logger import LogEvent
import cherrypy.lib.auth_basic

Expand Down Expand Up @@ -63,16 +63,21 @@ def RunWebServer(self,isToDaemonize):
config = ConfigParser.RawConfigParser()
config.read('Gamez.ini')
interval = config.get('Scheduler','download_interval').replace('"','')
updateGameListInterval = config.get('Scheduler','game_list_update_interval').replace('"','')
fInterval = float(interval)
fUpdateGameListInterval = float(updateGameListInterval)
workerTask = cherrypy.process.plugins.BackgroundTask(fInterval,RunGameTask)
gameListUpdaterWorkTask = cherrypy.process.plugins.BackgroundTask(fUpdateGameListInterval,RunGameListUpdaterTask)
try:
workerTask.start()
workerTask.start()
gameListUpdaterWorkTask.start()

LogEvent("Starting the Gamez web server")
cherrypy.quickstart(WebRoot(app_path),'/',config=conf)
except KeyboardInterrupt:
LogEvent("Shutting down Gamez")
workerTask.cancel()
gameListUpdaterWorkTask.cancel()
if(isToDaemonize == 1):
daemon.unsubscribe()

Expand Down Expand Up @@ -136,6 +141,19 @@ def RunGameTask():
errorMessage = errorMessage + " - " + str(message)
LogEvent(errorMessage)

def RunGameListUpdaterTask():
try:
LogEvent("Updating Game Lists")
AddWiiGamesIfMissing()
LogEvent("Wii Game List Updated")
AddXbox360GamesIfMissing()
LogEvent("XBOX 360 Game List Updated")
except:
errorMessage = "Major error occured when running Update Game List scheduled tasks"
for message in sys.exc_info():
errorMessage = errorMessage + " - " + str(message)
LogEvent(errorMessage)

if __name__ == '__main__':
app_path = sys.path[0]
ValidateDB()
Expand All @@ -147,4 +165,4 @@ def RunGameTask():
if(param == "-d"):
isToDaemonize = 1

RunApp().RunWebServer(isToDaemonize)
RunApp().RunWebServer(isToDaemonize)
Binary file modified cherrypy/__init__.pyc
Binary file not shown.
Binary file modified cherrypy/_cpchecker.pyc
Binary file not shown.
Binary file modified cherrypy/_cpcompat.pyc
Binary file not shown.
Binary file modified cherrypy/_cpconfig.pyc
Binary file not shown.
Binary file modified cherrypy/_cpdispatch.pyc
Binary file not shown.
Binary file modified cherrypy/_cperror.pyc
Binary file not shown.
Binary file modified cherrypy/_cplogging.pyc
Binary file not shown.
Binary file modified cherrypy/_cpreqbody.pyc
Binary file not shown.
Binary file modified cherrypy/_cprequest.pyc
Binary file not shown.
Binary file modified cherrypy/_cpserver.pyc
Binary file not shown.
Binary file modified cherrypy/_cptools.pyc
Binary file not shown.
Binary file modified cherrypy/_cptree.pyc
Binary file not shown.
Binary file modified cherrypy/_cpwsgi.pyc
Binary file not shown.
Binary file modified cherrypy/_cpwsgi_server.pyc
Binary file not shown.
Binary file modified cherrypy/lib/__init__.pyc
Binary file not shown.
Binary file modified cherrypy/lib/auth.pyc
Binary file not shown.
Binary file modified cherrypy/lib/auth_basic.pyc
Binary file not shown.
Binary file modified cherrypy/lib/auth_digest.pyc
Binary file not shown.
Binary file modified cherrypy/lib/caching.pyc
Binary file not shown.
Binary file modified cherrypy/lib/cptools.pyc
Binary file not shown.
Binary file modified cherrypy/lib/encoding.pyc
Binary file not shown.
Binary file modified cherrypy/lib/httpauth.pyc
Binary file not shown.
Binary file modified cherrypy/lib/httputil.pyc
Binary file not shown.
Binary file modified cherrypy/lib/jsontools.pyc
Binary file not shown.
Binary file modified cherrypy/lib/reprconf.pyc
Binary file not shown.
Binary file modified cherrypy/lib/sessions.pyc
Binary file not shown.
Binary file modified cherrypy/lib/static.pyc
Binary file not shown.
Binary file modified cherrypy/lib/xmlrpcutil.pyc
Binary file not shown.
Binary file modified cherrypy/process/__init__.pyc
Binary file not shown.
Binary file modified cherrypy/process/plugins.pyc
Binary file not shown.
Binary file modified cherrypy/process/servers.pyc
Binary file not shown.
Binary file modified cherrypy/process/win32.pyc
Binary file not shown.
Binary file modified cherrypy/process/wspbus.pyc
Binary file not shown.
Binary file modified cherrypy/wsgiserver/__init__.pyc
Binary file not shown.
Binary file modified cherrypy/wsgiserver/wsgiserver2.pyc
Binary file not shown.
4 changes: 4 additions & 0 deletions lib/ConfigFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ def CheckConfigForAllKeys(app_path):
if(config.has_option('Scheduler','download_interval') == False):
config.set('Scheduler','download_interval','60')
changesMade = True

if(config.has_option('Scheduler','game_list_update_interval') == False):
config.set('Scheduler','game_list_update_interval','86400')
changesMade = True

if(config.has_option('SystemGenerated','is_to_ignore_update') == False):
config.set('SystemGenerated','is_to_ignore_update','0')
Expand Down
Binary file modified lib/ConfigFunctions.pyc
Binary file not shown.
2 changes: 1 addition & 1 deletion lib/Constants.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
def VersionNumber():
return "1.1.6.0"
return "1.1.7.0"
Binary file modified lib/Constants.pyc
Binary file not shown.
Binary file modified lib/DBFunctions.pyc
Binary file not shown.
Binary file modified lib/GameTasks.pyc
Binary file not shown.
Binary file modified lib/Logger.pyc
Binary file not shown.
Binary file modified lib/Notifications.pyc
Binary file not shown.
Binary file modified lib/UpgradeFunctions.pyc
Binary file not shown.
8 changes: 6 additions & 2 deletions lib/WebRoot.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,9 @@ def settings(self):
<label>Download Interval (In Seconds)</label>
<input type="text" name="downloadInterval" id="downloadInterval" value='""" + config.get('Scheduler','download_interval').replace('"','') + """' />
<label>Game List Update Interval (In Seconds)</label>
<input type="text" name="gameListUpdateInterval" id="gameListUpdateInterval" value='""" + config.get('Scheduler','game_list_update_interval').replace('"','') + """' />
<label>Gamez API Key</label>
<input type="text" name="gamezApiKey" id="gamezApiKey" value='""" + config.get('SystemGenerated','api_key').replace('"','') + """' />
Expand Down Expand Up @@ -548,7 +551,7 @@ def upgradetolatestversion(self,verification):
raise cherrypy.InternalRedirect("/?status_message=" + status)

@cherrypy.expose
def savesettings(self,cherrypyHost='', nzbMatrixUsername='', downloadInterval=3600, sabPort='', nzbMatrixApi='', sabApi='', cherrypyPort='', sabHost='',gamezApiKey='',newznabHost='',newznabPort='',newznabApi='',newznabWiiCat='',newznabXbox360Cat='',prowlApi='',gamezUsername='',gamezPassword=''):
def savesettings(self,cherrypyHost='', nzbMatrixUsername='', downloadInterval=3600, sabPort='', nzbMatrixApi='', sabApi='', cherrypyPort='', sabHost='',gamezApiKey='',newznabHost='',newznabPort='',newznabApi='',newznabWiiCat='',newznabXbox360Cat='',prowlApi='',gamezUsername='',gamezPassword='',gameListUpdateInterval=''):
cherrypyHost = '"' + cherrypyHost + '"'
nzbMatrixUsername = '"' + nzbMatrixUsername + '"'
nzbMatrixApi = '"' + nzbMatrixApi + '"'
Expand All @@ -575,6 +578,7 @@ def savesettings(self,cherrypyHost='', nzbMatrixUsername='', downloadInterval=36
config.set('Sabnzbd','port',sabPort)
config.set('Sabnzbd','api_key',sabApi)
config.set('Scheduler','download_interval',downloadInterval)
config.set('Scheduler','game_list_update_interval',gameListUpdateInterval)
config.set('SystemGenerated','api_key',gamezApiKey)
config.set('Newznab','host',newznabHost)
config.set('Newznab','port',newznabPort)
Expand Down Expand Up @@ -624,4 +628,4 @@ def updategamelist(self):
AddWiiGamesIfMissing()
AddXbox360GamesIfMissing()
status = "Game list has been updated successfully"
raise cherrypy.InternalRedirect("/?status_message=" + status)
raise cherrypy.InternalRedirect("/?status_message=" + status)
Binary file modified lib/WebRoot.pyc
Binary file not shown.
Binary file modified lib/__init__.pyc
Binary file not shown.
Binary file modified prowlpy/__init__.pyc
Binary file not shown.
Binary file modified prowlpy/prowlpy.pyc
Binary file not shown.

0 comments on commit 5456be9

Please sign in to comment.