witten
/
luminotes
Archived
1
0
Fork 0

Automatically change to directory where executable / main script is located.

This commit is contained in:
Dan Helfman 2008-08-21 17:44:39 -07:00
parent af145cd79c
commit f092abee11
1 changed files with 15 additions and 0 deletions

View File

@ -2,6 +2,7 @@
import sys
import socket
import os.path
import urllib2 as urllib
import cherrypy
import webbrowser
@ -14,6 +15,18 @@ INITIAL_SOCKET_TIMEOUT_SECONDS = 1
SOCKET_TIMEOUT_SECONDS = 60
def change_to_main_dir():
"""
Change to the directory where the executable / main script is located.
"""
if hasattr( sys, "frozen" ):
path = os.path.dirname( unicode( sys.executable, sys.getfilesystemencoding() ) )
else:
path = os.path.dirname( unicode( __file__, sys.getfilesystemencoding() ) )
os.chdir( path )
def main( args ):
cherrypy.config.update( Common.settings )
@ -52,6 +65,8 @@ def main( args ):
socket.setdefaulttimeout( SOCKET_TIMEOUT_SECONDS )
change_to_main_dir()
database = Database(
host = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_host" ),
ssl_mode = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_ssl_mode" ),