コード例 #1
0
ファイル: Role.py プロジェクト: bloveing/openulteo
	def updateApplications(self):
		try:
			appsdetect = ApplicationsDetection()
		except:
			Logger.warn("Bug #3: Unable to access to registry in the same time a user access to a session")
			appsdetect = None
			for i in xrange(3):
				try:
				  	appsdetect = ApplicationsDetection()
				  	break
				except:
					pass
			
			if appsdetect is None:
				Logger.info("Unsuccefully build ApplicationDetection object in 4 times")
				return
		
		applications = appsdetect.get()
		if self.main_instance.ulteo_system:
			appsdetect.getDebianPackage(applications)
		
		known_ids = []
		
		self.applications_mutex.acquire()
		
		for id_, application in applications.items():
			known_ids.append(id_)
			
			if self.applications.has_key(id_):
				if self.applications[id_] == application:
					continue
			
			self.applications[id_] = application
		
		for id_ in self.applications.keys():
			if id_ in known_ids:
				continue
			
			del(self.applications[id_])
		self.applications_mutex.release()
コード例 #2
0
ファイル: Dialog.py プロジェクト: bacgroup/ovd_sources
	def req_icon(self, app_id):
		if self.role_instance.applications is None:
			return self.req_unauthorized()
		
		self.role_instance.applications_mutex.acquire()
		
		if not self.role_instance.applications_id_SM.has_key(app_id):
			self.role_instance.applications_mutex.release()
			return self.req_unauthorized()
		
		app =  self.role_instance.applications_id_SM[app_id]
		
		self.role_instance.applications_mutex.release()
		
		appsdetect = ApplicationsDetection()
		data = appsdetect.getIcon(app["filename"])
		if data is None:
			return self.req_not_found()
		
		response = {}
		response["code"] = httplib.OK
		response["Content-Type"] = "image/png"
		response["data"] = data
		return response
コード例 #3
0
    def cleanupShortcut(self, path):
        if self.mode != Session.MODE_DESKTOP:
            return

        shortcut_ext = ApplicationsDetection.shortcut_ext

        if not os.path.exists(path):
            return

        try:
            contents = os.listdir(path)
        except Exception:
            Logger.exception("Unable to list content of the directory %s" %
                             path)
            return

        for content in contents:
            target = None
            l = os.path.join(path, content)
            if not os.path.isfile(l):
                continue

            if not os.path.splitext(l)[1] == shortcut_ext:
                continue

            try:
                target = ApplicationsDetection.getExec(l)
            except Exception:
                Logger.exception("Unable to get the desktop target of %s" % l)
                target = None

            if target is None:
                continue

            for app in self.Ulteo_apps:
                if app.lower() in target.lower():
                    Logger.debug("removing shortcut %s" % (target))
                    try:
                        os.remove(l)
                    except Exception:
                        Logger.exception(
                            "Unable to delete the desktop target %s" % l)
コード例 #4
0
ファイル: Role.py プロジェクト: bacgroup/ovd_sources
    def updateApplications(self):
        try:
            appsdetect = ApplicationsDetection()
        except:
            Logger.warn(
                "Bug #3: Unable to access to registry in the same time a user access to a session"
            )
            appsdetect = None
            for i in xrange(3):
                try:
                    appsdetect = ApplicationsDetection()
                    break
                except:
                    pass

            if appsdetect is None:
                Logger.info(
                    "Unsuccefully build ApplicationDetection object in 4 times"
                )
                return

        applications = appsdetect.get()
        if self.main_instance.ulteo_system:
            appsdetect.getDebianPackage(applications)

        known_ids = []

        self.applications_mutex.acquire()

        for id_, application in applications.items():
            known_ids.append(id_)

            if self.applications.has_key(id_):
                if self.applications[id_] == application:
                    continue

            self.applications[id_] = application

        for id_ in self.applications.keys():
            if id_ in known_ids:
                continue

            del (self.applications[id_])
        self.applications_mutex.release()
コード例 #5
0
ファイル: Session.py プロジェクト: bloveing/openulteo
	def cleanupShortcut(self, path):
		if self.mode != Session.MODE_DESKTOP:
			return
		
		shortcut_ext = ApplicationsDetection.shortcut_ext
		
		if not os.path.exists(path):
			return
		
		try:
			contents = os.listdir(path)
		except Exception:
			Logger.exception("Unable to list content of the directory %s"%path)
			return
		
		for content in contents:
			target = None
			l = os.path.join(path, content)
			if not os.path.isfile(l):
				continue
			
			if not os.path.splitext(l)[1] == shortcut_ext:
				continue
			
			try:
				target = ApplicationsDetection.getExec(l)
			except Exception:
				Logger.exception("Unable to get the desktop target of %s"%l)
				target = None
			
			if target is None:
				continue
			
			for app in self.Ulteo_apps:
				if app.lower() in target.lower():
					Logger.debug("removing shortcut %s"%(target))
					try:
						os.remove(l)
					except Exception:
						Logger.exception("Unable to delete the desktop target %s"%l)
コード例 #6
0
class Session:
    Ulteo_apps = ["startovdapp", "UlteoOVDIntegratedLauncher"]

    SESSION_STATUS_UNKNOWN = "unknown"
    SESSION_STATUS_ERROR = "error"
    SESSION_STATUS_INIT = "init"
    SESSION_STATUS_INITED = "ready"
    SESSION_STATUS_ACTIVE = "logged"
    SESSION_STATUS_INACTIVE = "disconnected"
    SESSION_STATUS_WAIT_DESTROY = "wait_destroy"
    SESSION_STATUS_DESTROYED = "destroyed"

    SESSION_END_STATUS_NORMAL = "logout"
    SESSION_END_STATUS_SHUTDOWN = "shutdown"
    SESSION_END_STATUS_ERROR = "internal"

    MODE_DESKTOP = "desktop"
    MODE_APPLICATIONS = "applications"

    def __init__(self, id_, mode_, user_, parameters_, applications_):
        self.id = id_
        self.user = user_
        self.mode = mode_
        self.parameters = parameters_
        self.profile = None
        self.applications = applications_
        self.instanceDirectory = None
        self.used_applications = {}
        self.shellNode = None

        self.end_status = None
        self.user_session_dir = None
        self.locked = False

        self.domain = None

        self.log = SessionLogger()
        self.switch_status(Session.SESSION_STATUS_INIT)

    def init(self):
        raise NotImplementedError()

    def init_user_session_dir(self, user_session_dir):
        self.user_session_dir = user_session_dir
        if os.path.isdir(self.user_session_dir):
            System.DeleteDirectory(self.user_session_dir)

        try:
            os.makedirs(self.user_session_dir)
        except WindowsError, e:
            if e[0] == 183:  # The directory already exist
                Logger.debug("The directory %s already exist" %
                             (self.user_session_dir))

        self.instanceDirectory = os.path.join(self.user_session_dir,
                                              "instances")
        self.matchingDirectory = os.path.join(self.user_session_dir,
                                              "matching")
        self.shortcutDirectory = os.path.join(self.user_session_dir,
                                              "shortcuts")

        os.mkdir(self.instanceDirectory)
        os.mkdir(self.matchingDirectory)
        os.mkdir(self.shortcutDirectory)

        for application in self.applications:
            cmd = ApplicationsDetection.getExec(application["filename"])
            if cmd is None:
                Logger.error(
                    "Session::install_client unable to extract command from app_id %s (%s)"
                    % (application["id"], application["filename"]))
                continue

            f = file(os.path.join(self.matchingDirectory, application["id"]),
                     "w")
            f.write(cmd)
            f.close()

        if self.shellNode is not None:
            # Push the OvdShell configuration
            self.shellNode.setAttribute("sm", Config.session_manager)

            scriptsNodes = self.shellNode.getElementsByTagName("script")
            script2start_dir = os.path.join(self.user_session_dir, 'scripts')
            scripts_aps = os.path.join(Config.spool_dir, "scripts")
            os.mkdir(script2start_dir)

            for node in scriptsNodes:
                scriptID = node.getAttribute("id")
                scriptName = node.getAttribute("name")
                scriptType = node.getAttribute("type")
                scriptExt = Scripts.type2ext(scriptType)
                node.setAttribute("name", scriptName + "." + scriptExt)
                apsname = os.path.join(scripts_aps, scriptID + "." + scriptExt)
                sessionname = os.path.join(script2start_dir,
                                           scriptName + "." + scriptExt)
                if os.path.isfile(apsname):
                    shutil.copy(apsname, sessionname)

            f = open(os.path.join(self.user_session_dir, "shell.conf"), "w")
            f.write(self.shellNode.toprettyxml())
            f.close()