Revision 3ecf6786 lib/utils.py

b/lib/utils.py
116 116
      break
117 117
    except OSError, creat_err:
118 118
      if creat_err.errno != EEXIST:
119
        raise errors.LockError, ("Can't create the lock file. Error '%s'." %
120
                                 str(creat_err))
119
        raise errors.LockError("Can't create the lock file. Error '%s'." %
120
                               str(creat_err))
121 121

  
122 122
      try:
123 123
        pf = open(lockfile, 'r')
124 124
      except IOError, open_err:
125 125
        errcount += 1
126 126
        if errcount >= 5:
127
          raise errors.LockError, ("Lock file exists but cannot be opened."
128
                                   " Error: '%s'." % str(open_err))
127
          raise errors.LockError("Lock file exists but cannot be opened."
128
                                 " Error: '%s'." % str(open_err))
129 129
        time.sleep(1)
130 130
        continue
131 131

  
132 132
      try:
133 133
        pid = int(pf.read())
134 134
      except ValueError:
135
        raise errors.LockError('Invalid pid string in %s' %
135
        raise errors.LockError("Invalid pid string in %s" %
136 136
                               (lockfile,))
137 137

  
138 138
      if not IsProcessAlive(pid):
139
        raise errors.LockError, ('Stale lockfile %s for pid %d?' %
140
                                 (lockfile, pid))
139
        raise errors.LockError("Stale lockfile %s for pid %d?" %
140
                               (lockfile, pid))
141 141

  
142 142
      if max_retries and max_retries <= retries:
143
        raise errors.LockError, ("Can't acquire lock during the specified"
144
                                 " time, aborting.")
143
        raise errors.LockError("Can't acquire lock during the specified"
144
                               " time, aborting.")
145 145
      if retries == 5 and (debug or sys.stdin.isatty()):
146 146
        logger.ToStderr("Waiting for '%s' lock from pid %d..." % (name, pid))
147 147

  
......
596 596
  """
597 597
  for word in args:
598 598
    if not IsValidShellParam(word):
599
      raise errors.ProgrammerError, ("Shell argument '%s' contains"
600
                                     " invalid characters" % word)
599
      raise errors.ProgrammerError("Shell argument '%s' contains"
600
                                   " invalid characters" % word)
601 601
  return template % args
602 602

  
603 603

  
......
626 626
  """
627 627
  m = re.match('^([.\d]+)\s*([a-zA-Z]+)?$', input_string)
628 628
  if not m:
629
    raise errors.UnitParseError, ("Invalid format")
629
    raise errors.UnitParseError("Invalid format")
630 630

  
631 631
  value = float(m.groups()[0])
632 632

  
......
647 647
    value *= 1024 * 1024
648 648

  
649 649
  else:
650
    raise errors.UnitParseError, ("Unknown unit: %s" % unit)
650
    raise errors.UnitParseError("Unknown unit: %s" % unit)
651 651

  
652 652
  # Make sure we round up
653 653
  if int(value) < value:
......
722 722

  
723 723
  """
724 724
  if not os.path.isfile(file_name):
725
    raise errors.ProgrammerError, ("Can't make a backup of a non-file '%s'" %
726
                                   file_name)
725
    raise errors.ProgrammerError("Can't make a backup of a non-file '%s'" %
726
                                file_name)
727 727

  
728 728
  # Warning: the following code contains a race condition when we create more
729 729
  # than one backup of the same file in a second.
......
734 734

  
735 735
def ShellQuote(value):
736 736
  """Quotes shell argument according to POSIX.
737
  
737

  
738 738
  """
739 739
  if _re_shell_unquoted.match(value):
740 740
    return value

Also available in: Unified diff