comparison roundup-admin @ 153:b07b9a5b6aa9

Freshen is really broken. Commented out.
author Richard Jones <richard@users.sourceforge.net>
date Mon, 30 Jul 2001 02:37:07 +0000
parents 0e3cb7a4290f
children 002249ffa5d0
comparison
equal deleted inserted replaced
152:80c062af1b7d 153:b07b9a5b6aa9
1 #! /usr/bin/python 1 #! /usr/bin/python
2 # $Id: roundup-admin,v 1.7 2001-07-30 01:28:46 richard Exp $ 2 # $Id: roundup-admin,v 1.8 2001-07-30 02:37:07 richard Exp $
3 3
4 import sys 4 import sys
5 if int(sys.version[0]) < 2: 5 if int(sys.version[0]) < 2:
6 print 'Roundup requires python 2.0 or later.' 6 print 'Roundup requires python 2.0 or later.'
7 sys.exit(1) 7 sys.exit(1)
271 for designator in designators: 271 for designator in designators:
272 classname, nodeid = roundupdb.splitDesignator(designator) 272 classname, nodeid = roundupdb.splitDesignator(designator)
273 db.getclass(classname).retire(nodeid) 273 db.getclass(classname).retire(nodeid)
274 return 0 274 return 0
275 275
276 def db_freshen(db, args): 276 def do_freshen(db, args):
277 '''Usage: freshen 277 '''Usage: freshen
278 Freshen an existing instance. **do not use 278 Freshen an existing instance. **DO NOT USE**
279
280 This currently kills databases!!!!
279 281
280 This action should generally not be used. It reads in an instance 282 This action should generally not be used. It reads in an instance
281 database and writes it again. In the future, is may also update 283 database and writes it again. In the future, is may also update
282 instance code to account for changes in templates. It's probably wise 284 instance code to account for changes in templates. It's probably wise
283 not to use it anyway. Until we're sure it won't break things... 285 not to use it anyway. Until we're sure it won't break things...
284 ''' 286 '''
285 for classname, cl in db.classes.items(): 287 # for classname, cl in db.classes.items():
286 properties = cl.properties.keys() 288 # properties = cl.properties.items()
287 for nodeid in cl.list(): 289 # for nodeid in cl.list():
288 node = {} 290 # node = {}
289 for name in properties: 291 # for name, type in properties:
290 node[name] = cl.get(nodeid, name) 292 # if type.isMultilinkType:
291 db.setnode(classname, nodeid, node) 293 # node[name] = cl.get(nodeid, name, [])
292 return 0 294 # else:
295 # node[name] = cl.get(nodeid, name, None)
296 # db.setnode(classname, nodeid, node)
297 return 1
293 298
294 def figureCommands(): 299 def figureCommands():
295 d = {} 300 d = {}
296 for k, v in globals().items(): 301 for k, v in globals().items():
297 if k[:3] == 'do_': 302 if k[:3] == 'do_':
352 # before we open the db, we may be doing an init 357 # before we open the db, we may be doing an init
353 if command == 'init': 358 if command == 'init':
354 return do_init(instance_home, args) 359 return do_init(instance_home, args)
355 360
356 # open the database 361 # open the database
357 if command in ('create', 'set', 'retire'): 362 if command in ('create', 'set', 'retire', 'freshen'):
358 while not name: 363 while not name:
359 name = raw_input('Login name: ') 364 name = raw_input('Login name: ')
360 while not password: 365 while not password:
361 password = getpass.getpass(' password: ') 366 password = getpass.getpass(' password: ')
362 367
366 try: 371 try:
367 instance = __import__(instance) 372 instance = __import__(instance)
368 finally: 373 finally:
369 del sys.path[0] 374 del sys.path[0]
370 375
371 command = figureCommands().get(command, None) 376 function = figureCommands().get(command, None)
372 377
373 # not a valid command 378 # not a valid command
374 if command is None: 379 if function is None:
375 usage() 380 usage('Unknown command "%s"'%command)
376 return 1 381 return 1
377 382
378 db = instance.open(name or 'admin') 383 db = instance.open(name or 'admin')
379 try: 384 try:
380 return command(db, args[1:]) 385 return function(db, args[1:])
381 finally: 386 finally:
382 db.close() 387 db.close()
383 388
384 return 1 389 return 1
385 390
387 if __name__ == '__main__': 392 if __name__ == '__main__':
388 sys.exit(main()) 393 sys.exit(main())
389 394
390 # 395 #
391 # $Log: not supported by cvs2svn $ 396 # $Log: not supported by cvs2svn $
397 # Revision 1.7 2001/07/30 01:28:46 richard
398 # Bugfixes
399 #
392 # Revision 1.6 2001/07/30 00:57:51 richard 400 # Revision 1.6 2001/07/30 00:57:51 richard
393 # Now uses getopt, much improved command-line parsing. Much fuller help. Much 401 # Now uses getopt, much improved command-line parsing. Much fuller help. Much
394 # better internal structure. It's just BETTER. :) 402 # better internal structure. It's just BETTER. :)
395 # 403 #
396 # Revision 1.5 2001/07/30 00:04:48 richard 404 # Revision 1.5 2001/07/30 00:04:48 richard

Roundup Issue Tracker: http://roundup-tracker.org/