当前位置: 首页>>代码示例>>Python>>正文


Python System.System类代码示例

本文整理汇总了Python中ovd.Platform.System.System的典型用法代码示例。如果您正苦于以下问题:Python System类的具体用法?Python System怎么用?Python System使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了System类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: copyDirOverride

def copyDirOverride(src, dst, exception=None):
	src = System.local_encode(src)
	dst = System.local_encode(dst)
	if not os.path.isdir(src):
		return
	
	if exception is None:
		exception = []
	
	try:
		attr = win32file.GetFileAttributes(src)
		if attr & FILE_ATTRIBUTE_SYSTEM and attr & FILE_ATTRIBUTE_REPARSE_POINT:
			return 
		win32file.SetFileAttributes(dst, attr)
	except:
		#print "Unable to setAttribute of",dst
		pass
	
	if not os.path.isdir(dst):
		os.makedirs(dst)

	dirs = None
	try:
		dirs = os.listdir(src)
	except Exception, err:
		return
开发者ID:Oyatsumi,项目名称:ulteo4Kode4kids,代码行数:26,代码来源:Util.py

示例2: check_remaining_mount_points

	def check_remaining_mount_points(self):
		try:
			user = pwd.getpwnam(System.local_encode(self.name))
		except KeyError:
			return False
		
		mount_points = MountPoint.get_list(user.pw_dir)
		if mount_points is None:
			return False
		
		success = True
		for d in mount_points:
			path = System.local_encode(d)
			Logger.warn("Remaining mount point '%s'"%(path))
			cmd = 'umount "%s"'%(path)
			
			p = System.execute(cmd)
			if p.returncode == 0:
				continue
			
			Logger.warn("Unable to unmount remaining mount point %s: force the unmount"%(path))
			Logger.debug('umount command "%s" return: %s'%(cmd,  p.stdout.read()))
			cmd = 'umount -l "%s"'%(path)
			p = System.execute(cmd)
			if p.returncode != 0:
				Logger.error("Unable to force the unmount remaining mount point %s"%(path))
				Logger.debug('umount command "%s" return: %s'%(cmd,  p.stdout.read()))
			
			success = False
		
		if success == False:
			Logger.error("Unable to unmount remaining mount point, home dir %s won't be purged"%(user.pw_dir))
		
		return success
开发者ID:bloveing,项目名称:openulteo,代码行数:34,代码来源:User.py

示例3: destroy

	def destroy(self):
		ret = True
		
		cmd = 'htpasswd -D %s "%s"'%(Config.dav_passwd_file, self.login)
		p = System.execute(cmd)
		if p.returncode != 0:
			Logger.error("FS: unable to update apache auth file")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			return False
		
		cmd = 'smbpasswd -x %s'%(self.login)
		p = System.execute(cmd)
		if p.returncode != 0:
			Logger.error("FS: unable to del smb password")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			ret = False
		
		cmd = "userdel -f %s"%(self.login)
		p = System.execute(cmd)
		if p.returncode != 0:
			Logger.error("FS: unable to del user")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			ret = False
		
		return ret
开发者ID:bloveing,项目名称:openulteo,代码行数:25,代码来源:User.py

示例4: copySessionStart

    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())
            )
开发者ID:bloveing,项目名称:openulteo,代码行数:26,代码来源:Profile.py

示例5: destroy

	def destroy(self):
		lock = FileLock("/tmp/user.lock")
		
		arg_remove = ""
		if self.check_remaining_mount_points():
			arg_remove = "--remove"
		
		cmd = "userdel --force %s %s"%(arg_remove, System.local_encode(self.name))
		
		retry = 5
		while retry !=0:
			lock.acquire()
			p = System.execute(cmd)
			lock.release()
			if p.returncode == 0:
				return True
			if p.returncode == 12:
				Logger.debug("mail dir error: '%s' return %d => %s"%(str(cmd), p.returncode, p.stdout.read()))
				return True
			
			Logger.debug("User delete of %s: retry %i"%(self.name, 6-retry))
			if p.returncode == 1 or p.returncode == 10: # an other process is creating a user
				Logger.debug("An other process is creating a user")
				retry -=1
				time.sleep(0.2)
				continue
			if p.returncode != 0:
				Logger.error("userdel return %d (%s)"%(p.returncode, p.stdout.read()))
				return False
		
		return True
