Commit 8a2c88c3 authored by Thomas's avatar Thomas

initial commit

parents
# VIM
*.swp
*.swo
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
.hypothesis/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# pyenv
.python-version
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# dotenv
.env
# virtualenv
.venv
venv/
ENV/
# Spyder project settings
.spyderproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
/home/sikerdebaard/work/commandr/commandr
\ No newline at end of file
from setuptools import setup
setup(
name='commandr',
version='1.0',
description='A python commandbus implementation',
author='Thomas Phil',
author_email='thomas@tphil.nl',
packages=['commndr'], #same as name
install_requires=['bar', 'greek'], #external packages as dependencies
scripts=[]
)
from commandr.handlers.commandhandler import CommandHandler
from commandr.handlers.inflectors.callableinflector import CallableInflector
from commandr.handlers.locators.inmemorylocator import InMemoryLocator
from commandr.handlers.nameextractors.classnameextractor import ClassNameExtractor
from commandr.commandbus import CommandBus
from dto.vm.configuration import VMConfiguration
from commands import DeployVM
config = VMConfiguration(1, 4, False)
deployVmCommand = DeployVM() \
.name('thomas-test-deploy') \
.configuration(config)
extractor = ClassNameExtractor()
locator = InMemoryLocator({TestCommandHandler(): TestCommand.__name__})
inflector = CallableInflector()
handler = CommandHandler(extractor, locator, inflector)
a = CommandBus([Middleware1(), Middleware2(), handler])
print(a.handle(TestCommand({"a": 1, "b": 2})))
class DeployVM:
def name(self, name):
self.name = name
return self
def configuration(self, configuration):
self.configuration = configuration
return self
class VMConfiguration:
def __init__(self, cores, ram, gpu):
self.cores = cores
self.ram = ram
self.gpu = gpu
#!/usr/bin/python
import salt.cloud
import jsonpickle
#from concurrent.futures import ThreadPoolExecutor as Pool
#def launchVm(name):
# print "Launching " + name
# client.profile(names=[name], profile='salt-minion')
if __name__ == '__main__':
client = salt.cloud.CloudClient('/etc/salt/cloud')
names = ["thomas-new-testvm-" + str(i+1) for i in range(0,4)]
#p = Pool(3)
#p.map(launchVm, names)
vms = client.profile(names=names, profile='salt-minion', parallel=True)
print jsonpickle.encode(vms)
]0;IPython: work/commandr
NameErrorTraceback (most recent call last)
/home/sikerdebaard/work/commandr/commandr/commandbus.py in <module>()
 42 
 43 a = CommandBus([Middleware1(), Middleware2()])
---> 44 a.handle({a: 1, b: 2})

NameError: name 'b' is not defined
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment