示例#1
0
def can_create_file(value, nochroot=False):
    value = parent_is_dir(value)

    path = get_real_path(value, nochroot)
    if os.path.isdir(path):
        raise ValueError, _('Path is a directory')

    return value
示例#2
0
def can_create_file (value, nochroot=False):
    value = parent_is_dir (value)

    path = get_real_path (value, nochroot)
    if os.path.isdir(path):
        raise ValueError, _('Path is a directory')

    return value
示例#3
0
def is_local_file_exists(value, nochroot=False):
    value = is_path(value)
    path = get_real_path(value, nochroot)

    if not os.path.exists(path):
        raise ValueError, _('Path does not exist')

    if not os.path.isfile(path):
        raise ValueError, _('Path is not a regular file')

    return value
示例#4
0
def is_local_dir_exists(value, nochroot=False):
    value = is_path(value)
    path = get_real_path(value, nochroot)

    if not os.path.exists(path):
        raise ValueError, _('Path does not exist')

    if not os.path.isdir(path):
        raise ValueError, _('Path is not a directory')

    return value
def is_local_file_exists (value, nochroot=False):
    value = is_path (value)
    path  = get_real_path (value, nochroot)

    if not os.path.exists(path):
        raise ValueError, _('Path does not exist')

    if not os.path.isfile(path):
        raise ValueError, _('Path is not a regular file')

    return value
def is_local_dir_exists (value, nochroot=False):
    value = is_path (value)
    path  = get_real_path (value, nochroot)

    if not os.path.exists(path):
        raise ValueError, _('Path does not exist')

    if not os.path.isdir(path):
        raise ValueError, _('Path is not a directory')

    return value
示例#7
0
文件: mpath_dmp.py 项目: thomasmck/sm
def _is_valid_multipath_device(sid):

    # Check if device is already multipathed
    (ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-ll', sid])
    if not stdout + stderr:
        (ret, stdout, stderr) = util.doexec(['/usr/sbin/multipath', '-a', sid])
        if ret == 1:
            util.SMlog("Failed to add {}: wwid could be explicitly "
                       "blacklisted\n Continue with multipath disabled for "
                       "this SR".format(sid))
            return False

        by_scsid_path = "/dev/disk/by-scsid/" + sid
        if os.path.exists(by_scsid_path):
            devs = os.listdir(by_scsid_path)
        else:
            util.SMlog(
                "Device {} is not ready yet, skipping multipath check".format(
                    by_scsid_path))
            return False
        ret = 1
        # Some paths might be down, check all associated devices
        for dev in devs:
            devpath = os.path.join(by_scsid_path, dev)
            real_path = util.get_real_path(devpath)
            (ret, stdout,
             stderr) = util.doexec(['/usr/sbin/multipath', '-c', real_path])
            if ret == 0:
                break

        if ret == 1:
            # This is very fragile but it is not a good sign to fail without
            # any output. At least until multipath 0.4.9, for example,
            # multipath -c fails without any log if it is able to retrieve the
            # wwid of the device.
            # In this case it is better to fail immediately.
            if not stdout + stderr:
                # Attempt to cleanup wwids file before raising
                try:
                    (ret, stdout,
                     stderr) = util.doexec(['/usr/sbin/multipath', '-w', sid])
                except OSError:
                    util.SMlog("Error removing {} from wwids file".format(sid))
                raise xs_errors.XenError(
                    'MultipathGenericFailure',
                    '"multipath -c" failed without any'
                    ' output on {}'.format(real_path))
            util.SMlog(
                "When dealing with {} multipath status returned:\n "
                "{}{} Continue with multipath disabled for this SR".format(
                    sid, stdout, stderr))
            return False
    return True
示例#8
0
 def preview(self):
     if not self.check_form():
         return False
     try:
         real_path = util.get_real_path(self.git_edit.text(),
                                        self.branch_edit.text(),
                                        self.base_edit.text())
     except Exception:
         msg_box = Qt.QMessageBox(Qt.QMessageBox.Warning, '警告',
                                  '预览出现异常,请检查输入参数')
         msg_box.exec_()
         return False
     self.real_edit.setText(real_path)
     return True
def setParent(path, parentPath, parentRaw):
    realPPath = util.get_real_path(parentPath)
    cmd = [VHD_UTIL, "modify", OPT_LOG_ERR, "-p", realPPath, "-n", path]
    if parentRaw:
        cmd.append("-m")
    ioretry(cmd)
示例#10
0
def setParent(path, parentPath, parentRaw):
    realPPath = util.get_real_path(parentPath)
    cmd = [VHD_UTIL, "modify", OPT_LOG_ERR, "-p", realPPath, "-n", path]
    if parentRaw:
        cmd.append("-m")
    ioretry(cmd)