开发者ID:bloveing,项目名称:openulteo,代码行数:31,代码来源:User.py

示例6: perform

	def perform(self):
		os.mkdir(self.directory)
		f_stdout = open(os.path.join(self.directory, "stdout"), "w")
		f_stderr = open(os.path.join(self.directory, "stderr"), "w")
		process_out = {"stdout": f_stdout, "stderr": f_stderr}
		
		p = System.execute(["apt-get", "update"], True, {}, process_out)
		if p.returncode != 0:
			f_stdout.close()
			f_stderr.close()
			return False
		
		apt_env = {"DEBIAN_FRONTEND": "noninteractive", "DEBIAN_PRIORITY": "critical", "DEBCONF_NONINTERACTIVE_SEEN": "true"}
		command = ["apt-get", "--yes", "--force-yes", "--option", "DPkg::Options::=--force-confold"]
		if self.order == "upgrade":
			command.append("dist-upgrade")
		elif self.order == "install":
			command.append("install")
		elif self.order == "remove":
			command.append("autoremove")
			command.append("--purge")
		
		if self.order in ["install", "remove"]:
			command.extend(self.packages)
		
		p = System.execute(command, True, apt_env, process_out)
		if p.returncode != 0:
			f_stdout.close()
			f_stderr.close()
			return False
		
		f_stdout.close()
		f_stderr.close()
		return True
开发者ID:bloveing,项目名称:openulteo,代码行数:34,代码来源:Apt.py

示例7: purgeGroup

	def purgeGroup(self):
		users = System.groupMember(Config.group)
		if users is None:
			return False
		
		ret = True
		for user in users:
			if user == Config.dav_user:
				continue
			
			Logger.debug("FileServer:: deleting user '%s'"%(user))
			
			u = User(user)
			u.clean()
			if u.existSomeWhere():
				Logger.error("FS: unable to del user %s"%(user))
				ret =  False
		
		htgroup = HTGroup(Config.dav_group_file)
		htgroup.purge()
		
		try:
			groups = [g.gr_name for g in grp.getgrall() if g.gr_name.startswith("ovd_share_")]
			for g in groups:
				System.groupDelete(g)
                except Exception:
                        Logger.exception("Failed to purge groups")
           		ret = False
		
		return ret
开发者ID:bloveing,项目名称:openulteo,代码行数:30,代码来源:Role.py

示例8: req_server_conf

	def req_server_conf(self, request):
		cpuInfos = System.getCPUInfos()
		ram_total = System.getRAMTotal()
		
		doc = Document()
		rootNode = doc.createElement('configuration')
		
		rootNode.setAttribute("type", System.getName())
		rootNode.setAttribute("version", System.getVersion())
		rootNode.setAttribute("ram", str(ram_total))
		rootNode.setAttribute("ulteo_system", str(self.server.ulteo_system).lower())
		
		cpuNode = doc.createElement('cpu')
		cpuNode.setAttribute('nb_cores', str(cpuInfos[0]))
		textNode = doc.createTextNode(cpuInfos[1])
		cpuNode.appendChild(textNode)
		
		rootNode.appendChild(cpuNode)
		
		for role,dialog in self.server.role_dialogs:
			roleNode = doc.createElement('role')
			roleNode.setAttribute('name', dialog.getName())
			rootNode.appendChild(roleNode)
		
		doc.appendChild(rootNode)
		return self.req_answer(doc)
开发者ID:bloveing,项目名称:openulteo,代码行数:26,代码来源:Dialog.py

示例9: main

	def main(self):
		self.synchronizer.restore()
		Logger._instance.setQueue(self.logging_queue, False)
		
		System.prepareForSessionActions()
		
		# Prevent the process to be stop by a keyboard interruption
		signal.signal(signal.SIGINT, signal.SIG_IGN)
		signal.signal(signal.SIGTERM, signal.SIG_IGN)
		
		Logger.debug("Starting SessionManager process")
		while True:
			self.current_session_id.value = ""
			try:
				(request, obj) = self.queue2.get_nowait()
			except Queue.Empty:
				try:
					(request, obj) = self.queue.get(True, 4)
				except Queue.Empty, e:
					continue
				except IOError, e:
					if e.errno == 4:
						break
					else:
						raise e
