def __init__(self, log): """ Initialize voyager model including all logic of the program. ** Arguments ** *log* log file """ Model.__init__(self) self.__log = log self.__status = self.STOPPED self.__currentRecording = None self.__recordings = {} self.__playbackVenueUrl = None homePath = None name = None if IsWindows(): from win32com.shell import shell, shellcon homePath = shell.SHGetFolderPath(0, shellcon.CSIDL_APPDATA, 0, 0) name = "Voyager" elif IsLinux(): homePath = os.environ["HOME"] name = ".Voyager" else: self.__log.debug("VoyagerModel.__init__: Voyager only supports windows and linux for now.") sys.exit(-1) if not homePath: self.__log.debug("VoyagerModel.__init__: Home path not found") sys.exit(-1) self.__path = os.path.join(homePath, name) self.__processManager = ProcessManager() if not os.path.exists(self.__path): os.mkdir(self.__path) self.__log.debug("VoyagerModel.__init__: Persistence path: %s" % (self.__path)) self.__LoadRecordings()
def __init__( self, appUrl, name): ''' Creates the shared application client, used for application service interaction, and opens the audience/moderatorView for UI display. ''' Model.__init__(self) self.allQuestions = [] # Create shared application client self.sharedAppClient = SharedAppClient(name) self.log = self.sharedAppClient.InitLogging() self.log.debug("SharedQuestionTool.__init__:Started shared question tool appUrl %s" %(appUrl)) # Get client profile try: clientProfileFile = os.path.join(UserConfig.instance().GetConfigDir(), "profile") self.clientProfile = ClientProfile(clientProfileFile) except: self.log.info("SharedQuestionTool.__init__: Could not load client profile, set clientProfile = None") self.clientProfile = None # Join the application session self.sharedAppClient.Join(appUrl, self.clientProfile) self.publicId = self.sharedAppClient.GetPublicId() # Register event callback self.sharedAppClient.RegisterEventCallback(self.SEND_QUESTION, self.SendQuestionCb) self.sharedAppClient.RegisterEventCallback(self.REMOVE_QUESTION, self.RemoveQuestionCb) # Get all questions currently stored in the application service clients = self.sharedAppClient.GetDataKeys() if clients: for clientId in clients: try: list = self.sharedAppClient.GetData(clientId) if len(list) > 0: qlist = self.__FromXML(list) for question in qlist: self.allQuestions.append(question) except: self.log.exception("SharedQuestionTool.__init__: Failed to get questions")