本文整理汇总了Python中ovd.Platform.System.System.rchown方法的典型用法代码示例。如果您正苦于以下问题:Python System.rchown方法的具体用法?Python System.rchown怎么用?Python System.rchown使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovd.Platform.System.System
的用法示例。
在下文中一共展示了System.rchown方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: copySessionStart
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import rchown [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: copySessionStart
# 需要导入模块: from ovd.Platform.System import System [as 别名]
# 或者: from ovd.Platform.System.System import rchown [as 别名]
def copySessionStart(self):
d = shell.SHGetFolderPath(0, shellcon.CSIDL_COMMON_APPDATA, 0, 0)
profile_tmp_dir = os.path.join(d, "ulteo", "profile", self.session.user.name)
profile_tmp_dir = System.local_encode(profile_tmp_dir)
profile_filter = System.local_encode(Config.profile_filters_filename)
for f in [self.DesktopDir, self.DocumentsDir]:
d = os.path.join(self.mountPoint, "Data", f)
trial = 5
while not os.path.exists(d):
try:
os.makedirs(d)
except OSError:
trial -= 1
if trial == 0:
Logger.exception("Failed to create directory %s"%d)
return False
time.sleep(random.randint(1,10)/100.0)
Logger.debug2("Profile mkdir failed (concurrent access because of more than one ApS)")
continue
d = os.path.join(self.mountPoint, "conf.Windows.%s"%System.getWindowsVersionName())
if os.path.exists(d):
# clean temporary file used by windows to load registry
dirs = None
try:
dirs = os.listdir(d)
except Exception:
Logger.exception("Unable to list content of the directory %s"%d)
return
for content in dirs:
if content.startswith(r"NTUSER.DAT.LOG") or content.startswith(r"NTUSER.DAT{"):
try :
path = os.path.join(d, content)
os.remove(path)
except Exception:
Logger.exception("Unable to delete %s"%path)
# Copy user registry
src = os.path.join(d, "NTUSER.DAT")
if os.path.exists(src):
dst = os.path.join(self.session.windowsProfileDir, "NTUSER.DAT")
rand = random.randrange(10000, 50000)
hiveName_src = "OVD_%s_%d"%(str(self.session.id), rand)
win32api.RegLoadKey(win32con.HKEY_USERS, hiveName_src, src)
hiveName_dst = "OVD_%s_%d"%(str(self.session.id), rand+1)
win32api.RegLoadKey(win32con.HKEY_USERS, hiveName_dst, dst)
hkey_src = win32api.RegOpenKey(win32con.HKEY_USERS, r"%s"%(hiveName_src), 0, win32con.KEY_ALL_ACCESS)
hkey_dst = win32api.RegOpenKey(win32con.HKEY_USERS, r"%s"%(hiveName_dst), 0, win32con.KEY_ALL_ACCESS)
Reg.CopyTree(hkey_src, "Software", hkey_dst, self.registry_copy_blacklist)
win32api.RegCloseKey(hkey_src)
win32api.RegCloseKey(hkey_dst)
win32api.RegUnLoadKey(win32con.HKEY_USERS, hiveName_src)
win32api.RegUnLoadKey(win32con.HKEY_USERS, hiveName_dst)
# Copy configuration File
if self.profile['profile_mode'] == 'standard':
cmd = self.getRsyncMethod(Profile.toCygPath(d), Profile.toCygPath(profile_tmp_dir), Profile.toCygPath(profile_filter))
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()))
if os.path.exists(profile_tmp_dir):
System.rchown(profile_tmp_dir, self.session.user.name)