| author | Sandro Knauß <knauss@netzguerilla.net> |
| Fri, 30 Mar 2012 16:39:12 +0200 | |
| branch | devel |
| changeset 270 | 665c3ea02d35 |
| parent 237 | eb3501d2cdc9 |
| child 284 | f3be8a77b3e2 |
| permissions | -rwxr-xr-x |
|
237
eb3501d2cdc9
update setup.py file and moving some scripts to subdirs
Sandro Knauß <knauss@netzguerilla.net>
parents:
229
diff
changeset
|
1 |
#!/usr/bin/env python2.7 |
| 227 | 2 |
from twisted.python import log |
3 |
||
4 |
from sqlalchemy import create_engine, pool |
|
5 |
from sqlalchemy.exc import ArgumentError |
|
6 |
import sys |
|
7 |
||
8 |
import logging |
|
9 |
||
10 |
from iro.controller.pool import dbPool |
|
|
237
eb3501d2cdc9
update setup.py file and moving some scripts to subdirs
Sandro Knauß <knauss@netzguerilla.net>
parents:
229
diff
changeset
|
11 |
from iro import config, __version__, install |
| 227 | 12 |
|
13 |
observer = log.PythonLoggingObserver() |
|
14 |
observer.start() |
|
15 |
||
16 |
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s') |
|
17 |
||
18 |
import argparse |
|
19 |
||
20 |
parser = argparse.ArgumentParser(description='Iro main routine.', version=__version__) |
|
21 |
parser.add_argument('--install', action='store_true', |
|
22 |
help='will create the right database layout.') |
|
23 |
parser.add_argument('--update', action='store_true', |
|
24 |
help='will install all routes and providers.') |
|
25 |
args = parser.parse_args() |
|
26 |
||
27 |
if not install.checkConfig(): |
|
28 |
install.createSampleConfig() |
|
29 |
logging.info("Please edit iro.conf") |
|
30 |
sys.exit(1) |
|
31 |
||
32 |
config.init() |
|
33 |
||
34 |
try: |
|
35 |
engine = create_engine(config.main.dburl, |
|
36 |
poolclass = pool.SingletonThreadPool, pool_size=dbPool.maxthreads, ) |
|
37 |
except ArgumentError: |
|
38 |
logging.error("Can't connect to database") |
|
39 |
logging.info("Please edit iro.conf") |
|
40 |
sys.exit(1) |
|
41 |
||
42 |
||
43 |
if not install.checkDatabaseConnection(): |
|
44 |
logging.error("Can't connect to database") |
|
45 |
logging.info("Please edit iro.conf") |
|
46 |
sys.exit(1) |
|
47 |
||
48 |
if not install.checkDatabase(): |
|
49 |
logging.error("Database not in right format.") |
|
50 |
if args.install: |
|
51 |
install.createDatabase() |
|
52 |
logging.info("Database layout created.") |
|
53 |
else: |
|
54 |
logging.info("Please edit iro.conf and run %s --install"%sys.argv[0]) |
|
55 |
sys.exit(1) |
|
56 |
||
57 |
routes = [ s for s in config.configParser.sections() if not s in ["main",]] |
|
58 |
ao = install.getAllRoutes(routes, False) |
|
59 |
for o in ao["orphand"]: |
|
60 |
logging.info("Offer(%s) is orphand (no route using this offer)."%o) |
|
61 |
if ao["added"]: |
|
62 |
if args.install or args.update: |
|
63 |
ao = install.getAllRoutes(routes,True) |
|
64 |
for a in ao["added"]: |
|
65 |
logging.info("Added Offer(%s)"%a) |
|
66 |
logging.info('Updated offerlist.') |
|
67 |
else: |
|
68 |
logging.warning('offerlist is not up-to-date.') |
|
69 |
logging.info("Please run %s --update"%sys.argv[0]) |
|
|
270
665c3ea02d35
extras/iro.tac: now using check functions
Sandro Knauß <knauss@netzguerilla.net>
parents:
237
diff
changeset
|
70 |
sys.exit(1) |
| 227 | 71 |
|
|
237
eb3501d2cdc9
update setup.py file and moving some scripts to subdirs
Sandro Knauß <knauss@netzguerilla.net>
parents:
229
diff
changeset
|
72 |
logging.info("You can just start your iro server.") |
|
229
1bd4c7f58b3f
createing iro-service.tac
Sandro Knauß <knauss@netzguerilla.net>
parents:
227
diff
changeset
|
73 |
|
| 227 | 74 |