about summary refs log tree commit diff
path: root/kcc.py
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2014-12-30 11:00:21 +0100
committerPaweł Jastrzębski <pawelj@iosphe.re>2014-12-30 11:00:21 +0100
commit36f8c82eaf2a539bb4571bf97309f9a30a4f0926 (patch)
treee41b8f4f7b3635be3deb55f5dea96ecae441f99e /kcc.py
parentMerge pull request #119 from ciromattia/4.x (diff)
downloadkcc-36f8c82eaf2a539bb4571bf97309f9a30a4f0926.tar.gz
kcc-36f8c82eaf2a539bb4571bf97309f9a30a4f0926.tar.bz2
kcc-36f8c82eaf2a539bb4571bf97309f9a30a4f0926.zip
Fixed OSX race condition
Diffstat (limited to 'kcc.py')
-rwxr-xr-xkcc.py42
1 files changed, 21 insertions, 21 deletions
diff --git a/kcc.py b/kcc.py
index 296714a..0c963d3 100755
--- a/kcc.py
+++ b/kcc.py
@@ -24,10 +24,31 @@ __copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jas
 __docformat__ = 'restructuredtext en'
 
 import sys
+import os
 if sys.version_info[0] != 3:
     print('ERROR: This is Python 3 script!')
     exit(1)
 
+# OS specific PATH variable workarounds
+if sys.platform.startswith('darwin') and 'RESOURCEPATH' not in os.environ:
+    os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/:' + os.environ['PATH']
+elif sys.platform.startswith('win'):
+    if getattr(sys, 'frozen', False):
+        os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
+
+        # Implementing dummy stdout and stderr for frozen Windows release
+        class FakeSTD(object):
+            def write(self, string):
+                pass
+
+            def flush(self):
+                pass
+        sys.stdout = FakeSTD()
+        sys.stderr = FakeSTD()
+    else:
+        os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/;' + os.environ['PATH']
+        os.chdir(os.path.dirname(os.path.abspath(__file__)))
+
 # Dependency check
 missing = []
 try:
@@ -69,30 +90,9 @@ if len(missing) > 0:
         print('ERROR: ' + ', '.join(missing) + ' is not installed!')
     exit(1)
 
-import os
 from multiprocessing import freeze_support
 from kcc import KCC_gui
 
-# OS specific PATH variable workarounds
-if sys.platform.startswith('darwin') and 'RESOURCEPATH' not in os.environ:
-    os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/:' + os.environ['PATH']
-elif sys.platform.startswith('win'):
-    if getattr(sys, 'frozen', False):
-        os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
-
-        # Implementing dummy stdout and stderr for frozen Windows release
-        class FakeSTD(object):
-            def write(self, string):
-                pass
-
-            def flush(self):
-                pass
-        sys.stdout = FakeSTD()
-        sys.stderr = FakeSTD()
-    else:
-        os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/;' + os.environ['PATH']
-        os.chdir(os.path.dirname(os.path.abspath(__file__)))
-
 
 # Implementing detection of already running KCC instance and forwarding argv to it
 class QApplicationMessaging(QtWidgets.QApplication):