~evarlast/cloud-init/cloud-init

« back to all changes in this revision

Viewing changes to cloudinit/future_util.py

  • Committer: Scott Moser
  • Author(s): Ben Howard
  • Date: 2013-10-16 13:17:35 UTC
  • Revision ID: smoser@ubuntu.com-20131016131735-vdw2gflvhzfkxh01
Tags: 0.6.3-0ubuntu1.8
* debian/patches/lp-1233315-add-smartos-support.patch:
  Add SmartOS DataSource, including disk format support (LP: #1233315).
* debian/patches/lp-1231490-azure-ephemeral-format.patch:
  Format Windows Azure ephemeral disks (LP: #1231490)
* debian/patches/lp-1233315-1231490-ephmeralX.Y-support.patch:
  Add support for referencing ephemeral devices as 'ephemeralX.Y
  (LP: #1231490, LP: #1233315)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
import logging
 
2
import os.path
2
3
import subprocess
 
4
import types
3
5
 
4
6
LOG = logging.getLogger(__name__)
5
7
 
116
118
            'reason': self.reason,
117
119
        }
118
120
        IOError.__init__(self, message)
 
121
 
 
122
 
 
123
def which(program):
 
124
    # Return path of program for execution if found in path
 
125
    def is_exe(fpath):
 
126
        return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
 
127
 
 
128
    _fpath, _ = os.path.split(program)
 
129
    if _fpath:
 
130
        if is_exe(program):
 
131
            return program
 
132
    else:
 
133
        for path in os.environ["PATH"].split(os.pathsep):
 
134
            path = path.strip('"')
 
135
            exe_file = os.path.join(path, program)
 
136
            if is_exe(exe_file):
 
137
                return exe_file
 
138
 
 
139
    return None
 
140
 
 
141
 
 
142
def expand_dotted_devname(dotted):
 
143
    toks = dotted.rsplit(".", 1)
 
144
    if len(toks) > 1:
 
145
        return toks
 
146
    else:
 
147
        return (dotted, None)
 
148
 
 
149
 
 
150
def type_utils_obj_name(obj):
 
151
    if isinstance(obj, (types.TypeType,
 
152
                        types.ModuleType,
 
153
                        types.FunctionType,
 
154
                        types.LambdaType)):
 
155
        return str(obj.__name__)