~tr3buchet/nova/lock

« back to all changes in this revision

Viewing changes to nova/utils.py

  • Committer: Vishvananda Ishaya
  • Date: 2010-12-22 20:59:53 UTC
  • mto: This revision was merged to the branch mainline in revision 482.
  • Revision ID: vishvananda@gmail.com-20101222205953-j2j5t0qjwlcd0t2s
merge trunk and upgrade to cheetah templating

Show diffs side-by-side

added added

removed removed

Lines of Context:
50
50
        __import__(mod_str)
51
51
        return getattr(sys.modules[mod_str], class_str)
52
52
    except (ImportError, ValueError, AttributeError):
53
 
        raise exception.NotFound('Class %s cannot be found' % class_str)
 
53
        raise exception.NotFound(_('Class %s cannot be found') % class_str)
54
54
 
55
55
 
56
56
def import_object(import_str):
64
64
 
65
65
 
66
66
def fetchfile(url, target):
67
 
    logging.debug("Fetching %s" % url)
 
67
    logging.debug(_("Fetching %s") % url)
68
68
#    c = pycurl.Curl()
69
69
#    fp = open(target, "wb")
70
70
#    c.setopt(c.URL, url)
76
76
 
77
77
 
78
78
def execute(cmd, process_input=None, addl_env=None, check_exit_code=True):
79
 
    logging.debug("Running cmd (subprocess): %s", cmd)
 
79
    logging.debug(_("Running cmd (subprocess): %s"), cmd)
80
80
    env = os.environ.copy()
81
81
    if addl_env:
82
82
        env.update(addl_env)
89
89
        result = obj.communicate()
90
90
    obj.stdin.close()
91
91
    if obj.returncode:
92
 
        logging.debug("Result was %s" % (obj.returncode))
 
92
        logging.debug(_("Result was %s") % (obj.returncode))
93
93
        if check_exit_code and obj.returncode != 0:
94
94
            (stdout, stderr) = result
95
95
            raise ProcessExecutionError(exit_code=obj.returncode,
127
127
 
128
128
 
129
129
def runthis(prompt, cmd, check_exit_code=True):
130
 
    logging.debug("Running %s" % (cmd))
 
130
    logging.debug(_("Running %s") % (cmd))
131
131
    rv, err = execute(cmd, check_exit_code=check_exit_code)
132
132
 
133
133
 
160
160
        csock.close()
161
161
        return addr
162
162
    except socket.gaierror as ex:
163
 
        logging.warn("Couldn't get IP, using 127.0.0.1 %s", ex)
 
163
        logging.warn(_("Couldn't get IP, using 127.0.0.1 %s"), ex)
164
164
        return "127.0.0.1"
165
165
 
166
166
 
204
204
        if not self.__backend:
205
205
            backend_name = self.__pivot.value
206
206
            if backend_name not in self.__backends:
207
 
                raise exception.Error('Invalid backend: %s' % backend_name)
 
207
                raise exception.Error(_('Invalid backend: %s') % backend_name)
208
208
 
209
209
            backend = self.__backends[backend_name]
210
210
            if type(backend) == type(tuple()):