开发者ID:bloveing,项目名称:openulteo,代码行数:25,代码来源:SessionManagement.py

示例10: create

	def create(self, password):
		cmd = "useradd -d /dev/null -s /bin/false -G %s,%s %s"%(Config.group, "sambashare", self.login)
		p = System.execute(cmd)
		if p.returncode == 9:
			Logger.warn("FS: unable to create user: already exists")
			return False
		elif p.returncode != 0:
			Logger.error("FS: unable to create user")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			return False
		
		cmd = 'smbpasswd -s -a %s'%(self.login)
		p = System.execute(cmd, wait = False)
		p.stdin.write("%s\n%s\n"%(password, password))
		p.wait()
		
		if p.returncode != 0:
			Logger.error("FS: unable to set samba password")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			return False
		
		cmd = 'htpasswd -b %s "%s" "%s"'%(Config.dav_passwd_file, self.login, password)
		p = System.execute(cmd)
		if p.returncode != 0:
			Logger.error("FS: unable to update apache auth file")
			Logger.debug("FS: command '%s' return %d: %s"%(cmd, p.returncode, p.stdout.read().decode("UTF-8")))
			return False
		
		return True
开发者ID:bloveing,项目名称:openulteo,代码行数:29,代码来源:User.py

示例11: install_client

	def install_client(self):
		name = System.local_encode(self.user.name)
		
		d = os.path.join(self.SPOOL_USER, self.user.name)
		self.init_user_session_dir(d)
		self.install_desktop_shortcuts()
		
		os.chown(self.instanceDirectory, pwd.getpwnam(name)[2], -1)
		os.chown(self.user_session_dir, pwd.getpwnam(name)[2], -1)
		
		xdg_dir = os.path.join(d, "xdg")
		xdg_app_d = os.path.join(xdg_dir, "applications")
		if not os.path.isdir(xdg_app_d):
			os.makedirs(xdg_app_d)
		
		for p in ["icons", "pixmaps", "mime", "themes"]:
			src_dir = os.path.join("/usr/share/", p)
			dst_dir =  os.path.join(xdg_dir, p)
			
			os.symlink(src_dir, dst_dir)
		
		
		os.system('update-desktop-database "%s"'%(System.local_encode(xdg_app_d)))
	
		if self.parameters.has_key("desktop_icons") and self.parameters["desktop_icons"] == "1":
			path = os.path.join(xdg_app_d, ".show_on_desktop")
			f = file(path, "w")
			f.close()
		
		
		env_file_lines = []
		# Set the language
		if self.parameters.has_key("locale"):
			env_file_lines.append("LANG=%s.UTF-8\n"%(self.parameters["locale"]))
			env_file_lines.append("LC_ALL=%s.UTF-8\n"%(self.parameters["locale"]))
			env_file_lines.append("LANGUAGE=%s.UTF-8\n"%(self.parameters["locale"]))
		
		if self.parameters.has_key("timezone"):
			tz_file = "/usr/share/zoneinfo/" + self.parameters["timezone"]
			if not os.path.exists(tz_file):
				Logger.warn("Unsupported timezone '%s'"%(self.parameters["timezone"]))
				Logger.debug("Unsupported timezone '%s'. File '%s' does not exists"%(self.parameters["timezone"], tz_file))
			else:
				env_file_lines.append("TZ=%s\n"%(tz_file))
		
		f = file(os.path.join(d, "env"), "w")
		f.writelines(env_file_lines)
		f.close()
		
		if self.profile is not None:
			self.profile.mount()
			
			shares_dir = os.path.join(d, "shares")
			if not os.path.isdir(shares_dir):
				os.makedirs(shares_dir)
			
			self.profile.register_shares(shares_dir)
		
		return True
开发者ID:Oyatsumi,项目名称:ulteo4Kode4kids,代码行数:59,代码来源:Session.py

