Skip to content

Commit

Permalink
Added folder processing
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dlesk committed Jan 15, 2012
1 parent 670de66 commit 72ea74b
Show file tree
Hide file tree
Showing 113 changed files with 400 additions and 141 deletions.
8 changes: 6 additions & 2 deletions API.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,12 @@ Examples:

***GETREQUESTED***
<br />
To Be Added
<br /><br />
This mode returns a list of the games that have been requested. The result is in the same format as the SEARCH mode. No additional parameters are needed.

Examples:
<br />
&nbsp;&nbsp;&nbsp;Get Requested Games: http://127.0.0.1:8085/api?api_key=ikzFRzA1Y8I1UajNJAOQ803TbTYk1vLB64A9SxrAxAw&mode=GETREQUESTED
<br />
***ADDREQUESTED***
<br />
To Be Added
Expand Down
Binary file modified Gamez.db
Binary file not shown.
34 changes: 17 additions & 17 deletions Gamez.ini
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[global]
server.socket_host = "127.0.0.1"
server.socket_port = 8085
user_name =
password =
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
category =
category = ""

[Scheduler]
download_interval = 900
Expand Down Expand Up @@ -47,21 +47,21 @@ process_download_folder_xbox360_enabled = 0
nzb_completed = 0

[Notifications]
prowl_api =
growl_host =
prowl_api = ""
growl_host = ""
growl_port = 23053
growl_password =
notifo_username =
notifo_apikey =
growl_password = ""
notifo_username = ""
notifo_apikey = ""

[Blackhole]
nzb_blackhole_path =
torrent_blackhole_path =
nzb_blackhole_path = ""
torrent_blackhole_path = ""

[Folders]
torrent_completed = ""
nzb_completed = ""
sabnzbd_completed = ""
wii_destination =
xbox360_destination =
wii_destination = ""
xbox360_destination = "c:\\xbox360"

37 changes: 26 additions & 11 deletions Gamez.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from lib.DBFunctions import ValidateDB,AddWiiGamesIfMissing,AddXbox360GamesIfMissing,AddComingSoonGames
from lib.Logger import LogEvent
import cherrypy.lib.auth_basic
from lib.FolderFunctions import *

app_path = os.path.dirname(os.path.abspath("__FILE__"))
config_path = os.path.join(app_path,'Gamez.ini')
Expand All @@ -35,7 +36,7 @@ def RunWebServer(self,isToDaemonize):
theme_path = os.path.join(css_path,'redmond')
theme_images_path = os.path.join(theme_path,'images')
config = ConfigParser.RawConfigParser()
config.read('Gamez.ini')
config.read('Gamez.ini')
username = config.get('global','user_name').replace('"','')
password = config.get('global','password').replace('"','')
useAuth = False
Expand Down Expand Up @@ -70,16 +71,16 @@ def RunWebServer(self,isToDaemonize):
updateGameListInterval = config.get('Scheduler','game_list_update_interval').replace('"','')
fInterval = float(interval)
fUpdateGameListInterval = float(updateGameListInterval)
#thread.start_new_thread(ScheduleGameTasks,(fInterval,))
#workerTask = cherrypy.process.plugins.BackgroundTask(fInterval,RunGameTask)
#gameListUpdaterWorkTask = cherrypy.process.plugins.BackgroundTask(fUpdateGameListInterval,RunGameListUpdaterTask)
try:
LogEvent("Setting up download scheduler")
gameTasksScheduler = cherrypy.process.plugins.Monitor(cherrypy.engine,RunGameTask,fInterval)
gameTasksScheduler.subscribe()
LogEvent("Setting up game list update scheduler")
gameListUpdaterScheduler = cherrypy.process.plugins.Monitor(cherrypy.engine,RunGameListUpdaterTask,fUpdateGameListInterval)
gameListUpdaterScheduler.subscribe()
gameTasksScheduler.subscribe()
LogEvent("Setting up game list update scheduler")
gameListUpdaterScheduler = cherrypy.process.plugins.Monitor(cherrypy.engine,RunGameListUpdaterTask,fUpdateGameListInterval)
gameListUpdaterScheduler.subscribe()
LogEvent("Setting up folder processing scheduler")
folderProcessingScheduler = cherrypy.process.plugins.Monitor(cherrypy.engine,RunFolderProcessingTask,float(900))
folderProcessingScheduler.subscribe()
LogEvent("Starting the Gamez web server")
cherrypy.quickstart(WebRoot(app_path),'/',config=conf)
except KeyboardInterrupt:
Expand All @@ -103,6 +104,8 @@ def GenerateSabPostProcessScript():
file.write("\n")
file.write('import urllib')
file.write("\n")
file.write("filePath = str(sys.argv[1])")
file.write("\n")
file.write('fields = str(sys.argv[3]).split("-")')
file.write("\n")
file.write('gamezID = fields[0].replace("[","").replace("]","").replace(" ","")')
Expand All @@ -115,7 +118,7 @@ def GenerateSabPostProcessScript():
file.write("\n")
file.write(" downloadStatus = 'Downloaded'")
file.write("\n")
file.write('url = "' + gamezBaseUrl + 'updatestatus?game_id=" + gamezID + "&status=" + downloadStatus')
file.write('url = "' + gamezBaseUrl + 'updatestatus?game_id=" + gamezID + "&filePath=" + urllib.quote(filePath) + "&status=" + downloadStatus')
file.write("\n")
file.write('responseObject = urllib.FancyURLopener({}).open(url)')
file.write("\n")
Expand All @@ -125,6 +128,9 @@ def GenerateSabPostProcessScript():
file.write("\n")
file.write('print("Processing Completed Successfully")')
file.close
LogEvent("Setting permissions on post process script")
cmd = "chmod +x '" + postProcessScript + "'"
os.system(cmd)

