Automatically change to directory where executable / main script is located.
This commit is contained in:
parent
af145cd79c
commit
f092abee11
15
luminotes.py
15
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" ),
|
||||
|
|
Reference in New Issue