示例12: create

	def create(self):
		lock = FileLock("/tmp/user.lock")
		
		# TODO get the default home in /etc/default/useradd
		default_home_dir = os.path.join(u"/home", self.name)
		home_dir = default_home_dir
		i = 0
		while os.path.exists(home_dir) and i < 100:
			home_dir = default_home_dir+"_%d"%(i)
			i+= 1

		if i > 0:
			Logger.warn("Unable to create home directory %s, the home is now %s"%(default_home_dir, home_dir))

		if os.path.exists(home_dir):
			Logger.error("Unable to find a valid home directory")
			return False
		
		cmd = u"useradd -m -d '%s' -k '%s'"%(home_dir, Config.linux_skel_directory)
		if self.infos.has_key("displayName"):
			cmd+= u""" --comment "%s,,," """%(self.infos["displayName"].replace('"', ""))
		
		groups = ["video", "audio", "pulse", "pulse-access", Config.linux_fuse_group]
		if self.infos.has_key("groups"):
			groups+= self.infos["groups"]
		cmd+= u" --groups %s"%(",".join(groups))
		
		cmd+= u" "+self.name
		
		retry = 5
		while retry !=0:
			if retry < 0:
				  Logger.error("ERROR: unable to add a new user")
			lock.acquire()
			p = System.execute(System.local_encode(cmd))
			lock.release()
			if p.returncode == 0:
				break
			
			Logger.debug("Add user :retry %i"%(6-retry))
			if p.returncode == 9: # user already exist
				Logger.error("User %s already exist"%(self.name))
				break;
			if p.returncode == 1: # an other process is creating a user
				Logger.error("An other process is creating a user")
				retry -=1
				time.sleep(0.2)
				continue
			if p.returncode != 0:
				Logger.error("UserAdd return %d (%s)"%(p.returncode, p.stdout.read()))
				return False
		
		
		if self.infos.has_key("password"):
			if not self.set_password():
				return False
		
		return self.post_create()
开发者ID:bloveing,项目名称:openulteo,代码行数:58,代码来源:User.py

示例13: do_right_normalization

	def do_right_normalization(self):
		cmd = 'chown -R %s:%s "%s"'%(Config.uid, Config.gid, self.directory)
		p = System.execute(cmd)
		if p.returncode is not 0:
			Logger.debug("FS: following command '%s' returned %d => %s"%(cmd, p.returncode, p.stdout.read()))
		
		cmd = 'chmod -R u=rwX,g=rwX,o-rwx "%s"'%(self.directory)
		p = System.execute(cmd)
		if p.returncode is not 0:
			Logger.debug("FS: following command '%s' returned %d => %s"%(cmd, p.returncode, p.stdout.read()))
开发者ID:bloveing,项目名称:openulteo,代码行数:10,代码来源:Share.py

示例14: tuneGroups

	def tuneGroups(self, username, groups):
		if groups is None or len(groups) == 0:
			return False
		
		groupString = ','.join(groups)
		cmd = u"usermod -G %s %s"%(groupString, username)
		p = System.execute(System.local_encode(cmd))
		if p.returncode != 0:
			Logger.error("UserAdd return %d (%s)"%(p.returncode, p.stdout.read()))
			return False
		
		return True
开发者ID:bloveing,项目名称:openulteo,代码行数:12,代码来源:DomainMicrosoft.py

示例15: cleanup_repository

	def cleanup_repository(self):
		cmd = 'chown -R %s:%s "%s"'%(Config.uid, Config.gid, Config.backendSpool)
		p = System.execute(cmd)
		if p.returncode is not 0:
			Logger.debug("FS: following command '%s' returned %d => %s"%(cmd, p.returncode, p.stdout.read()))
			return False
		
		cmd = 'chmod -R u=rwX,g=rwX,o-rwx "%s"'%(Config.backendSpool)
		p = System.execute(cmd)
		if p.returncode is not 0:
			Logger.debug("FS: following command '%s' returned %d => %s"%(cmd, p.returncode, p.stdout.read()))
			return False
		
		return True
开发者ID:bloveing,项目名称:openulteo,代码行数:14,代码来源:Role.py


注:本文中的ovd.Platform.System.System类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。