本文整理汇总了Python中ovd.Platform.System.System.mount_point_exist方法的典型用法代码示例。如果您正苦于以下问题:Python System.mount_point_exist方法的具体用法?Python System.mount_point_exist怎么用?Python System.mount_point_exist使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovd.Platform.System.System
的用法示例。
在下文中一共展示了System.mount_point_exist方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copySessionStart
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import mount_point_exist [as 别名]
def copySessionStart(self):
profile_tmp_dir = os.path.join(Profile.TEMPORARY_PROFILE_PATH, self.session.user.name)
if os.path.exists(profile_tmp_dir):
System.rchown(profile_tmp_dir, self.session.user.name)
if self.homeDir is None or not os.path.isdir(self.homeDir):
return
d = os.path.join(self.profile_mount_point, "conf.Linux")
if not System.mount_point_exist(d):
return
if self.profile["profile_mode"] == "advanced":
return
# Copy conf files
d = self.transformToLocaleEncoding(d)
cmd = self.getRsyncMethod(d, self.homeDir, Config.profile_filters_filename, True)
Logger.debug("rsync cmd '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode is not 0:
Logger.error("Unable to copy conf from profile")
Logger.debug(
"Unable to copy conf from profile, cmd '%s' return %d: %s" % (cmd, p.returncode, p.stdout.read())
)
示例2: mount_webdav
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import mount_point_exist [as 别名]
def mount_webdav(self, share, uri, dest):
davfs_conf = os.path.join(self.cifs_dst, "davfs.conf")
davfs_secret = os.path.join(self.cifs_dst, "davfs.secret")
if uri.scheme == "webdav":
mount_uri = urlparse.urlunparse(("http", uri.netloc, uri.path, uri.params, uri.query, uri.fragment))
else:
mount_uri = urlparse.urlunparse(("https", uri.netloc, uri.path, uri.params, uri.query, uri.fragment))
if not System.mount_point_exist(davfs_conf):
f = open(davfs_conf, "w")
f.write("ask_auth 0\n")
f.write("use_locks 0\n")
f.write("secrets %s\n" % (davfs_secret))
f.close()
if not System.mount_point_exist(davfs_secret):
f = open(davfs_secret, "w")
f.close()
os.chmod(davfs_secret, stat.S_IRUSR | stat.S_IWUSR)
if share.has_key("login") and share.has_key("password"):
f = open(davfs_secret, "a")
f.write("%s %s %s\n" % (mount_uri, share["login"], share["password"]))
f.close()
cmd = "mount -t davfs -o 'conf=%s,uid=%s,gid=0,%s' '%s' %s" % (
davfs_conf,
self.session.user.name,
self.DEFAULT_PERMISSION,
mount_uri,
dest,
)
cmd = self.transformToLocaleEncoding(cmd)
Logger.debug("Profile, sharedFolder mount command: '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode != 0:
Logger.debug("WebDAV mount failed (status: %d) => %s" % (p.returncode, p.stdout.read()))
return False
return True
示例3: copySessionStop
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import mount_point_exist [as 别名]
def copySessionStop(self):
if self.homeDir is None or not os.path.isdir(self.homeDir):
return
d = os.path.join(self.profile_mount_point, "conf.Linux")
trial = 5
while not System.mount_point_exist(d):
try:
os.makedirs(d)
except OSError, err:
if self.isNetworkError(err[0]):
Logger.exception("Unable to access profile")
return
trial -= 1
if trial == 0:
Logger.exception("Failed to create directory %s" % d)
return
time.sleep(random.randint(1, 10) / 100.0)
Logger.debug2("conf.Linux mkdir failed (concurrent access because of more than one ApS)")
continue
示例4: umount
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import mount_point_exist [as 别名]
def umount(self):
if self.profile is not None and self.profileMounted:
self.copySessionStop()
for sharedFolder in self.sharedFolders:
if sharedFolder.has_key("local_path"):
self.delGTKBookmark(sharedFolder["local_path"])
while len(self.folderRedirection) > 0:
d = self.folderRedirection.pop()
try:
if not self.ismount(d):
continue
except IOError:
Logger.exception("Unable to check mount point %s" % d)
cmd = 'umount "%s"' % (d)
Logger.debug("Profile bind dir command: '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode != 0:
Logger.error("Profile bind dir failed")
Logger.error("Profile bind dir failed (status: %d) %s" % (p.returncode, p.stdout.read()))
for sharedFolder in self.sharedFolders:
if sharedFolder.has_key("mountdest"):
cmd = """umount "%s" """ % (sharedFolder["mountdest"])
Logger.debug("Profile sharedFolder umount dir command: '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode != 0:
Logger.error("Profile sharedFolder umount dir failed")
Logger.error(
"Profile sharedFolder umount dir failed (status: %d) %s" % (p.returncode, p.stdout.read())
)
continue
try:
os.rmdir(sharedFolder["mountdest"])
except OSError:
Logger.exception("Unable to delete mount point (%s)" % sharedFolder["mountdest"])
for fname in ("davfs.conf", "davfs.secret"):
path = os.path.join(self.cifs_dst, fname)
if not System.mount_point_exist(path):
continue
try:
os.remove(path)
except OSError:
Logger.exception("Unable to delete file (%s)" % path)
if self.profile is not None and self.profileMounted:
cmd = "umount %s" % (self.profile_mount_point)
cmd = self.transformToLocaleEncoding(cmd)
Logger.debug("Profile umount command: '%s'" % (cmd))
for _ in xrange(5):
p = System.execute(cmd)
if p.returncode != 0:
time.sleep(1)
else:
break
if p.returncode != 0:
Logger.warn("Profile umount failed, force the unmount")
Logger.debug("Profile umount failed (status: %d) => %s" % (p.returncode, p.stdout.read()))
cmd = "umount -l %s" % (self.profile_mount_point)
cmd = self.transformToLocaleEncoding(cmd)
Logger.debug("Profile umount force command: '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode != 0:
Logger.error("Profile force umount failed")
Logger.debug("Profile force umount failed (status: %d) => %s" % (p.returncode, p.stdout.read()))
try:
os.rmdir(self.profile_mount_point)
except OSError:
Logger.exception("Unable to delete mount point (%s)" % self.profile_mount_point)
try:
os.rmdir(self.cifs_dst)
except OSError:
Logger.exception("Unable to delete profile (%s)" % self.cifs_dst)
示例5: mount
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import mount_point_exist [as 别名]
def mount(self):
os.makedirs(self.cifs_dst)
self.homeDir = pwd.getpwnam(self.transformToLocaleEncoding(self.session.user.name))[5]
if self.profile is not None:
os.makedirs(self.profile_mount_point)
u = urlparse.urlparse(self.profile["uri"])
if u.scheme == "cifs":
ret = self.mount_cifs(self.profile, u, self.profile_mount_point)
elif u.scheme in ("webdav", "webdavs"):
ret = self.mount_webdav(self.profile, u, self.profile_mount_point)
else:
Logger.warn("Profile: unknown protocol in share uri '%s'" % (self.profile["uri"]))
ret = False
if ret is False:
Logger.error("Profile mount failed")
os.rmdir(self.profile_mount_point)
return False
else:
self.profileMounted = True
if self.profile is not None and self.profileMounted:
for d in [self.DesktopDir, self.DocumentsDir]:
src = os.path.join(self.profile_mount_point, "Data", d)
src = self.transformToLocaleEncoding(src)
dst = os.path.join(self.homeDir, d)
trial = 5
while not System.mount_point_exist(src):
try:
os.makedirs(src)
except OSError, err:
if self.isNetworkError(err[0]):
Logger.exception("Unable to access profile")
return False
trial -= 1
if trial == 0:
Logger.exception("Failed to create directory %s" % (src))
return False
time.sleep(random.randint(1, 10) / 100.0)
Logger.debug2(
"Profile mkdir failed (concurrent access because of more than one ApS) => %s" % (str(err))
)
continue
if self.profile["profile_mode"] == "standard":
if not System.mount_point_exist(dst):
os.makedirs(dst)
cmd = 'mount -o bind "%s" "%s"' % (src, dst)
Logger.debug("Profile bind dir command '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode != 0:
Logger.error("Profile bind dir failed")
Logger.error("Profile bind dir failed (status: %d) %s" % (p.returncode, p.stdout.read()))
return False
else:
self.folderRedirection.append(dst)
if self.profile["profile_mode"] == "advanced":
cmd = 'RegularUnionFS "%s" "%s" -o user=%s' % (
self.transformToLocaleEncoding(self.profile_mount_point),
self.homeDir,
self.transformToLocaleEncoding(self.session.user.name),
)
Logger.debug("Profile bind dir command '%s'" % (cmd))
p = System.execute(cmd)
if p.returncode != 0:
Logger.error("Profile bind dir failed")
Logger.error("Profile bind dir failed (status: %d) %s" % (p.returncode, p.stdout.read()))
return False
else:
self.folderRedirection.append(self.homeDir)
self.copySessionStart()