diff --git a/Gamez.db b/Gamez.db index b4e8a28..24c5d11 100644 Binary files a/Gamez.db and b/Gamez.db differ diff --git a/Gamez.ini b/Gamez.ini index d2344da..cba5c10 100644 --- a/Gamez.ini +++ b/Gamez.ini @@ -1,20 +1,22 @@ [global] server.socket_host = "127.0.0.1" server.socket_port = 8085 +user_name = "" +password = "" [NZBMatrix] -username = -api_key = +username = "" +api_key = "" [Newznab] -api_key = +api_key = "" wii_category_id = "1030" xbox360_category_id = "1050" -host = +host = "" port = [Sabnzbd] -api_key = +api_key = "" host = "127.0.0.1" port = 8081 diff --git a/Gamez.py b/Gamez.py index aeb28f3..6fa7388 100644 --- a/Gamez.py +++ b/Gamez.py @@ -15,6 +15,7 @@ from lib.ConfigFunctions import CheckConfigForAllKeys from lib.DBFunctions import ValidateDB from lib.Logger import LogEvent +import cherrypy.lib.auth_basic app_path = os.path.dirname(os.path.abspath("__FILE__")) config_path = os.path.join(app_path,'Gamez.ini') @@ -30,13 +31,23 @@ def RunWebServer(self,isToDaemonize): js_path = os.path.join(app_path,'js') theme_path = os.path.join(css_path,'redmond') theme_images_path = os.path.join(theme_path,'images') + config = ConfigParser.RawConfigParser() + config.read('Gamez.ini') + username = config.get('global','user_name').replace('"','') + password = config.get('global','password').replace('"','') + useAuth = False + if(username <> "" or password <> ""): + useAuth = True + userPassDict = {username:password} + checkpassword = cherrypy.lib.auth_basic.checkpassword_dict(userPassDict) conf = { + '/':{'tools.auth_basic.on':useAuth,'tools.auth_basic.realm':'Gamez','tools.auth_basic.checkpassword':checkpassword}, '/css': {'tools.staticdir.on':True,'tools.staticdir.dir':css_path}, '/js':{'tools.staticdir.on':True,'tools.staticdir.dir':js_path}, '/css/redmond':{'tools.staticdir.on':True,'tools.staticdir.dir':theme_path}, '/css/redmond/images':{'tools.staticdir.on':True,'tools.staticdir.dir':theme_images_path}, '/css/navigation_images':{'tools.staticdir.on':True,'tools.staticdir.dir':navigation_images_path}, - '/css/datatables_images':{'tools.staticdir.on':True,'tools.staticdir.dir':datatables_images_path} + '/css/datatables_images':{'tools.staticdir.on':True,'tools.staticdir.dir':datatables_images_path}, } daemon = Daemonizer(cherrypy.engine) diff --git a/lib/ConfigFunctions.py b/lib/ConfigFunctions.py index 5ec218f..da6041b 100644 --- a/lib/ConfigFunctions.py +++ b/lib/ConfigFunctions.py @@ -46,6 +46,14 @@ def CheckConfigForAllKeys(app_path): config.set('global','server.socket_port','8085') changesMade = True + if(config.has_option('global','user_name') == False): + config.set('global','user_name','""') + changesMade = True + + if(config.has_option('global','password') == False): + config.set('global','password','""') + changesMade = True + if(config.has_option('NZBMatrix','username') == False): config.set('NZBMatrix','username','""') changesMade = True diff --git a/lib/ConfigFunctions.pyc b/lib/ConfigFunctions.pyc index bf8001b..408b275 100644 Binary files a/lib/ConfigFunctions.pyc and b/lib/ConfigFunctions.pyc differ diff --git a/lib/Constants.py b/lib/Constants.py index b6a1844..a9012b1 100644 --- a/lib/Constants.py +++ b/lib/Constants.py @@ -1,2 +1,2 @@ def VersionNumber(): - return "1.1.4.0" + return "1.1.5.0" diff --git a/lib/Constants.pyc b/lib/Constants.pyc index be227ec..ac16170 100644 Binary files a/lib/Constants.pyc and b/lib/Constants.pyc differ diff --git a/lib/DBFunctions.py b/lib/DBFunctions.py index ae54e2b..86b7688 100644 --- a/lib/DBFunctions.py +++ b/lib/DBFunctions.py @@ -5,6 +5,7 @@ from Logger import LogEvent import urllib import json +import Notifications def GetGamesFromTerm(term): db_path = os.path.join(os.path.abspath(""),"Gamez.db") @@ -121,17 +122,29 @@ def GetRequestedGamesAsArray(): cursor.close() return result -def UpdateStatus(game_id,status): +def UpdateStatus(game_id,status,appPath): LogEvent("Update status of game to " + status) db_path = os.path.join(os.path.abspath(""),"Gamez.db") - sql = "update requested_games set status='" + status + "' where ID='" + game_id + "'" + game_name = "" + system = "" + sql = "select game_name,system from requested_games where ID='" + game_id + "'" + connection = sqlite3.connect(db_path) + cursor = connection.cursor() + cursor.execute(sql) + result = cursor.fetchall() + tables = list() + for record in result: + game_name = str(record[0]) + system = str(record[1]) + cursor.close() + sql = "update requested_games set status='" + status + "' where game_name = '" + game_name + "' and system = '" + system + "'" connection = sqlite3.connect(db_path) cursor = connection.cursor() cursor.execute(sql) connection.commit() cursor.close() - - Notifications.HandleNotifications(game_id,status) + message = "Gamez Notification: " + system + " Game: " + game_name + " has been " + status + Notifications.HandleNotifications(status,message,appPath) return def ValidateDB(): diff --git a/lib/DBFunctions.pyc b/lib/DBFunctions.pyc index 1e4ffa0..d7423b5 100644 Binary files a/lib/DBFunctions.pyc and b/lib/DBFunctions.pyc differ diff --git a/lib/Notifications.py b/lib/Notifications.py index e53db6b..814ed00 100644 --- a/lib/Notifications.py +++ b/lib/Notifications.py @@ -1,9 +1,22 @@ -import DBFunctions +import ConfigParser +import os +import prowlpy +from Logger import LogEvent -def LogEvent(message): - DBFunctions.AddEventToDB(message) - return - -def ClearLog(): - ClearDBLog() +def HandleNotifications(status,message,appPath): + config = ConfigParser.RawConfigParser() + configFilePath = os.path.join(appPath,'Gamez.ini') + config.read(configFilePath) + prowlApi = config.get('Notifications','prowl_api').replace('"','') + if(prowlApi <> ""): + SendNotificationToProwl(status,message,prowlApi) + return + +def SendNotificationToProwl(status,message,prowlApi): + prowl = prowlpy.Prowl(prowlApi) + try: + prowl.add('Gamez',status,message,1,None,"http://www.prowlapp.com/") + LogEvent("Prowl Notification Sent") + except Exception,msg: + LogEvent("Prowl Notification Error: " + msg) return \ No newline at end of file diff --git a/lib/Notifications.pyc b/lib/Notifications.pyc new file mode 100644 index 0000000..94b660b Binary files /dev/null and b/lib/Notifications.pyc differ diff --git a/lib/WebRoot.py b/lib/WebRoot.py index e00cdbc..136c99a 100644 --- a/lib/WebRoot.py +++ b/lib/WebRoot.py @@ -311,6 +311,12 @@ def settings(self): + + + + + + @@ -482,7 +488,7 @@ def updatestatus(self,game_id='',status=''): if(os.name <> 'nt'): os.chdir(WebRoot.appPath) if(status <> ''): - UpdateStatus(game_id,status) + UpdateStatus(game_id,status,WebRoot.appPath) raise cherrypy.InternalRedirect('/') @cherrypy.expose @@ -518,7 +524,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=''): + def savesettings(self,cherrypyHost='', nzbMatrixUsername='', downloadInterval=3600, sabPort='', nzbMatrixApi='', sabApi='', cherrypyPort='', sabHost='',gamezApiKey='',newznabHost='',newznabPort='',newznabApi='',newznabWiiCat='',newznabXbox360Cat='',prowlApi='',gamezUsername='',gamezPassword=''): cherrypyHost = '"' + cherrypyHost + '"' nzbMatrixUsername = '"' + nzbMatrixUsername + '"' nzbMatrixApi = '"' + nzbMatrixApi + '"' @@ -530,11 +536,15 @@ def savesettings(self,cherrypyHost='', nzbMatrixUsername='', downloadInterval=36 newznabWiiCat = '"' + newznabWiiCat + '"' newznabXbox360Cat = '"' + newznabXbox360Cat + '"' prowlApi = '"' + prowlApi + '"' + gamezUsername = '"' + gamezUsername + '"' + gamezPassword = '"' + gamezPassword + '"' config = ConfigParser.RawConfigParser() configFilePath = os.path.join(WebRoot.appPath,'Gamez.ini') config.read(configFilePath) config.set('global','server.socket_host',cherrypyHost) config.set('global','server.socket_port',cherrypyPort) + config.set('global','user_name',gamezUsername) + config.set('global','password',gamezPassword) config.set('NZBMatrix','username',nzbMatrixUsername) config.set('NZBMatrix','api_key',nzbMatrixApi) config.set('Sabnzbd','host',sabHost) diff --git a/lib/WebRoot.pyc b/lib/WebRoot.pyc index 2fefea1..737d279 100644 Binary files a/lib/WebRoot.pyc and b/lib/WebRoot.pyc differ diff --git a/prowlpy/__init__.pyc b/prowlpy/__init__.pyc new file mode 100644 index 0000000..4aa8fb6 Binary files /dev/null and b/prowlpy/__init__.pyc differ diff --git a/prowlpy/prowlpy.pyc b/prowlpy/prowlpy.pyc new file mode 100644 index 0000000..1b9bc37 Binary files /dev/null and b/prowlpy/prowlpy.pyc differ