def RunGameTask():
try:
Expand Down Expand Up @@ -172,10 +178,20 @@ def RunGameListUpdaterTask():
errorMessage = errorMessage + " - " + str(message)
LogEvent(errorMessage)

def RunFolderProcessingTask():
try:
ScanFoldersToProcess()
except:
errorMessage = "Error occurred while processing folders"
for message in sys.exc_info():
errorMessage = errorMessage + " - " + str(message)
LogEvent(errorMessage)

if __name__ == '__main__':
app_path = sys.path[0]
LogEvent("Checking DB")
ValidateDB()
LogEvent("Checking config file for completeness")
CheckConfigForAllKeys(app_path)
config = ConfigParser.RawConfigParser()
configFilePath = os.path.join(app_path,'Gamez.ini')
Expand All @@ -190,8 +206,7 @@ def RunGameListUpdaterTask():
config.set('Folders','sabnzbd_completed','"' + sabCompleted + '"')
LogEvent("Trying to save")
with open(configFilePath,'wb') as configFile:
config.write(configFile)
LogEvent("Checking config file for completeness")
config.write(configFile)
isToDaemonize = 0
params = sys.argv
for param in params:
Expand Down
26 changes: 26 additions & 0 deletions Gamez.pyproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{00000000-0000-0000-0000-000000000000}</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>
</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<Name>Gamez</Name>
<RootNamespace>Gamez</RootNamespace>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
<EnableUnmanagedDebugging>false</EnableUnmanagedDebugging>
</PropertyGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" />
</Project>
Binary file added Gamez.suo
Binary file not shown.
Binary file added _ReSharper.Gamez/BuildScriptCache/.crc
Binary file not shown.
Binary file added _ReSharper.Gamez/BuildScriptCache/.version
Binary file not shown.
1 change: 1 addition & 0 deletions _ReSharper.Gamez/JavaScriptCache/.crc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
��8
Binary file added _ReSharper.Gamez/JavaScriptCache/.version
Binary file not shown.
Binary file added _ReSharper.Gamez/JavaScriptCache/8/2767ed7e.dat
Binary file not shown.
Binary file added _ReSharper.Gamez/MVC/.crc
Binary file not shown.
Binary file added _ReSharper.Gamez/MVC/.version
Binary file not shown.
1 change: 1 addition & 0 deletions _ReSharper.Gamez/NamedArguments/.crc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
�L�
Binary file added _ReSharper.Gamez/NamedArguments/.version
Binary file not shown.
Binary file added _ReSharper.Gamez/NamedArguments/5/5706720e.dat
Binary file not shown.
Binary file added _ReSharper.Gamez/Resources/.crc
Binary file not shown.
Binary file added _ReSharper.Gamez/Resources/.version
Binary file not shown.
Binary file added _ReSharper.Gamez/SymbolCache.bin
Binary file not shown.
Binary file added _ReSharper.Gamez/TagPrefixes/.crc
Binary file not shown.
Binary file added _ReSharper.Gamez/TagPrefixes/.version
Binary file not shown.
1 change: 1 addition & 0 deletions _ReSharper.Gamez/TodoCache/.crc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7�P�
Binary file added _ReSharper.Gamez/TodoCache/.version
Binary file not shown.
Binary file added _ReSharper.Gamez/TodoCache/8/2767ed7e.dat
Binary file not shown.
Binary file added _ReSharper.Gamez/WebSymbols/.crc
Binary file not shown.
Binary file added _ReSharper.Gamez/WebSymbols/.version
Binary file not shown.
1 change: 1 addition & 0 deletions _ReSharper.Gamez/WordIndex/.crc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
I�E�
Binary file added _ReSharper.Gamez/WordIndex/.version
Binary file not shown.
Binary file added _ReSharper.Gamez/WordIndex/5/5706720e.dat
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added _ReSharper.Gamez/XmlIndex/System.xml/D647FF29.bin
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
78 changes: 39 additions & 39 deletions lib/ConfigFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,57 +188,57 @@ def CheckConfigForAllKeys(app_path):
changesMade = True

