Skip to content

Commit

Permalink
Fixed issues when launching from different folder using abs path
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Dlesk committed Dec 25, 2011
1 parent 2f3c218 commit 16cbb7f
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
Binary file added Gamez.Python.VS2010.suo
Binary file not shown.
7 changes: 4 additions & 3 deletions Gamez.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def RunWebServer(self,isToDaemonize):

def GenerateSabPostProcessScript():
config = ConfigParser.RawConfigParser()
config.read('Gamez.ini')
print(os.path.join(app_path,'Gamez.ini'))
config.read(os.path.join(app_path,'Gamez.ini'))
gamezWebHost = config.get('global','server.socket_host').replace('"','')
gamezWebport = config.get('global','server.socket_port').replace('"','')
gamezBaseUrl = "http://" + gamezWebHost + ":" + gamezWebport + "/"
Expand Down Expand Up @@ -119,10 +120,10 @@ def RunGameTask():
print(sys.exc_info()[0])

if __name__ == '__main__':
app_path = sys.path[0]
ValidateDB()
LogEvent("Checking config file for completeness")
CheckConfigForAllKeys(app_path)
LogEvent("Checking to make sure all tables exist in the database")
ValidateDB()
isToDaemonize = 0
params = sys.argv
for param in params:
Expand Down
4 changes: 4 additions & 0 deletions lib/ConfigFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ def CheckConfigForAllKeys(app_path):
config.set('Sabnzbd','host','"127.0.0.1"')
changesMade = True

if(config.has_option('Sabnzbd','port') == False):
config.set('Sabnzbd','port','')
changesMade = True

if(config.has_option('Scheduler','download_interval') == False):
config.set('Scheduler','download_interval','60')
changesMade = True
Expand Down
2 changes: 0 additions & 2 deletions lib/DBFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ def UpdateStatus(game_id,status):
return

def ValidateDB():
LogEvent("Checking to make sure database has the correct tables")
db_path = os.path.join(os.path.abspath(""),"Gamez.db")
sql = "select name from sqlite_master where type='table'"
logTableExists = False
Expand All @@ -182,7 +181,6 @@ def ValidateDB():
logTableExists = True
cursor.close()
if(logTableExists == False):
LogEvent("Creating table 'gamez_log'")
sql = "create table gamez_log(ID INTEGER NOT NULL PRIMARY KEY UNIQUE,message TEXT(255) NOT NULL,created_date DATE)"
connection = sqlite3.connect(db_path)
cursor = connection.cursor()
Expand Down

0 comments on commit 16cbb7f

Please sign in to comment.