Exemplo n.º 1
0
    def updateApplications(self):
        try:
            appsdetect = RolePlatform.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 = RolePlatform.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()
Exemplo n.º 2
0
	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 = Platform.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