if(config.has_option('Notifications','prowl_api') == False):
config.set('Notifications','prowl_api','""')
changesMade = True
config.set('Notifications','prowl_api','""')
changesMade = True

if(config.has_option('Notifications','growl_host') == False):
config.set('Notifications','growl_host','""')
changesMade = True
config.set('Notifications','growl_host','""')
changesMade = True

if(config.has_option('Notifications','growl_port') == False):
config.set('Notifications','growl_port','23053')
changesMade = True
config.set('Notifications','growl_port','23053')
changesMade = True

if(config.has_option('Notifications','growl_password') == False):
config.set('Notifications','growl_password','""')
changesMade = True
config.set('Notifications','growl_password','""')
changesMade = True

if(config.has_option('Notifications','notifo_username') == False):
config.set('Notifications','notifo_username','""')
changesMade = True
config.set('Notifications','notifo_username','""')
changesMade = True

if(config.has_option('Notifications','notifo_apikey') == False):
config.set('Notifications','notifo_apikey','""')
changesMade = True
config.set('Notifications','notifo_apikey','""')
changesMade = True

if(config.has_option('Blackhole','nzb_blackhole_path') == False):
config.set('Blackhole','nzb_blackhole_path','""')
changesMade = True
config.set('Blackhole','nzb_blackhole_path','""')
changesMade = True

if(config.has_option('Blackhole','torrent_blackhole_path') == False):
config.set('Blackhole','torrent_blackhole_path','""')
changesMade = True
if(config.has_option('Folders','torrent_blackhole_path') == False):
config.set('Folders','torrent_completed','""')
changesMade = True
if(config.has_option('Folders','torrent_blackhole_path') == False):
config.set('Folders','nzb_completed','""')
changesMade = True
if(config.has_option('Folders','torrent_blackhole_path') == False):
config.set('Folders','sabnzbd_completed','""')
changesMade = True
config.set('Blackhole','torrent_blackhole_path','""')
changesMade = True

if(config.has_option('Folders','torrent_completed') == False):
config.set('Folders','torrent_completed','""')
changesMade = True

if(config.has_option('Folders','nzb_completed') == False):
config.set('Folders','nzb_completed','""')
changesMade = True

if(config.has_option('Folders','sabnzbd_completed') == False):
config.set('Folders','sabnzbd_completed','""')
changesMade = True

if(config.has_option('Folders','wii_destination') == False):
config.set('Folders','wii_destination','""')
changesMade = True
config.set('Folders','wii_destination','""')
changesMade = True

if(config.has_option('Folders','xbox360_destination') == False):
config.set('Folders','xbox360_destination','""')
changesMade = True
config.set('Folders','xbox360_destination','""')
changesMade = True

if(changesMade):
with open(configFilePath,'wb') as configFile:
config.write(configFile)
Binary file modified lib/ConfigFunctions.pyc
Binary file not shown.
Loading

0 comments on commit 72ea74b

Please sign in to comment.