Commit d254ec96 authored by Dan Pascu's avatar Dan Pascu

Simplified code

parent 856b5c21
...@@ -3,10 +3,11 @@ ...@@ -3,10 +3,11 @@
import os import os
import sys import sys
frozen = hasattr(sys, 'frozen')
# We need to mangle Python's import path in case blink is run directly from # We need to mangle Python's import path in case blink is run directly from
# the bin/ directory. # the bin/ directory.
script = globals().get('__file__', sys.argv[0]) script_dir = os.path.dirname(os.path.realpath(sys.executable if frozen else __file__))
script_dir = os.path.dirname(os.path.realpath(script))
parent_dir = os.path.dirname(script_dir) parent_dir = os.path.dirname(script_dir)
if os.path.basename(script_dir) == 'bin' and os.path.exists(os.path.join(parent_dir, 'blink', '__init__.py')): if os.path.basename(script_dir) == 'bin' and os.path.exists(os.path.join(parent_dir, 'blink', '__init__.py')):
# Insert the parent path just before the existing script's path. We need # Insert the parent path just before the existing script's path. We need
...@@ -20,7 +21,7 @@ if os.path.basename(script_dir) == 'bin' and os.path.exists(os.path.join(parent_ ...@@ -20,7 +21,7 @@ if os.path.basename(script_dir) == 'bin' and os.path.exists(os.path.join(parent_
sys.path.insert(position, parent_dir) sys.path.insert(position, parent_dir)
if getattr(sys, 'frozen', False): if frozen:
from StringIO import StringIO from StringIO import StringIO
sys.stdout = sys.stderr = StringIO() sys.stdout = sys.stderr = StringIO()
......
...@@ -58,7 +58,7 @@ from blink.update import UpdateManager ...@@ -58,7 +58,7 @@ from blink.update import UpdateManager
from blink.util import QSingleton, run_in_gui_thread from blink.util import QSingleton, run_in_gui_thread
if getattr(sys, 'frozen', False): if hasattr(sys, 'frozen'):
output = sys.stdout output = sys.stdout
makedirs(ApplicationData.get('logs')) makedirs(ApplicationData.get('logs'))
sys.stdout = sys.stderr = open(ApplicationData.get('logs/output.log'), 'a') sys.stdout = sys.stderr = open(ApplicationData.get('logs/output.log'), 'a')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment