Permalink
Browse files

Removed GPL license and refactored settings

  • Loading branch information...
1 parent ab1dc1d commit f9ee3904c5a157adef8c606d55d4ddefb718a931 @BasicWolf committed May 30, 2012
View
25 LICENSE
@@ -2,13 +2,10 @@ Copyright (c) 2012 by Zaur Nasibov and contributors. See AUTHORS for more
details.
Some rights reserved.
-Distribution is allowed under either conditions of MIT or GPLv3 license
-which are provided below.
+Distribution is allowed under conditions of MIT license:
-MIT License
------------
Permission is hereby granted, free of charge, to any person obtaining a copy of
-this software and associated documentation files (the "Software"), to deal in
+Kaylee and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished
@@ -22,20 +19,4 @@ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
-CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
-
-GNU General Public License version 3.
--------------------------------------
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-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 this program. If not, see <http://www.gnu.org/licenses/>.
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
14 src/bin/settings.py
@@ -1,11 +1,13 @@
# -*- coding: utf-8 -*-
+
PROJECTS_DIR = '/home/zaur/Documents/projects/kaylee/src/projects'
+KAYLEE_JS_ROOT = '/static/js/kaylee'
+LIB_JS_ROOT = '/static/js/lib'
+PROJECTS_STATIC_ROOT = '/static/js/projects'
-KAYLEE = {
- 'nodes_storage' : {
- 'name' : 'MemoryNodesStorage',
- 'config' : {},
- },
+NODES_STORAGE = {
+ 'name' : 'MemoryNodesStorage',
+ 'config' : {},
}
APPLICATIONS = [
@@ -14,7 +16,7 @@
'project' : {
'name' : 'MonteCarloPiProject',
'config' : {
- 'alias' : 'monte_carlo_pi',
+ 'script' : 'monte_carlo_pi/monte_carlo_pi.js',
'random_points' : 1000000,
'tasks_count' : 20
},
View
2 src/kaylee/__init__.py
@@ -11,7 +11,7 @@
stuff automatically.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
__version__ = '0.1'
View
2 src/kaylee/controller.py
@@ -6,7 +6,7 @@
This module provides classes for Kaylee controllers.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
from abc import ABCMeta, abstractmethod, abstractproperty
from datetime import datetime
View
2 src/kaylee/errors.py
@@ -6,7 +6,7 @@
This module implements all exceptions raised by the Kaylee package.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
View
11 src/kaylee/kaylee.py
@@ -7,7 +7,7 @@
be easily used with any web framework.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
import threading
import json
@@ -24,19 +24,24 @@ class Kaylee(object):
Usually you don't create an instance of :class:`Kaylee` is not created,
but rather call :function:`kaylee.load` with settings as an argument.
+ :param nodes_config: settings-based configuration required by every node
+ in order to function properly. This includes for
+ example the URL root of the projects' script files.
:param nodes_storage: an instance of :class:`kaylee.NodesStorage`.
:param applications: an instance of :class:`kaylee.Applications` object.
"""
- def __init__(self, nodes_storage, applications = Applications({})):
- self.applications = applications
+ def __init__(self, nodes_config, nodes_storage, applications):
+ self.nodes_config = nodes_config
self.nodes = nodes_storage
+ self.applications = applications
self._lock = threading.Lock()
def register(self, remote_host):
with self._lock:
node = Node(NodeID(remote_host))
self.nodes.add(node)
return json.dumps ({ 'node_id' : str(node.id),
+ 'config' : self.nodes_config,
'applications' : self.applications.names } )
def unregister(self, node_id):
View
14 src/kaylee/loader.py
@@ -6,7 +6,7 @@
Implements Kaylee projects, controllers and Kaylee loader.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
import os
import importlib
@@ -105,11 +105,17 @@ def _load_kaylee(settings):
controllers[app_name] = controller
_idx += 1
applications = Applications(controllers)
+
+ # build Kaylee nodes configuration
+ nodes_config = {'projects_static_root' : settings.PROJECTS_STATIC_ROOT,
+ 'kaylee_js_root' : settings.KAYLEE_JS_ROOT,
+ 'lib_js_root' : settings.LIB_JS_ROOT,
+ }
# initialize Kaylee
- nsname = settings.KAYLEE['nodes_storage']['name']
+ nsname = settings.NODES_STORAGE['name']
nscls = nstorage_classes[nsname]
- nstorage = nscls(**settings.KAYLEE['nodes_storage']['config'])
- kaylee = Kaylee(nstorage, applications)
+ nstorage = nscls(**settings.NODES_STORAGE['config'])
+ kaylee = Kaylee(nodes_config, nstorage, applications)
return kaylee
def _store_classes(dest, classes, cls):
View
2 src/kaylee/node.py
@@ -8,7 +8,7 @@
Implements Kaylee server-side node classes.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
from datetime import datetime
View
6 src/kaylee/project.py
@@ -6,7 +6,7 @@
This module provides basic interfaces for Kaylee projects.
:copyright: (c) 2012 by Zaur Nasibov.
- :license: MIT or GPLv3, see LICENSE for more details.
+ :license: MIT, see LICENSE for more details.
"""
from abc import ABCMeta, abstractmethod
from copy import copy
@@ -26,7 +26,9 @@ def __init__(self, *args, **kwargs):
#: contain a path to the javascript file with project's
#: client-side logic. That path will be later used by Kaylee's
#: client engine to load and start calculations on client.
- self.nodes_config = { }
+ self.nodes_config = {
+ 'script' : kwargs['script'],
+ }
def __iter__(self):
return self
View
34 src/kayleejs/src/kaylee.coffee
@@ -5,9 +5,12 @@ kl = {
config : null # {}
worker : null # Worker object
classes : {}
- config:
- root : '/kaylee'
- jsroot : '/static/js'
+ config: {
+ # url_root # set by kl.setup()
+ # kaylee_js_root
+ # lib_js_root
+ # projects_static_root
+ }
}
class Event
@@ -71,23 +74,28 @@ kl.post_message = (msg, data = {}) ->
kl.import = $script
kl.import_lib = (libname, callback) ->
- kl.import("#{kl.config.jsroot}/lib/#{libname}", callback)
+ kl.import("#{kl.config.lib_js_root}/#{libname}", callback)
+
+kl.setup = (config) ->
+ # expected configuration
+ # url_root = all Kaylee requests fill starts with current prefix
+ kl.config = config
kl.register = () ->
- kl.get("#{kl.config.root}/register", kl.node_registered.trigger)
+ kl.get("#{kl.config.url_root}/register", kl.node_registered.trigger)
kl.subscribe = (app_name) ->
kl.app.name = app_name
- kl.get("#{kl.config.root}/apps/#{app_name}/subscribe/#{kl.node_id}",
+ kl.get("#{kl.config.url_root}/apps/#{app_name}/subscribe/#{kl.node_id}",
kl.node_subscribed.trigger
)
kl.get_task = () ->
- kl.get("#{kl.config.root}/tasks/#{kl.node_id}",
+ kl.get("#{kl.config.url_root}/tasks/#{kl.node_id}",
_parse_action)
kl.send_results = (data) ->
- kl.post("#{kl.config.root}/tasks/#{kl.node_id}", data,
+ kl.post("#{kl.config.url_root}/tasks/#{kl.node_id}", data,
(edata) ->
kl.results_sent.trigger()
_parse_action(edata)
@@ -100,21 +108,23 @@ _parse_action = (data) ->
# Primary event handlers
on_node_registered = (data) ->
+ for key, val of data.config
+ kl.config[key] = val
kl.node_id = data.node_id
on_node_subscribed = (config) ->
kl.app.config = config
kl.app.worker.terminate() if kl.app.worker?
- worker = new Worker("#{kl.config.jsroot}/kaylee/klworker.js");
+ worker = new Worker("#{kl.config.kaylee_js_root}/klworker.js");
kl.app.worker = worker;
worker.addEventListener('message', ((e) -> on_worker_message(e.data)),
false);
worker.addEventListener('error', ((e) -> on_worker_error(e)), false);
- alias = config.alias
kl.post_message('import_project', {
- 'config' : kl.app.config,
- 'script' : "#{kl.config.jsroot}/projects/#{alias}/#{alias}.js",
+ 'kl_config' : kl.config,
+ 'app_config' : kl.app.config,
+ 'script' : "#{kl.config.projects_static_root}/#{config.script}",
})
View
1 src/kayleejs/src/kldemo.coffee
@@ -3,6 +3,7 @@ kl = window.kl
_tasks_counter = 0
$(document).ready( () ->
+ kl.setup( { url_root : '/kaylee' } )
kl.console.init('console')
kl.console.print('<b>Kaylee status console</b><br>')
kl.node_registered.bind(on_node_registered)
View
2 src/kayleejs/src/klworker.coffee
@@ -15,7 +15,7 @@ klw.post_message = (msg, data = {}) ->
klw.import_project = (data) ->
importScripts(data.script)
- pj.init(data.config)
+ pj.init(data.kl_config, data.app_config)
klw.post_message('project_imported')
klw.task_completed = (res) ->
View
9 src/projects/monte_carlo_pi/__init__.py
@@ -1,17 +1,14 @@
# -*- coding: utf-8 -*-
from kaylee.project import Project, Task
-ALIAS = 'monte_carlo_pi'
-
class MonteCarloPiProject(Project):
def __init__(self, *args, **kwargs):
super(MonteCarloPiProject, self).__init__(*args, **kwargs)
self.tasks_count = kwargs['tasks_count']
self.random_points = kwargs['random_points']
- self.nodes_config = {
- 'alias' : kwargs.get('alias', ALIAS),
- 'random_points' : self.random_points,
- }
+ self.nodes_config.update({
+ 'random_points' : self.random_points,
+ })
self._tasks_counter = -1
def __iter__(self):
View
6 src/projects/monte_carlo_pi/res/js/monte_carlo_pi.coffee
@@ -1,9 +1,9 @@
pj =
ALIAS : 'monte_carlo_pi'
-pj.init = (config) ->
- pj.config = config
- importScripts('/static/js/lib/alea.js')
+pj.init = (kl_config, app_config) ->
+ pj.config = app_config
+ importScripts("#{kl_config.lib_js_root}/alea.js")
pj.on_task_recieved = (data) ->
random = new Alea(data.id)

0 comments on commit f9ee390

Please sign in to comment.