diff --git a/luminotes.py b/luminotes.py index 0e96f38..2af2c64 100755 --- a/luminotes.py +++ b/luminotes.py @@ -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" ),