# HG changeset patch # User Sandro Knauß # Date 1332347765 -3600 # Node ID eb3501d2cdc99bd0d3e6ed031cb8469c127acd4a # Parent 63662db5ff251e91e064cb8778b8f2346d4d969d update setup.py file and moving some scripts to subdirs diff -r 63662db5ff25 -r eb3501d2cdc9 .hgignore --- a/.hgignore Wed Mar 21 17:32:14 2012 +0100 +++ b/.hgignore Wed Mar 21 17:36:05 2012 +0100 @@ -15,3 +15,5 @@ dist/* build/* _trial_temp/* +*.egg/* +twisted/plugins/dropin.cache diff -r 63662db5ff25 -r eb3501d2cdc9 MANIFEST.in --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MANIFEST.in Wed Mar 21 17:36:05 2012 +0100 @@ -0,0 +1,5 @@ +include README +include MANIFEST.in +include iro.conf.inst +recursive-include extras * +recursive-include bin * diff -r 63662db5ff25 -r eb3501d2cdc9 bin/iro-install --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bin/iro-install Wed Mar 21 17:36:05 2012 +0100 @@ -0,0 +1,90 @@ +#!/usr/bin/env python2.7 +from twisted.python import log + +from sqlalchemy import create_engine, pool +from sqlalchemy.exc import ArgumentError +import sys + +import logging + +from iro.controller.pool import dbPool +from iro import config, __version__, install + +observer = log.PythonLoggingObserver() +observer.start() + +logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s') + +import argparse + +parser = argparse.ArgumentParser(description='Iro main routine.', version=__version__) +parser.add_argument('--install', action='store_true', + help='will create the right database layout.') +parser.add_argument('--update', action='store_true', + help='will install all routes and providers.') +args = parser.parse_args() + +if not install.checkConfig(): + install.createSampleConfig() + logging.info("Please edit iro.conf") + sys.exit(1) + +config.init() + +try: + engine = create_engine(config.main.dburl, + poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, ) +except ArgumentError: + logging.error("Can't connect to database") + logging.info("Please edit iro.conf") + sys.exit(1) + + +if not install.checkDatabaseConnection(): + logging.error("Can't connect to database") + logging.info("Please edit iro.conf") + sys.exit(1) + +if not install.checkDatabase(): + logging.error("Database not in right format.") + if args.install: + install.createDatabase() + logging.info("Database layout created.") + logging.info("Now you can run "+sys.argv[0]) + else: + logging.info("Please edit iro.conf and run %s --install"%sys.argv[0]) + sys.exit(1) + +routes = [ s for s in config.configParser.sections() if not s in ["main",]] +ao = install.getAllRoutes(routes, False) +for o in ao["orphand"]: + logging.info("Offer(%s) is orphand (no route using this offer)."%o) +if ao["added"]: + if args.install or args.update: + ao = install.getAllRoutes(routes,True) + for a in ao["added"]: + logging.info("Added Offer(%s)"%a) + logging.info('Updated offerlist.') + logging.info("Now you can run "+sys.argv[0]) + else: + logging.warning('offerlist is not up-to-date.') + logging.info("Please run %s --update"%sys.argv[0]) + sys.exit(1) + +if args.install or args.update: + logging.info('Nothing todo for me.') + logging.info("Now you can run "+sys.argv[0]) + sys.exit(1) + +logging.info("You can just start your iro server.") + +#start via cmdline +#root = resource.Resource() +#root = xmlrpc.appendResource(root) + +#v2 = resource.Resource() +#v2 = xmlrpc.appendResource(root) +#root.putChild('2.0', v2) + +#reactor.callLater(0.2, config.readConfig) +#main.runReactor(reactor, engine, config.main.port, root) diff -r 63662db5ff25 -r eb3501d2cdc9 extras/iro.tac --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/extras/iro.tac Wed Mar 21 17:36:05 2012 +0100 @@ -0,0 +1,41 @@ +from twisted.application.service import Service, Application +from twisted.application import internet +from twisted.web import resource, server +from twisted.internet import reactor +from twisted.python import log + +from sqlalchemy import create_engine, pool + +from iro import config +from iro.view import xmlrpc +from iro.model import setEngine, setPool +from iro.controller.pool import startPool, dbPool + +class IroService(Service): + def startService(self): + log.msg("Starting service...") + engine = create_engine(config.main.dburl, + poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, ) + + setEngine(engine) + startPool(reactor) + setPool(dbPool) + reactor.callWhenRunning(config.readConfig) + + +def get_application(): + app = Application("Iro") + config.init() + + root = resource.Resource() + root = xmlrpc.appendResource(root) + + v2 = resource.Resource() + v2 = xmlrpc.appendResource(root) + root.putChild('2.0', v2) + + internet.TCPServer(config.main.port, server.Site(root)).setServiceParent(app) + IroService().setServiceParent(app) + return app + +application = get_application() diff -r 63662db5ff25 -r eb3501d2cdc9 fabfile.py --- a/fabfile.py Wed Mar 21 17:32:14 2012 +0100 +++ b/fabfile.py Wed Mar 21 17:36:05 2012 +0100 @@ -26,13 +26,17 @@ put("dist/iro-%s.tar.gz"%__version__,"%s/dist/"%env.directory) put("%(directory)s/dist/ngmodules-%(version)s-py2.7.egg"%ngmodules,"%s/dist/"%env.directory) virtualenv("easy_install %s/dist/ngmodules-%s-py2.7.egg"%(env.directory,ngmodules["version"])) - virtualenv("pip uninstall iro") + virtualenv("pip uninstall -y iro") virtualenv("pip install %s/dist/iro-%s.tar.gz"%(env.directory,__version__)) def prepare_tests(): put("tests/*","%s/tests/"%env.directory) +def startserver(): + run("cd %s && tar -xzf dist/iro-%s.tar.gz"%(env.directory,__version__)) + virtualenv("twistd -ny %s/iro-%s/extras/iro.tac"%(env.directory,__version__)) + def testserver(): prepare_tests() virtualenv("python %s/tests/xmlrpc.py"%env.directory) diff -r 63662db5ff25 -r eb3501d2cdc9 iro-service.tac --- a/iro-service.tac Wed Mar 21 17:32:14 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,41 +0,0 @@ -from twisted.application.service import Service, Application -from twisted.application import internet -from twisted.web import resource, server -from twisted.internet import reactor -from twisted.python import log - -from sqlalchemy import create_engine, pool - -from iro import config -from iro.view import xmlrpc -from iro.model import setEngine, setPool -from iro.controller.pool import startPool, dbPool - -class IroService(Service): - def startService(self): - log.msg("Starting service...") - engine = create_engine(config.main.dburl, - poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, ) - - setEngine(engine) - startPool(reactor) - setPool(dbPool) - reactor.callWhenRunning(config.readConfig) - - -def get_application(): - app = Application("Iro") - config.init() - - root = resource.Resource() - root = xmlrpc.appendResource(root) - - v2 = resource.Resource() - v2 = xmlrpc.appendResource(root) - root.putChild('2.0', v2) - - internet.TCPServer(config.main.port, server.Site(root)).setServiceParent(app) - IroService().setServiceParent(app) - return app - -application = get_application() diff -r 63662db5ff25 -r eb3501d2cdc9 iro.py --- a/iro.py Wed Mar 21 17:32:14 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,91 +0,0 @@ -from twisted.python import log -from twisted.internet import reactor -from twisted.web import resource - -from sqlalchemy import create_engine, pool -from sqlalchemy.exc import ArgumentError -import sys - -import logging - -from iro.controller.pool import dbPool -from iro.view import xmlrpc -from iro import config, main, __version__, install - -observer = log.PythonLoggingObserver() -observer.start() - -logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s') - -import argparse - -parser = argparse.ArgumentParser(description='Iro main routine.', version=__version__) -parser.add_argument('--install', action='store_true', - help='will create the right database layout.') -parser.add_argument('--update', action='store_true', - help='will install all routes and providers.') -args = parser.parse_args() - -if not install.checkConfig(): - install.createSampleConfig() - logging.info("Please edit iro.conf") - sys.exit(1) - -config.init() - -try: - engine = create_engine(config.main.dburl, - poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, ) -except ArgumentError: - logging.error("Can't connect to database") - logging.info("Please edit iro.conf") - sys.exit(1) - - -if not install.checkDatabaseConnection(): - logging.error("Can't connect to database") - logging.info("Please edit iro.conf") - sys.exit(1) - -if not install.checkDatabase(): - logging.error("Database not in right format.") - if args.install: - install.createDatabase() - logging.info("Database layout created.") - logging.info("Now you can run "+sys.argv[0]) - else: - logging.info("Please edit iro.conf and run %s --install"%sys.argv[0]) - sys.exit(1) - -routes = [ s for s in config.configParser.sections() if not s in ["main",]] -ao = install.getAllRoutes(routes, False) -for o in ao["orphand"]: - logging.info("Offer(%s) is orphand (no route using this offer)."%o) -if ao["added"]: - if args.install or args.update: - ao = install.getAllRoutes(routes,True) - for a in ao["added"]: - logging.info("Added Offer(%s)"%a) - logging.info('Updated offerlist.') - logging.info("Now you can run "+sys.argv[0]) - else: - logging.warning('offerlist is not up-to-date.') - logging.info("Please run %s --update"%sys.argv[0]) - sys.exit(1) - -if args.install or args.update: - logging.info('Nothing todo for me.') - logging.info("Now you can run "+sys.argv[0]) - sys.exit(1) - - -#start via cmdline -#root = resource.Resource() -#root = xmlrpc.appendResource(root) - -#v2 = resource.Resource() -#v2 = xmlrpc.appendResource(root) -#root.putChild('2.0', v2) - -#reactor.callLater(0.2, config.readConfig) -#main.runReactor(reactor, engine, config.main.port, root) diff -r 63662db5ff25 -r eb3501d2cdc9 setup.py --- a/setup.py Wed Mar 21 17:32:14 2012 +0100 +++ b/setup.py Wed Mar 21 17:36:05 2012 +0100 @@ -5,13 +5,16 @@ setup(name='iro', version=__version__, - packages=['iro','iro.controller','iro.view','iro.model','iro.offer'], - setup_requires = ["ngmodules>=0.2","mock"], + packages=['iro','iro.controller','iro.view','iro.model','iro.offer','iro.tests', 'iro.test_helpers'], + setup_requires = ["ngmodules>=0.2","mock", 'setuptools_trial'], install_requires=['twisted>=11.1.0',"ConfigParser","sqlalchemy","MySQL-python","SOAPpy",'decorator'], - #test_suite="nose.collector", #ToDo switch to trial + #test_suite="tests", #ToDo switch to trial description='Non Blocking Interface for sending a bunsh of SMSes, FAXes and Mails', author='Sandro Knauß', author_email='knauss@netzguerilla.net', url='https://netzguerilla.net/admin/hg/iro', - scripts=['iro.py'] -) + scripts=["bin/iro-install"], + #entry_points = { + # 'console_scripts': ['iro = iro.py',], + # } + )