equal
deleted
inserted
replaced
1 #!/usr/bin/env python2.7 |
1 #!/usr/bin/env python2.7 |
2 from twisted.python import log |
2 from twisted.python import log |
3 |
3 |
4 from sqlalchemy import create_engine, pool |
4 from sqlalchemy import create_engine, pool |
5 from sqlalchemy.exc import ArgumentError |
5 from sqlalchemy.exc import ArgumentError |
6 import sys |
6 import sys,os |
7 |
7 |
8 import logging |
8 import logging |
9 |
9 |
10 from iro.controller.pool import dbPool |
10 from iro.controller.pool import dbPool |
11 from iro import config, __version__, install |
11 from iro import config, __version__, install |
15 |
15 |
16 logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s') |
16 logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)s(%(processName)s)-%(levelname)s: %(message)s') |
17 |
17 |
18 import argparse |
18 import argparse |
19 |
19 |
20 parser = argparse.ArgumentParser(description='Iro main routine.', version=__version__) |
20 parser = argparse.ArgumentParser(description='Iro installer.') |
|
21 parser.add_argument('-v', '--version', action='version', version="%s %s"%(os.path.basename(sys.argv[0]),__version__)) |
21 parser.add_argument('--install', action='store_true', |
22 parser.add_argument('--install', action='store_true', |
22 help='will create the right database layout.') |
23 help='will create the right database layout.') |
23 parser.add_argument('--update', action='store_true', |
24 parser.add_argument('--update', action='store_true', |
24 help='will install all routes and providers.') |
25 help='will install all routes and providers.') |
25 args = parser.parse_args() |
26 args = parser.parse_args() |
49 logging.error("Database not in right format.") |
50 logging.error("Database not in right format.") |
50 if args.install: |
51 if args.install: |
51 install.createDatabase() |
52 install.createDatabase() |
52 logging.info("Database layout created.") |
53 logging.info("Database layout created.") |
53 else: |
54 else: |
54 logging.info("Please edit iro.conf and run %s --install"%sys.argv[0]) |
55 logging.info("Please edit iro.conf and run %s --install"%os.path.basename(sys.argv[0])) |
55 sys.exit(1) |
56 sys.exit(1) |
56 |
57 |
57 routes = [ s for s in config.configParser.sections() if not s in ["main",]] |
58 routes = [ s for s in config.configParser.sections() if not s in ["main",]] |
58 ao = install.getAllRoutes(routes, False) |
59 ao = install.getAllRoutes(routes, False) |
59 for o in ao["orphand"]: |
60 for o in ao["orphand"]: |
64 for a in ao["added"]: |
65 for a in ao["added"]: |
65 logging.info("Added Offer(%s)"%a) |
66 logging.info("Added Offer(%s)"%a) |
66 logging.info('Updated offerlist.') |
67 logging.info('Updated offerlist.') |
67 else: |
68 else: |
68 logging.warning('offerlist is not up-to-date.') |
69 logging.warning('offerlist is not up-to-date.') |
69 logging.info("Please run %s --update"%sys.argv[0]) |
70 logging.info("Please run %s --update"%os.path.basename(sys.argv[0])) |
70 sys.exit(1) |
71 sys.exit(1) |
71 |
72 |
72 logging.info("You can just start your iro server.") |
73 logging.info("You can just start your iro server.") |
73 |
74 |
74 |
75 |