Revision a4af651e lib/cli.py

b/lib/cli.py
177 177
FORCE_OPT = make_option("-f", "--force", dest="force", action="store_true",
178 178
                        default=False, help="Force the operation")
179 179

  
180
_LOCK_OPT = make_option("--lock-retries", default=None,
181
                        type="int", help=SUPPRESS_HELP)
182

  
183 180
TAG_SRC_OPT = make_option("--from", dest="tags_source",
184 181
                          default=None, help="File with tag names")
185 182

  
......
283 280
    cmd = aliases[cmd]
284 281

  
285 282
  func, nargs, parser_opts, usage, description = commands[cmd]
286
  parser_opts.append(_LOCK_OPT)
287 283
  parser = OptionParser(option_list=parser_opts,
288 284
                        description=description,
289 285
                        formatter=TitledHelpFormatter(),
......
519 515
  logger.SetupLogging(debug=options.debug, program=binary)
520 516

  
521 517
  utils.debug = options.debug
522
  try:
523
    utils.Lock('cmd', max_retries=options.lock_retries, debug=options.debug)
524
  except errors.LockError, err:
525
    logger.ToStderr(str(err))
526
    return 1
527
  except KeyboardInterrupt:
528
    logger.ToStderr("Aborting.")
529
    return 1
530 518

  
531 519
  if old_cmdline:
532 520
    logger.Info("run with arguments '%s'" % old_cmdline)
......
534 522
    logger.Info("run with no arguments")
535 523

  
536 524
  try:
537
    try:
538
      result = func(options, args)
539
    except errors.GenericError, err:
540
      result, err_msg = FormatError(err)
541
      logger.ToStderr(err_msg)
542
  finally:
543
    utils.Unlock('cmd')
544
    utils.LockCleanup()
525
    result = func(options, args)
526
  except errors.GenericError, err:
527
    result, err_msg = FormatError(err)
528
    logger.ToStderr(err_msg)
545 529

  
546 530
  return result
547 531

  

Also available in: Unified diff