Example #1
0
    def new_wb(self, name):
        """ Create a new webbox with this name. """

        name = name.lower()

        if self.invalid_name(name):
            raise Exception("WebBox name contains illegal characters.")

        webbox_dir = os.path.abspath(self.config['wbs_dir'] + os.sep + name)
        if os.path.exists(webbox_dir):
            raise Exception("WebBox already exists")

        kbname = "webboxmulti_"+name

        next_port = self.config['next_port']
        self.config['next_port'] += 2

        fs_port = next_port
        ws_port = next_port + 1

        setup = WebBoxSetup()
        setup.setup(webbox_dir, "webbox.json.default", kbname, fs_port = fs_port, ws_port = ws_port) # directory, default config, kbname

        self.config['webboxes'].append( {"directory": name, "status": "stopped", "location": webbox_dir } )
        self.save_config()
Example #2
0
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with WebBox.  If not, see <http://www.gnu.org/licenses/>.

# import core modules
import sys, os, logging, json, shutil, getpass, re
from webboxsetup import WebBoxSetup
from webbox import WebBox
from webserver import WebServer

# Initial Setup of ~/.webbox
kbname = "webbox_" + getpass.getuser() # per user knowledge base
webbox_dir = os.path.expanduser('~'+os.sep+".webbox")
setup = WebBoxSetup()
setup.setup(webbox_dir, "webbox.json.default", kbname) # directory, default config, kbname


# load configuration into 'config' variable
webbox_config = webbox_dir + os.sep + "webbox.json"
conf_fh = open(webbox_config, "r")
config = json.loads(conf_fh.read())
conf_fh.close()

# add the webbox path to the config (at runtime only)
config['webbox']['webbox_dir'] = webbox_dir

# add additional binary paths to the PATH
for bindir in config['server']['bindirs']:
    os.environ['PATH'] = os.path.join(os.path.dirname(__file__), bindir) + ":" + os.environ['PATH']