Permalink
Browse files

adding option for config path and mods

  • Loading branch information...
adammhaile committed Sep 14, 2016
1 parent 01d95ef commit 8cd295dcbbc179bde2e3b1903bd918f891edfc59
Showing with 41 additions and 18 deletions.
  1. +4 −4 pixelweb/bpmanager.py
  2. +11 −2 pixelweb/config.py
  3. +10 −2 pixelweb/pixelweb.py
  4. +5 −1 run-pixelweb
  5. +11 −9 setup.py
View
@@ -57,7 +57,7 @@ def __genModObj(self, config):
for p in config.presets:
p.id = config.id
- c = {
+ c = {
"display":config.display,
"desc":config.desc,
"params":config.params,
@@ -142,8 +142,8 @@ def loadBaseMods(self):
def loadMods(self):
mod_dirs = globals._server_config.mod_dirs
- for dir in (mod_dirs + globals._bpa_dirs):
- self.loadModules(loader.load_folder(dir))
+ for d in (mod_dirs + globals._bpa_dirs):
+ self.loadModules(loader.load_folder(d))
def __getInstance(self, config, inst_type):
config = d(config)
@@ -299,7 +299,7 @@ def getAnim(c):
max_steps = r.max_steps,
untilComplete = r.untilComplete,
max_cycles = r.max_cycles,
- seconds = r.seconds)
+ seconds = r.seconds)
status.pushStatus("Starting Animation Queue")
self.anim.run(**(run))
return success()
View
@@ -53,6 +53,10 @@
},]
});
+def setHome(home):
+ global __home
+ __home = home
+
def genDefaultConfig(params):
c = {}
for p in params:
@@ -64,13 +68,16 @@ def genDefaultConfig(params):
def initConfig():
try:
+ print __home
if not os.path.exists(__home):
print "Creating {}".format(__home)
os.makedirs(__home)
except:
print "Failed to initialize PixelWeb config!"
-def readConfig(file, key = None, path=__home):
+def readConfig(file, key = None, path=None):
+ if not path:
+ path = __home
data = {}
try:
with open(path + "/" + file + ".json", "r") as fp:
@@ -85,7 +92,9 @@ def readConfig(file, key = None, path=__home):
return d(data)
-def writeConfig(file, data, key = None, path=__home):
+def writeConfig(file, data, key = None, path=None):
+ if not path:
+ path = __home
base = data
if key:
base = readConfig(file, path=path)
View
@@ -102,6 +102,7 @@ def startup():
bpa_path = os.path.dirname(os.path.abspath(BiblioPixelAnimations.__file__)).replace("\\", "/")
bpa_matrix = bpa_path + "/matrix/"
bpa_strip = bpa_path + "/strip/"
+ bpa_recv = bpa_path + "/receivers/"
status.pushStatus("Starting PixelWeb Server")
config.initConfig()
@@ -111,15 +112,22 @@ def startup():
# if(bpa_matrix not in cfg.mod_dirs): cfg.mod_dirs.append(bpa_matrix)
# if(bpa_strip not in cfg.mod_dirs): cfg.mod_dirs.append(bpa_strip)
- globals._bpa_dirs = [bpa_matrix, bpa_strip]
+ globals._bpa_dirs = [bpa_matrix, bpa_strip, bpa_recv]
level = log.INFO
if cfg.show_debug: level = log.DEBUG
log.setLogLevel(level)
+ mod_dir = os.path.join(config.__home, 'mods')
+ if os.path.isdir(mod_dir):
+ globals._bpa_dirs.append(mod_dir)
+ print globals._bpa_dirs
+
initBPM()
-def startServer():
+def startServer(home_dir=None):
+ if home_dir:
+ config.setHome(home_dir)
while globals._running:
try:
startup()
View
@@ -1,4 +1,8 @@
#! /usr/bin/env python
+import sys
from pixelweb.pixelweb import startServer
-startServer()
+home = None
+if len(sys.argv) > 1:
+ home = sys.argv[1]
+startServer(home)
View
@@ -1,13 +1,14 @@
from __future__ import with_statement
-import os, sys
+import os
+import sys
from os.path import join as pjoin, splitext, split as psplit
from distutils.core import setup
from distutils.command.install_scripts import install_scripts
from distutils.command.install import install as _install
from distutils import log
BAT_TEMPLATE = \
-r"""@echo off
+ r"""@echo off
REM wrapper to use shebang first line of {FNAME}
set mypath=%~dp0
set pyscript="%mypath%{FNAME}"
@@ -22,6 +23,7 @@
class do_install_scripts(install_scripts):
+
def run(self):
install_scripts.run(self)
if not os.name == "nt":
@@ -34,7 +36,7 @@ def run(self):
if not (first_line.startswith('#!') and
'python' in first_line.lower()):
log.info("No #!python executable found, skipping .bat "
- "wrapper")
+ "wrapper")
continue
pth, fname = psplit(filepath)
froot, ext = splitext(fname)
@@ -49,7 +51,7 @@ def run(self):
data_dirs = []
for root, dirs, files in os.walk("./pixelweb/ui"):
- base = root.replace("\\","/").replace("./pixelweb/", "")
+ base = root.replace("\\", "/").replace("./pixelweb/", "")
for f in files:
data_dirs.append(base + "/" + f)
@@ -63,13 +65,13 @@ def run(self):
license='MIT',
packages=['pixelweb'],
scripts=['run-pixelweb', 'pixelweb_genmanifest'],
- package_data = {'pixelweb' : data_dirs},
- cmdclass = {'install_scripts': do_install_scripts},
- classifiers = [
+ package_data={'pixelweb': data_dirs},
+ cmdclass={'install_scripts': do_install_scripts},
+ classifiers=[
'Development Status :: 4 - Beta',
'License :: OSI Approved :: MIT License',
'Programming Language :: Python :: 2',
'Programming Language :: Python :: 2.6',
'Programming Language :: Python :: 2.7',
- ],
- )
+ ],
+)

0 comments on commit 8cd295d

Please sign in to comment.