- Timestamp:
- 04/07/11 15:09:37 (13 years ago)
- Location:
- trunk/sara_cmt
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sara_cmt/cmt.py
r12664 r12812 36 36 from sara_cmt.django_cli import ModelExtension, ObjectManager, QueryManager, \ 37 37 logger, parser 38 from sara_cmt.parser import Parser39 38 40 39 import sara_cmt.cluster.models … … 80 79 81 80 # Instantiate ConfigParser 82 #configfile = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'config/cmt.cfg')83 81 configfile = os.path.join(settings.PROJECT_BASE, 'config/cmt.cfg') 84 82 config_parser = ConfigParser.ConfigParser() … … 100 98 CMTSARA_DESCRIPTION = config_parser.get('info', 'description').strip("'") 101 99 102 parse_object = Parser()103 parser = parse_object.getParser()104 105 # Get and set the defaults106 DRYRUN = config_parser.getboolean('defaults', 'DRYRUN')107 INTERACTIVE = config_parser.getboolean('defaults', 'INTERACTIVE')108 100 # 109 101 # </CMT-specific settings from file> … … 392 384 393 385 parser.add_option('-n', '--dry-run', 394 395 396 397 386 action='store_true', 387 dest='DRYRUN', 388 default=config_parser.getboolean('defaults', 'DRYRUN'), 389 help="""This flag has to be given before -[aclmr]""") 398 390 parser.add_option('--script', 399 action='store_false', 400 dest='INTERACTIVE', 401 default=config_parser.getboolean('defaults', 402 'INTERACTIVE')) 391 action='store_false', 392 dest='INTERACTIVE', 393 default=config_parser.getboolean('defaults', 'INTERACTIVE')) 403 394 parser.add_option('-a', '--add', 404 action='callback', 405 callback=add, 406 type='string', 407 metavar='ENTITY', 408 nargs=1, 409 help="""Add an object of given ENTITY. 410 411 arguments: set <ASSIGNMENTS> 412 413 The object will get values according to the given 414 assignments. Assignments could be formed like 415 [<FK>__]<attr>=<value>""") 395 action='callback', 396 callback=add, 397 type='string', 398 metavar='ENTITY', 399 nargs=1, 400 help="""Add an object of given ENTITY. 401 402 arguments: set <ASSIGNMENTS> 403 404 The object will get values according to the given assignments. 405 Assignments could be formed like [<FK>__]<attr>=<value>""") 416 406 parser.add_option('-c', '--change', 417 action='callback', 418 callback=change, 419 type='string', 420 metavar='ENTITY', 421 nargs=1, 422 help="""Change value(s) of object(s) of given ENTITY. 423 424 arguments: get <QUERY> set <ASSIGNMENTS> 425 426 The query, which consists out of one or more terms, is 427 used to make a selection of objects to change. These 428 objects will be changed according to the given 429 assignments.""") 407 action='callback', 408 callback=change, 409 type='string', 410 metavar='ENTITY', 411 nargs=1, 412 help="""Change value(s) of object(s) of given ENTITY. 413 414 arguments: get <QUERY> set <ASSIGNMENTS> 415 416 The query, which consists out of one or more terms, is used to make 417 a selection of objects to change. These objects will be changed 418 according to the given assignments.""") 430 419 parser.add_option('-g', '--generate', 431 432 433 434 435 436 420 action='callback', 421 callback=generate, 422 type='string', 423 metavar='TEMPLATE', 424 nargs=1, 425 help='Render the given template') 437 426 parser.add_option('-l', '--list', 438 439 440 441 442 443 444 445 446 447 The query, which consists out of one or more terms, is448 used to makea selection of objects to list.""")427 action='callback', 428 callback=show, 429 type='string', 430 metavar='ENTITY [ATTRIBUTE=VALUE]', 431 nargs=1, 432 help="""List object(s) of the given ENTITY. 433 434 arguments: get <QUERY> 435 436 The query, which consists out of one or more terms, is used to make 437 a selection of objects to list.""") 449 438 parser.add_option('-r', '--remove', 450 451 452 453 454 455 439 action='callback', 440 callback=remove, 441 type='string', 442 metavar='ENTITY [ATTRIBUTE=VALUE]', 443 nargs=1, 444 help='Remove objects which reflect the given query') 456 445 457 446 # TODO: implement the following option(s) 458 447 parser.add_option('-v', '--verbose', 459 action='store_true', 460 dest='VERBOSE', 461 default=config_parser.getboolean('defaults', 462 'VERBOSE')) 448 action='store_true', 449 dest='VERBOSE', 450 default=config_parser.getboolean('defaults', 'VERBOSE')) 463 451 464 452 (options, args) = parser.parse_args() -
trunk/sara_cmt/sara_cmt/django_cli.py
r12655 r12812 140 140 """ 141 141 m2ms = [] # to collect M2Ms (which should be done at last) 142 142 143 for arg in arg_dict: 143 144 field = self._meta.get_field(arg) … … 151 152 continue 152 153 153 #if type(field) == ForeignKey: 154 # self._setfk(field, arg_dict[arg]) 155 156 #elif type(field) == ManyToManyField: 157 # # Leave M2Ms for later, because they need an object's id 158 # m2ms.append([field, arg_dict[arg]]) 154 # Leave M2Ms for later, because they need an object's id 159 155 elif type(field) == ManyToManyField: 160 156 m2ms.append([field,arg_dict[arg]]) 161 157 162 #else:163 # logger.debug("Assuming '%s' is a regular field" % arg)164 # self._setattr(field=arg, value=arg_dict[arg])165 158 self._setattr(field=arg, value=arg_dict[arg]) 166 159 … … 236 229 except AssertionError, err: 237 230 logger.error(err) 238 except sqlite3.IntegrityError, err: 231 except sqlite3.IntegrityError, err: # ??? what if using non-sqlite db? ??? 239 232 logger.error('IntegrityError:', err) 240 233 -
trunk/sara_cmt/sara_cmt/settings.py
r12458 r12812 10 10 PROJECT_BASE = os.path.normpath(os.path.join(SARACMT_BASE, os.path.pardir)) 11 11 12 #DEBUG = False13 12 DEBUG = True 14 TEMPLATE_DEBUG = DEBUG15 13 16 14 ADMINS = ( … … 25 23 # excluded from the SVN repository. An example of the needed info for database 26 24 # configuration is commented out. 25 # DATABASE_ENGINE = 'postgresql_psycopg2' 26 # DATABASE_NAME = 'my_database' 27 # DATABASE_USER = 'db_user' 28 # DATABASE_PASSWORD = 'secret' 29 # DATABASE_HOST = 'database.example.com' 27 30 from settings_db import * 28 #TEST_DATABASE_NAME = ''29 31 30 32 … … 140 142 ROOT_URLCONF = 'sara_cmt.urls' 141 143 144 # Templates for the CMT command line interface. 145 # (thus, the templates for our configfiles, etc) 146 CMT_TEMPLATES_DIR = '/etc/sara_cmt/templates' 147 142 148 # Templates for the CMT web-frontend. 143 149 TEMPLATE_DIRS = ( … … 147 153 # Don't forget to use absolute paths, not relative paths. 148 154 os.path.normpath(os.path.join(os.path.dirname(__file__), 'cluster/templates')), 155 CMT_TEMPLATES_DIR, 149 156 ) 150 151 # Templates for the CMT command line interface.152 # (thus, the templates for our configfiles, etc)153 CMT_TEMPLATES_DIR = '/etc/sara_cmt/templates'154 157 155 158 FIXTURE_DIRS = (
Note: See TracChangeset
for help on using the changeset viewer.