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 sys
|
||||||
import socket
|
import socket
|
||||||
|
import os.path
|
||||||
import urllib2 as urllib
|
import urllib2 as urllib
|
||||||
import cherrypy
|
import cherrypy
|
||||||
import webbrowser
|
import webbrowser
|
||||||
|
@ -14,6 +15,18 @@ INITIAL_SOCKET_TIMEOUT_SECONDS = 1
|
||||||
SOCKET_TIMEOUT_SECONDS = 60
|
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 ):
|
def main( args ):
|
||||||
cherrypy.config.update( Common.settings )
|
cherrypy.config.update( Common.settings )
|
||||||
|
|
||||||
|
@ -52,6 +65,8 @@ def main( args ):
|
||||||
|
|
||||||
socket.setdefaulttimeout( SOCKET_TIMEOUT_SECONDS )
|
socket.setdefaulttimeout( SOCKET_TIMEOUT_SECONDS )
|
||||||
|
|
||||||
|
change_to_main_dir()
|
||||||
|
|
||||||
database = Database(
|
database = Database(
|
||||||
host = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_host" ),
|
host = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_host" ),
|
||||||
ssl_mode = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_ssl_mode" ),
|
ssl_mode = cherrypy.config.configMap[ u"global" ].get( u"luminotes.db_ssl_mode" ),
|
||||||
|
|
Reference in New Issue