changeset 1697:5c04a54df635

fix startup (this might be breaking mypy) Ignore-this: d81817852cde18bb475ce7be80499b5d
author Drew Perttula <drewp@bigasterisk.com>
date Thu, 26 Apr 2018 08:20:19 +0000
parents d9337dfe941a
children f140153c087c
files bin/collector bin/run_local.py bin/subcomposer
diffstat 3 files changed, 51 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/bin/collector	Thu Apr 26 06:43:31 2018 +0000
+++ b/bin/collector	Thu Apr 26 08:20:19 2018 +0000
@@ -8,6 +8,8 @@
 """
 
 from __future__ import division
+from run_local import log
+
 from rdflib import URIRef, Literal
 from twisted.internet import reactor, utils
 from txzmq import ZmqEndpoint, ZmqFactory, ZmqPullConnection
@@ -19,7 +21,6 @@
 import cyclone.web, cyclone.websocket
 from greplin import scales
 
-from run_local import log
 from lib.cycloneerr import PrettyErrorHandler
 from light9.collector.output import EnttecDmx, Udmx, DummyOutput
 from light9.collector.collector import Collector
--- a/bin/run_local.py	Thu Apr 26 06:43:31 2018 +0000
+++ b/bin/run_local.py	Thu Apr 26 08:20:19 2018 +0000
@@ -3,7 +3,50 @@
 # this should be turned off when the programs are installed
 
 import sys, os, socket
-sys.path.insert(0,os.path.join(os.path.dirname(sys.argv[0]),".."))
+
+def fixSysPath():
+    root = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]), '..')) + '/'
+
+    # this is site-packages/zope.interface-4.5.0-py2.7-nspkg.pth,
+    # slightly edited.
+    import types
+    has_mfs = sys.version_info > (3, 5);
+    p = root + 'env/local/lib/python2.7/site-packages/zope'
+    importlib = has_mfs and __import__('importlib.util');
+    has_mfs and __import__('importlib.machinery');
+    m = has_mfs and sys.modules.setdefault(
+        'zope', importlib.util.module_from_spec(
+            importlib.machinery.PathFinder.find_spec(
+                'zope', [os.path.dirname(p)])));
+    m = m or sys.modules.setdefault('zope', types.ModuleType('zope'));
+    mp = (m or []) and m.__dict__.setdefault('__path__',[]);
+    (p not in mp) and mp.append(p)
+    
+    p = root + 'env/local/lib/python2.7/site-packages/greplin'
+    importlib = has_mfs and __import__('importlib.util');
+    has_mfs and __import__('importlib.machinery');
+    m = has_mfs and sys.modules.setdefault('greplin', importlib.util.module_from_spec(importlib.machinery.PathFinder.find_spec('greplin', [os.path.dirname(p)])));
+    m = m or sys.modules.setdefault('greplin', types.ModuleType('greplin'));
+    mp = (m or []) and m.__dict__.setdefault('__path__',[]);
+    (p not in mp) and mp.append(p)
+
+    sys.path = [
+        root,
+        root + 'env/lib/python2.7',
+        root + 'env/lib/python2.7/plat-x86_64-linux-gnu',
+        root + 'env/lib/python2.7/lib-tk',
+        root + 'env/lib/python2.7/lib-old',
+        root + 'env/lib/python2.7/lib-dynload',
+        '/usr/lib/python2.7',
+        '/usr/lib/python2.7/plat-x86_64-linux-gnu',
+        '/usr/lib/python2.7/lib-tk',
+        root + 'env/local/lib/python2.7/site-packages',
+        root + 'env/local/lib/python2.7/site-packages/gtk-2.0',
+        root + 'env/lib/python2.7/site-packages',
+        root + 'env/lib/python2.7/site-packages/gtk-2.0',
+    ]
+
+fixSysPath()
 
 from twisted.python.failure import Failure
 
--- a/bin/subcomposer	Thu Apr 26 06:43:31 2018 +0000
+++ b/bin/subcomposer	Thu Apr 26 08:20:19 2018 +0000
@@ -16,7 +16,12 @@
 
 """
 from __future__ import division, nested_scopes
+
+from run_local import log
 import time, logging
+
+log.setLevel(logging.DEBUG)
+
 from optparse import OptionParser
 import logging, urllib
 import Tkinter as tk
@@ -24,12 +29,8 @@
 from twisted.internet import reactor, tksupport, task
 from rdflib import URIRef, RDF, RDFS, Literal
 
-from run_local import log
-log.setLevel(logging.DEBUG)
-
 from light9.dmxchanedit import Levelbox
 from light9 import dmxclient, Submaster, prof, showconfig, networking
-
 from light9.Patch import get_channel_name
 from light9.uihelpers import toplevelat
 from rdfdb.syncedgraph import SyncedGraph