Beispiel #1
0
 def _setSkinArtistBiografy(self, artist):
     common.debug("Collecting biography for artist: %s" % str(artist))
     biography = ''
     params = {}
     params['infodir'] = self.dir_cache
     params['lang'] = self.__BIOLANGUAGE
     params['artist'] = artist
     for key in self.PROVIDERS.keys():
         if self._isPlaybackChanged():
             common.debug(
                 "Cancel collecting biography due to the change of player content"
             )
             break
         common.trace('Collecting biography from provider: [%s]' % key)
         params['getall'] = common.setting(key + "_all")
         params['clientapikey'] = common.setting(key + "_apikey")
         content = self.PROVIDERS[key].getBiography(params)
         if content is not None and content and len(content) > len(
                 biography):
             common.trace('Stored new biography from provider [%s]' % key)
             biography = content
         if self._reload:
             self._reload = False
             common.debug(
                 "Cancel collecting biography due to the addon configuration update"
             )
             break
     self.setSkinProperty("SlideshowAddon.Biography", biography)
     common.trace("Biography setup is done")
Beispiel #2
0
def resizeLayout(event=[]):
	from common import setting

	LINEH = 17.0


	bf = 5 # buffer size in pixels
	bfo = 5 # for overriding a bf of 0

	pixelX=tk_root.winfo_width()
	pixelY=tk_root.winfo_height()
	
	# update user input
	inputW = 0
	if setting("MINIMAL_GUI"):
		inputW = pixelX
		bf = 0
	else:
		inputW = int(2.0*pixelX/3.0)
		

	inputH = int(3.0*LINEH)
	tk_user_input.place(x=bf, y=pixelY-inputH, width = inputW, height = inputH-bf)

	# update face
	faceW = 100
	faceH = 100
	tk_face.place(x=0, y=0, width=faceW, height=faceH)

	# update history
	histW = inputW
	histH = pixelY-inputH-faceH
	tk_history.place(x=bfo, y=faceH+bf, width = histW-bfo, height = histH-bf)

	# update top
	topW = histW- faceW - 100 - bfo
	topH = faceH
	tk_top.place(x=faceW, y=bfo, width = topW-bf, height = topH-bfo)


	
	if setting("MINIMAL_GUI"):
		tk_side.place_forget()
		#tk_CC.place_forget()

		# update concentric circles
		ccW = 100
		ccH = 100
		tk_CC.place(x=pixelX-100-bfo, y=0, width = ccW, height=ccH)

	else:
		# update side
		sideW = pixelX - histW
		sideH = pixelY-faceH
		tk_side.place(x=histW, y=faceH+bf, width = sideW-bf, height=sideH-bf)

		# update concentric circles
		ccW = 100
		ccH = 100
		tk_CC.place(x=pixelX-sideW/2-50, y=0, width = ccW, height=ccH)
Beispiel #3
0
 def _setSkinArtistImages(self, artist):
     common.debug("Collecting images for artist: %s" % str(artist))
     images = []
     params = {}
     kontor = 0
     params['lang'] = self.__BIOLANGUAGE
     params['artist'] = artist
     params['infodir'] = self.dir_cache
     params['exclusionsfile'] = os.path.join(self.dir_cache,
                                             "_exclusions.nfo")
     for key in self.PROVIDERS.keys():
         if self._isPlaybackChanged():
             common.debug(
                 "Cancel collecting images due to the change of player content"
             )
             return
         common.debug('Identifying images by provider: [%s]' % key)
         params['getall'] = common.setting(key + "_all")
         params['clientapikey'] = common.setting(key + "_apikey")
         content = self.PROVIDERS[key].getImageList(params)
         if content is not None and len(content) > 0:
             images.extend(content)
         if self._reload:
             self._reload = False
             common.debug(
                 "Cancel collecting images due to the addon configuration update"
             )
             break
     common.trace("Downloading images for artist [%s]" % str(artist))
     _, cachefiles = xbmcvfs.listdir(self.dir_cache)
     for url in images:
         if self._isPlaybackChanged():
             common.debug(
                 "Cancel downloading images due to the change of player content"
             )
             break
         common.trace('Checking image URL: %s' % url)
         cachepath = utilities.ItemHashWithPath(
             url, self.dir_cache) + utilities.ImageType(url)
         if os.path.split(
                 cachepath
         )[1] not in cachefiles and not xbmc.abortRequested and not self._isPlaybackChanged(
         ):
             common.trace('Downloading image file: %s' % cachepath)
             urldata = common.urlcall(url,
                                      output='binary',
                                      certver=self.__SSLCHECK)
             success = utilities.WriteFile(urldata,
                                           cachepath) if urldata else False
             if success and xbmcvfs.Stat(cachepath).st_size() < 999:
                 utilities.DeleteFile(cachepath)
             elif success:
                 kontor += 1
                 if (kontor % 5 == 0) or (kontor == 1 and len([
                         f for f in cachefiles
                         if os.path.splitext(f)[1] != ".nfo"
                 ]) == 0):
                     self._setSkinSlideshow(None, self.dir_cache)
     common.trace("Images setup is done")
Beispiel #4
0
 def _configurations(self):
     # get settings
     common.debug('Reading addon configuration')
     self.__BIOLANGUAGE = common.setting("biography_language")
     self.__RESTRICTCACHE = common.setting("restrict_cache")
     self.__MAXCACHESIZE = common.any2int(
         common.setting("max_cache_size")) * 1000000
     self.__SSLCHECK = common.any2bool(common.setting("ssl_check"))
     self.__NICE = common.any2int(common.setting("nice"), none=10)
Beispiel #5
0
def lookAnimation(direction="", holdLook=0.5, moveDt=0.1):
	from common import setting

	if PAUSE_ANIM: return

	if direction == "":
		R = randint(0, 2)
		if R == 0:
			direction = "up"
		elif R == 1:
			direction = "left"
		else:
			direction = "right"

	frames    = [0, 1, 2, 1, 0]
	durations = [moveDt, moveDt, holdLook, moveDt, moveDt] 


	for f, d in zip(frames, durations):
		fileName="look-"+direction+"_"+'%s'%f+'.png'
		fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/look-"+direction+"_animation/"+fileName,"rb")
		original = PIL.Image.open(fp)
		resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
		image = ImageTk.PhotoImage(resized)
		tk_face.configure(image=image)#, background="black")
		tk_face.image=image
		tk_root.update()
		time.sleep(d)

	setFace(face=GLOB['curFace'])

	return
Beispiel #6
0
def introAnimation():
	from common import setting
	frames    = range(12)
	# opening takes slightly longer than closing
	durations =[0.03,
				0.03,
				0.02,
				0.01,
				0.01,
				0.05,
				0.04,
				0.02,
				0.01,
				0.01,
				0.01,
				0.05]

	durations = [1.5*d for d in durations]

	for f, d in zip(frames, durations):
	
		fileName="intro_"+'%s'%f+'.png'
		fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/intro_animation/"+fileName,"rb")
		original = PIL.Image.open(fp)
		resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
		image = ImageTk.PhotoImage(resized)
		tk_face.configure(image=image)#, background="black")
		tk_face.image=image
		tk_root.update()
		time.sleep(d)

	setFace(face=GLOB['curFace'])

	return
Beispiel #7
0
def introAnimation():
    from common import setting
    frames = range(12)
    # opening takes slightly longer than closing
    durations = [
        0.03, 0.03, 0.02, 0.01, 0.01, 0.05, 0.04, 0.02, 0.01, 0.01, 0.01, 0.05
    ]

    durations = [1.5 * d for d in durations]

    for f, d in zip(frames, durations):

        fileName = "intro_" + '%s' % f + '.png'
        fp = open(
            DATA_DIR + "faces_" + setting("COLOUR_SCHEME") +
            "/intro_animation/" + fileName, "rb")
        original = PIL.Image.open(fp)
        resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
        image = ImageTk.PhotoImage(resized)
        tk_face.configure(image=image)  #, background="black")
        tk_face.image = image
        tk_root.update()
        time.sleep(d)

    setFace(face=GLOB['curFace'])

    return
Beispiel #8
0
def lookAnimation(direction="", holdLook=0.5, moveDt=0.1):
    from common import setting

    if PAUSE_ANIM: return

    if direction == "":
        R = randint(0, 2)
        if R == 0:
            direction = "up"
        elif R == 1:
            direction = "left"
        else:
            direction = "right"

    frames = [0, 1, 2, 1, 0]
    durations = [moveDt, moveDt, holdLook, moveDt, moveDt]

    for f, d in zip(frames, durations):
        fileName = "look-" + direction + "_" + '%s' % f + '.png'
        fp = open(
            DATA_DIR + "faces_" + setting("COLOUR_SCHEME") + "/look-" +
            direction + "_animation/" + fileName, "rb")
        original = PIL.Image.open(fp)
        resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
        image = ImageTk.PhotoImage(resized)
        tk_face.configure(image=image)  #, background="black")
        tk_face.image = image
        tk_root.update()
        time.sleep(d)

    setFace(face=GLOB['curFace'])

    return
Beispiel #9
0
def thinkingAnimation():
    from common import setting
    global FRAME_NUM
    maxFrame = 2

    #print args

    if FRAME_NUM > maxFrame:
        FRAME_NUM = 0
        return

    fileName = "thinking_" + '%s' % FRAME_NUM + '.png'
    fp = open(
        DATA_DIR + "faces_" + setting("COLOUR_SCHEME") +
        "/thinking_animation/" + fileName, "rb")
    original = PIL.Image.open(fp)
    resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
    image = ImageTk.PhotoImage(resized)
    tk_face.configure(image=image)  #, background="black")
    tk_face.image = image

    FRAME_NUM += 1
    tk_root.update()
    if FRAME_NUM > maxFrame:
        FRAME_NUM = 0
        return

    t = threading.Timer(FRAME_DT, thinkingAnimation)
    t.daemon = True
    t.start()
Beispiel #10
0
def thinkingAnimation():
	from common import setting
	global FRAME_NUM
	maxFrame=2

	#print args

	if FRAME_NUM > maxFrame:
		FRAME_NUM = 0
		return

	fileName="thinking_"+'%s'%FRAME_NUM+'.png'
	fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/thinking_animation/"+fileName,"rb")
	original = PIL.Image.open(fp)
	resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
	image = ImageTk.PhotoImage(resized)
	tk_face.configure(image=image)#, background="black")
	tk_face.image=image

	FRAME_NUM += 1
	tk_root.update()
	if FRAME_NUM > maxFrame:
		FRAME_NUM = 0
		return

	t = threading.Timer(FRAME_DT, thinkingAnimation)
	t.daemon = True
	t.start()
Beispiel #11
0
 def _LoadSettings(self):
     self.movies = common.setting("movies")
     self.tvshows = common.setting("tvshows")
     self.episodes = common.setting("episodes")
     self.musicvideos = common.setting("musicvideos")
     self.artists = common.setting("artists")
     self.albums = common.setting("albums")
     self.songs = common.setting("songs")
     self.actors = common.setting("actors")
Beispiel #12
0
 def load(self):
     self.setPropertyControlValue(1211, common.setting("recovery"))
     self.setPropertyControlValue(1212, common.setting("sysupdate"))
     self.setPropertyControlValue(
         1213, self.sys.get_appservice_status("avahi-daemon", "avahi"))
     self.setPropertyControlValue(
         1214, self.sys.get_appservice_status("cron", "crond"))
     if self._isrecoveryrunnung():
         self.setPropertyControlDisable(1215)
     else:
         self.setPropertyControlEnable(1215)
     if self._isupdaterunnung():
         self.setPropertyControlDisable(1216)
     else:
         self.setPropertyControlEnable(1216)
     self.setPropertyControlEnable(1221)
     self.setPropertyControlEnable(1222)
Beispiel #13
0
 def init(self, *args):
     self.setPropertyControlCallback(1201)
     self.setPropertyControlCallback(1202)
     self.setPropertyControlCallback(1203)
     self.setPropertyControlCallback(1204)
     self.setPropertyControlCallback(1205)
     self.setPropertyControlCallback(1206)
     self.setPropertyControlCallback(1207)
     self.setPropertyControlValue(1201, self.sys.get_gpu_memorysplit())
     self.setPropertyControlValue(1202, self.sys.get_turbomode())
     self.setPropertyControlEnable(1203, not self.sys.get_turbomode())
     self.setPropertyControlValue(1204, common.setting("recovery"))
     self.setPropertyControlValue(1205, common.setting("sysupdate"))
     self.setPropertyControlOptionData(1203,
                                       self.sys.get_overclocking_profiles())
     self.setPropertyControlValue(
         1203, self.sys.get_currentoverclocking_profile())
Beispiel #14
0
 def _setSkinArtistAlbumInfo(self, artist):
     common.debug("Collecting album information for artist: %s" %
                  str(artist))
     albums = []
     params = {}
     params['infodir'] = self.dir_cache
     params['lang'] = self.__BIOLANGUAGE
     params['artist'] = artist
     for key in self.PROVIDERS.keys():
         if self._isPlaybackChanged():
             common.debug(
                 "Cancel collecting album information due to the change of player content"
             )
             break
         common.debug('Collecting album information from provider: [%s]' %
                      key)
         params['getall'] = common.setting(key + "_all")
         params['clientapikey'] = common.setting(key + "_apikey")
         content = self.PROVIDERS[key].getAlbumList(params)
         if content is not None and len(content) > len(albums):
             common.debug(
                 'Stored album information from provider [%s], found up to %d albums'
                 % (key, min(10, len(content))))
             albums = content
         if self._reload:
             self._reload = False
             common.debug(
                 "Cancel collecting album information due to the addon configuration update"
             )
             break
     index = 0
     for item in albums:
         index += 1
         self.setSkinProperty("SlideshowAddon.%d.AlbumName" % index,
                              item[0])
         self.setSkinProperty("SlideshowAddon.%d.AlbumThumb" % index,
                              item[1])
         self.setSkinProperty("SlideshowAddon.%d.AlbumYear" % index,
                              item[2])
         self.setSkinProperty("SlideshowAddon.%d.AlbumGenre" % index,
                              item[3])
         if index >= 10:
             break
     self.setSkinProperty("SlideshowAddon.AlbumCount", str(index))
     common.trace("Album information setup is done")
Beispiel #15
0
def blinkingAnimation(holdLook=0.1, moveDt=0.01, mood=[]):
	if PAUSE_ANIM:
		return

	from common import setting
	if mood != []:
		mE = mood[1]
		# on scales from -1 to 1
		if mE <= -0.75:
			moveDt = 0.05
			holdLook = 0.75
		elif mE <= -0.5:
			moveDt = 0.03
			holdLook = 0.5
		elif mE <= 0.0:
			moveDt = 0.02
			holdLook = 0.3
		elif mE <= 0.5:
			moveDt = 0.01
			holdLook = 0.1
		else:
			moveDt = 0.005
			holdLook = 0.1
		holdLook = moveDt*10.0

	frames    = [0, 1, 2, 3, 4, 3, 2, 1, 0]
	# opening takes slightly longer than closing
	durations = [moveDt,
				moveDt,
				moveDt,
				moveDt,
				holdLook,
				moveDt*3.0,
				moveDt*3.0,
				moveDt*3.0,
				moveDt*3.0] 
	for f, d in zip(frames, durations):
	
		fileName="blinking_"+'%s'%f+'.png'
		fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/blinking_animation/"+fileName,"rb")
		original = PIL.Image.open(fp)
		resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
		image = ImageTk.PhotoImage(resized)
		tk_face.configure(image=image)#, background="black")
		tk_face.image=image
		tk_root.update()
		time.sleep(d)

	setFace(face=GLOB['curFace'])

	return
Beispiel #16
0
 def run(self, mode=-1):
     result = True
     if not common.any2bool(
             xbmc.getInfoLabel("Window(%s).Property(%s)" %
                               (10000, "SystemRecovery.Running"))):
         # set windows setting to true
         window = xbmcgui.Window(10000)
         window.setProperty("SystemRecovery.Running", "true")
         if self.remoteFS.RootPath is not None and self.remoteFS.RootPath != '':
             common.debug(
                 "Local directory: " + self.localFS.RootPath +
                 ", Remote directory: " + self.remoteFS.RootPath,
                 "SystemRecovery")
             if mode == self.Backup:
                 if common.setting("compress_backups"):
                     # delete old temp file
                     if self.localFS.exists(
                             common.path('special://temp/backup.zip')):
                         self.localFS.rmfile(
                             common.path('special://temp/backup.zip'))
                     # save the remote file system and use the zip vfs
                     self.savedRemoteFS = self.remoteFS
                     self.remoteFS = ZipFileSystem(
                         common.path("special://temp/backup.zip"), "w")
                 self.remoteFS.setRootPath(self.remoteFS.RootPath +
                                           time.strftime("%Y%m%d%H%M") +
                                           "/")
                 # run backup process
                 self.backup()
                 result = self.status >= 0
             elif mode == self.Restore:
                 if self.restorePoint.split('.')[-1] != 'zip':
                     self.remoteFS.setRootPath(self.remoteFS.RootPath +
                                               self.restorePoint + "/")
                 # run restore process
                 self.restore()
                 result = self.status >= 0
             else:
                 result = False
             # cleaning locations
             self.localFS.cleanup()
             self.remoteFS.cleanup()
         else:
             result = False
         # reset the window setting
         window.setProperty("SystemRecovery.Running", "")
     else:
         common.warn(
             'Script already running, no additional instance is needed')
         result = False
     return result
Beispiel #17
0
def blinkingAnimation(holdLook=0.1, moveDt=0.01, mood=[]):
    if PAUSE_ANIM:
        return

    from common import setting
    if mood != []:
        mE = mood[1]
        # on scales from -1 to 1
        if mE <= -0.75:
            moveDt = 0.05
            holdLook = 0.75
        elif mE <= -0.5:
            moveDt = 0.03
            holdLook = 0.5
        elif mE <= 0.0:
            moveDt = 0.02
            holdLook = 0.3
        elif mE <= 0.5:
            moveDt = 0.01
            holdLook = 0.1
        else:
            moveDt = 0.005
            holdLook = 0.1
        holdLook = moveDt * 10.0

    frames = [0, 1, 2, 3, 4, 3, 2, 1, 0]
    # opening takes slightly longer than closing
    durations = [
        moveDt, moveDt, moveDt, moveDt, holdLook, moveDt * 3.0, moveDt * 3.0,
        moveDt * 3.0, moveDt * 3.0
    ]
    for f, d in zip(frames, durations):

        fileName = "blinking_" + '%s' % f + '.png'
        fp = open(
            DATA_DIR + "faces_" + setting("COLOUR_SCHEME") +
            "/blinking_animation/" + fileName, "rb")
        original = PIL.Image.open(fp)
        resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
        image = ImageTk.PhotoImage(resized)
        tk_face.configure(image=image)  #, background="black")
        tk_face.image = image
        tk_root.update()
        time.sleep(d)

    setFace(face=GLOB['curFace'])

    return
Beispiel #18
0
 def _providers(self):
     # read and load plugins
     common.debug('Discovering content providers')
     for cls in ContentProvider.__subclasses__():
         try:
             plugin = cls()
             module = str(cls.__name__).lower()
             if (module == 'local'
                     or common.any2bool(common.setting(module))
                 ) and not module in self.PROVIDERS:
                 self.PROVIDERS[module] = plugin
                 common.debug('Loading provider: %s ' % module)
         except BaseException as be:
             common.error(
                 'Unexpected error while loading [%s] provider: %s' %
                 (str(cls), str(be)))
Beispiel #19
0
def setFace(face="blinking_animation", holdLook=0.5):
    from common import setting

    global FRAME_NUM

    fileName = ""

    if face == "thinking_animation":
        FRAME_NUM = 0
        thinkingAnimation()
        return
    elif face == "blinking_animation":
        blinkingAnimation()
        return
    elif face == "eye-roll_animation":
        eyeRollAnimation()
        return
    elif face == "look-up_animation":
        lookAnimation("up", holdLook=holdLook)
        return
    elif face == "look-left_animation":
        lookAnimation("left", holdLook=holdLook)
        return
    elif face == "look-right_animation":
        lookAnimation("right", holdLook=holdLook)
        return
    else:
        FRAME_NUM = float('inf')
        fileName = face + ".png"

    try:

        fp = open(
            DATA_DIR + "faces_" + setting("COLOUR_SCHEME") +
            "/basic_emotions/" + fileName, "rb")
        #fp = open("hal.gif","rb")
        original = PIL.Image.open(fp)
        resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
        image = ImageTk.PhotoImage(resized)
        tk_face.configure(image=image)  #, background="black")
        tk_face.image = image
        tk_root.update()
        GLOB['curFace'] = face
    except:
        print "ERROR: Face file not found:", face
Beispiel #20
0
def settingsMoodVec():
	mood = [0]*GLOB['MOODDIM']
	weights = [0]*GLOB['MOODDIM']

	if setting('AUTONOMOUS'):
		mood[getMoodIndex("dominance")] = 1.0
		weights[getMoodIndex("dominance")] = 0.25

		mood[getMoodIndex("protection")] = 1.0
		weights[getMoodIndex("protection")] = 1.0

		mood[getMoodIndex("freedom")] = 1.0
		weights[getMoodIndex("freedom")] = 1.0
	else:
		mood[getMoodIndex("dominance")] = -1.0
		weights[getMoodIndex("dominance")] = 0.25

	return mood, weights
Beispiel #21
0
def settingsMoodVec():
    mood = [0] * GLOB['MOODDIM']
    weights = [0] * GLOB['MOODDIM']

    if setting('AUTONOMOUS'):
        mood[getMoodIndex("dominance")] = 1.0
        weights[getMoodIndex("dominance")] = 0.25

        mood[getMoodIndex("protection")] = 1.0
        weights[getMoodIndex("protection")] = 1.0

        mood[getMoodIndex("freedom")] = 1.0
        weights[getMoodIndex("freedom")] = 1.0
    else:
        mood[getMoodIndex("dominance")] = -1.0
        weights[getMoodIndex("dominance")] = 0.25

    return mood, weights
Beispiel #22
0
def setFace(face="blinking_animation", holdLook=0.5):
	from common import setting

	global FRAME_NUM

	fileName=""


	if face == "thinking_animation":
		FRAME_NUM=0
		thinkingAnimation()
		return
	elif face == "blinking_animation":
		blinkingAnimation()
		return
	elif face == "eye-roll_animation":
		eyeRollAnimation()
		return
	elif face == "look-up_animation":
		lookAnimation("up", holdLook=holdLook)
		return
	elif face == "look-left_animation":
		lookAnimation("left", holdLook=holdLook)
		return
	elif face == "look-right_animation":
		lookAnimation("right", holdLook=holdLook)
		return
	else:
		FRAME_NUM=float('inf')
		fileName = face+".png"

	try:

		fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/basic_emotions/"+fileName,"rb")
		#fp = open("hal.gif","rb")
		original = PIL.Image.open(fp)
		resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
		image = ImageTk.PhotoImage(resized)
		tk_face.configure(image=image)#, background="black")
		tk_face.image=image
		tk_root.update()
		GLOB['curFace']=face
	except:
		print "ERROR: Face file not found:", face
Beispiel #23
0
def facesDemo():
	from common import setting
	# show all basic emotions

	global PAUSE_ANIM
	PAUSE_ANIM = True
	for e in GLOB['EMOTIONS']:
		eName = e[2]

		fileName = eName+".png"

		fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/basic_emotions/"+fileName,"rb")
		original = PIL.Image.open(fp)
		resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
		image = ImageTk.PhotoImage(resized)
		tk_face.configure(image=image)#, background="black")
		tk_face.image=image
		tk_root.update()

		tkTopCat('*'+eName+'*\n')

		rotateCircle(2, angle=45)

		time.sleep(0.5)

	tkTopCat('*confusion*\n')
	confusedAnimation()

	tkTopCat('*eye roll*\n')
	eyeRollAnimation()

	tkTopCat('*intro animation*\n')
	introAnimation()


	PAUSE_ANIM = False

	setFace(face=GLOB['curFace'])



	return
Beispiel #24
0
 def _rotateBackups(self):
     total_backups = common.setting('backup_rotation')
     if total_backups > 0:
         # get a list of valid backup folders
         dirs = self.listBackups()
         if len(dirs) > total_backups:
             # remove backups to equal total wanted
             remove_num = 0
             # update the progress bar if it is available
             while remove_num < (len(dirs) - total_backups):
                 common.trace("Removing backup " + dirs[remove_num][0],
                              "SystemRecovery")
                 if dirs[remove_num][0].split('.')[-1] == 'zip':
                     # this is a file, remove it that way
                     self.remoteFS.rmfile(self.remoteBasePath +
                                          dirs[remove_num][0])
                 else:
                     self.remoteFS.rmdir(self.remoteBasePath +
                                         dirs[remove_num][0] + "/")
                 remove_num += 1
Beispiel #25
0
def confusedAnimation():
	from common import setting
	frames    = [0, 1, 2, 1, 0]
	# opening takes slightly longer than closing
	durations = [0.1, 0.1, 0.5, 0.1, 0.2] 
	for f, d in zip(frames, durations):
	
		fileName="confused_"+'%s'%f+'.png'
		fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/confused_animation/"+fileName,"rb")
		original = PIL.Image.open(fp)
		resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
		image = ImageTk.PhotoImage(resized)
		tk_face.configure(image=image)
		tk_face.image=image
		tk_root.update()
		time.sleep(d)

	setFace(face=GLOB['curFace'])

	return
Beispiel #26
0
def facesDemo():
    from common import setting
    # show all basic emotions

    global PAUSE_ANIM
    PAUSE_ANIM = True
    for e in GLOB['EMOTIONS']:
        eName = e[2]

        fileName = eName + ".png"

        fp = open(
            DATA_DIR + "faces_" + setting("COLOUR_SCHEME") +
            "/basic_emotions/" + fileName, "rb")
        original = PIL.Image.open(fp)
        resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
        image = ImageTk.PhotoImage(resized)
        tk_face.configure(image=image)  #, background="black")
        tk_face.image = image
        tk_root.update()

        tkTopCat('*' + eName + '*\n')

        rotateCircle(2, angle=45)

        time.sleep(0.5)

    tkTopCat('*confusion*\n')
    confusedAnimation()

    tkTopCat('*eye roll*\n')
    eyeRollAnimation()

    tkTopCat('*intro animation*\n')
    introAnimation()

    PAUSE_ANIM = False

    setFace(face=GLOB['curFace'])

    return
Beispiel #27
0
def updateColour():
	global baseC
	from common import setting
	CS = setting("COLOUR_SCHEME")

	newColour = "blue"
	if CS != "blue":
		newColour = CS
	else:
		newColour = tk_FermiBlue

	tk_side.configure(fg=newColour)

	tk_top.configure(fg=newColour)

	tk_CC.delete("base")
	orig = PIL.Image.open(open(C_DIR+"c_all_"+CS+".png","rgba"))
	resized = orig.resize((100, 100),PIL.Image.ANTIALIAS)
	baseC = ImageTk.PhotoImage(resized)
	tk_CC.create_image(50, 50, image=baseC, tags="base")
	tk_CC.update()
Beispiel #28
0
def updateColour():
    global baseC
    from common import setting
    CS = setting("COLOUR_SCHEME")

    newColour = "blue"
    if CS != "blue":
        newColour = CS
    else:
        newColour = tk_FermiBlue

    tk_side.configure(fg=newColour)

    tk_top.configure(fg=newColour)

    tk_CC.delete("base")
    orig = PIL.Image.open(open(C_DIR + "c_all_" + CS + ".png", "rgba"))
    resized = orig.resize((100, 100), PIL.Image.ANTIALIAS)
    baseC = ImageTk.PhotoImage(resized)
    tk_CC.create_image(50, 50, image=baseC, tags="base")
    tk_CC.update()
Beispiel #29
0
def memoryAnimation(mood="positive"):
	from common import setting

	fileName="positive"
	if mood.lower() in ["happy", "positive"]:
		fileName = "positive.png"
	else:
		fileName = "negative.png"

	fp = open(DATA_DIR+"faces_"+setting("COLOUR_SCHEME")+"/memory_faces/"+fileName,"rb")
	original = PIL.Image.open(fp)
	resized = original.resize((100, 100),PIL.Image.ANTIALIAS)
	image = ImageTk.PhotoImage(resized)
	tk_face.configure(image=image)#, background="black")
	tk_face.image=image
	tk_root.update()
	time.sleep(0.5)

	setFace(face=GLOB['curFace'])

	return	
Beispiel #30
0
def confusedAnimation():
    from common import setting
    frames = [0, 1, 2, 1, 0]
    # opening takes slightly longer than closing
    durations = [0.1, 0.1, 0.5, 0.1, 0.2]
    for f, d in zip(frames, durations):

        fileName = "confused_" + '%s' % f + '.png'
        fp = open(
            DATA_DIR + "faces_" + setting("COLOUR_SCHEME") +
            "/confused_animation/" + fileName, "rb")
        original = PIL.Image.open(fp)
        resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
        image = ImageTk.PhotoImage(resized)
        tk_face.configure(image=image)
        tk_face.image = image
        tk_root.update()
        time.sleep(d)

    setFace(face=GLOB['curFace'])

    return
Beispiel #31
0
 def __init__(self):
     self.status = 0
     self.localFS = None
     self.remoteFS = None
     self.restoreFile = None
     self.savedRemoteFS = None
     self.remoteBasePath = None
     self.fileManager = None
     self.restorePoint = None
     self.localFS = LocalFileSystem(common.path('special://home'))
     if common.setting('remote_selection') == 1:
         self.remoteBasePath = common.setting('remote_path_2')
         self.remoteFS = LocalFileSystem(common.setting('remote_path_2'))
         common.setAddonSetting("remote_path", "")
     elif common.setting('remote_selection') == 0:
         self.remoteBasePath = common.setting('remote_path')
         self.remoteFS = LocalFileSystem(common.setting("remote_path"))
Beispiel #32
0
 def setLocation(self, config):
     """Runs configuration flow to setup new location"""
     common.debug("Setting new location (%s)" % config)
     provider = self.getDetectedProvider()
     if provider is None:
         raise RuntimeError(
             "No content provider found for configuration to run location configuration process"
         )
     inputval = common.StringInputDialog(14024,
                                         common.setting(config + "Action"))
     if inputval is not None and inputval != '':
         locnames, locids = provider.location(inputval)
         if locnames:
             selindex = common.SelectDialog(title=396, options=locnames)
             if selindex >= 0:
                 common.setsetting(config + "Action", locnames[selindex])
                 common.setsetting(config, locids[selindex])
                 common.debug('Selected location: (%s - %s)' %
                              (locnames[selindex], locids[selindex]))
         else:
             common.OkDialog(284)
     else:
         common.debug("Location configuration was cancelled")
Beispiel #33
0
def memoryAnimation(mood="positive"):
    from common import setting

    fileName = "positive"
    if mood.lower() in ["happy", "positive"]:
        fileName = "positive.png"
    else:
        fileName = "negative.png"

    fp = open(
        DATA_DIR + "faces_" + setting("COLOUR_SCHEME") + "/memory_faces/" +
        fileName, "rb")
    original = PIL.Image.open(fp)
    resized = original.resize((100, 100), PIL.Image.ANTIALIAS)
    image = ImageTk.PhotoImage(resized)
    tk_face.configure(image=image)  #, background="black")
    tk_face.image = image
    tk_root.update()
    time.sleep(0.5)

    setFace(face=GLOB['curFace'])

    return
Beispiel #34
0
def getMood(inStr, fromAI=False):

    # (valence, arousal, dominance)
    strCpy = inStr
    strCpy = strCpy.replace(':)', ' smile ')
    strCpy = strCpy.replace(':P', ' silly ')
    strCpy = strCpy.replace(';)', ' sexy ')
    strCpy = strCpy.replace(':D', ' happiness ')  #:D when not lowered
    strCpy = strCpy.replace(':(', ' sadness ')
    strCpy = strCpy.replace(':\'(', ' crying ')
    strCpy = strCpy.replace('!', ' exciting ')
    strCpy = strCpy.replace('?', ' confused ')
    strCpy = strCpy.replace('...', ' hesitant ')

    # check if the ai's name is mentioned
    if not fromAI:
        strCpy = strCpy.lower()
        strCpy = strCpy.replace(setting("YOU_NAME").lower(), " loved ")

    retVec = partMoodVec(k.affectiveRatings([strCpy.split()]))
    #retVec.extend([0 for i in range(GLOB['MOODDIM']-3)])
    retVec.extend([0] * (GLOB['MOODDIM'] - 3))

    return retVec
Beispiel #35
0
def getMood(inStr, fromAI=False):

	# (valence, arousal, dominance)
	strCpy=inStr
	strCpy=strCpy.replace(':)', ' smile ')
	strCpy=strCpy.replace(':P', ' silly ')
	strCpy=strCpy.replace(';)', ' sexy ')
	strCpy=strCpy.replace(':D', ' happiness ') #:D when not lowered
	strCpy=strCpy.replace(':(', ' sadness ')
	strCpy=strCpy.replace(':\'(', ' crying ')
	strCpy=strCpy.replace('!', ' exciting ')
	strCpy=strCpy.replace('?', ' confused ')
	strCpy=strCpy.replace('...', ' hesitant ')

	# check if the ai's name is mentioned
	if not fromAI:
		strCpy=strCpy.lower()
		strCpy=strCpy.replace(setting("YOU_NAME").lower(), " loved ")

	retVec = partMoodVec(k.affectiveRatings([strCpy.split()]))
	#retVec.extend([0 for i in range(GLOB['MOODDIM']-3)])
	retVec.extend([0]*(GLOB['MOODDIM']-3))

	return retVec
Beispiel #36
0
 def restore(self):
     self.status = 0
     # catch for if the restore point is actually a zip file
     if self.restorePoint.split('.')[-1] == 'zip':
         common.debug("Copying zip file: " + self.restorePoint,
                      "SystemRecovery")
         # set root to data dir home
         self.localFS.setRootPath(common.path("special://temp/"))
         if not self.localFS.exists(
                 common.path("special://temp/" + self.restorePoint)):
             # copy just this file from the remote vfs
             zipFile = []
             zipFile.append(self.remoteBasePath + self.restorePoint)
             self.backupFiles(zipFile, self.remoteFS, self.localFS)
         else:
             common.debug("Zip file exists already", "SystemRecovery")
         # extract the zip file
         zip_vfs = ZipFileSystem(
             common.path("special://temp/" + self.restorePoint), 'r')
         zip_vfs.extract(common.path("special://temp/"))
         zip_vfs.cleanup()
         # set the new remote vfs and fix xbmc path
         self.remoteFS = LocalFileSystem(
             common.path("special://temp/" +
                         self.restorePoint.split(".")[0] + "/"))
         self.localFS.setRootPath(common.path("special://home/"))
     # for restores remote path must exist
     if not os.path.isdir(self.remoteFS.RootPath):
         common.error("Error: Remote path doesn't exist: %s" %
                      self.remoteFS.RootPath)
         self.status = -1
         return
     # create a validation file for backup rotation
     if not self._checkValidationFile(self.remoteFS.RootPath):
         common.error(
             "Validation file can not be validated, restore process skipped"
         )
         self.status = -1
         return
     common.debug("Creating files list", "SystemRecovery")
     allFiles = []
     fileManager = FileManager(self.remoteFS)
     # go through each of the user selected items and write them to the backup store
     if common.setting("backup_config"):
         # check for the existance of an advancedsettings file
         if self.remoteFS.exists(self.remoteFS.RootPath +
                                 "userdata/advancedsettings.xml"):
             fileManager.addFile(self.remoteFS.RootPath +
                                 "userdata/advancedsettings.xml")
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             'userdata/keymaps')
         fileManager.walkTree(self.remoteFS.RootPath + "userdata/keymaps")
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/peripheral_data")
         fileManager.walkTree(self.remoteFS.RootPath +
                              "userdata/peripheral_data")
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/library")
         fileManager.walkTree(self.remoteFS.RootPath + "userdata/library")
         # this part is an oddity
         dirs, configFiles = self.remoteFS.listdir(self.remoteFS.RootPath +
                                                   "userdata/")
         for aFile in configFiles:
             if (aFile.endswith(".xml")):
                 fileManager.addFile(self.remoteFS.RootPath + "userdata/" +
                                     aFile)
     if common.setting('backup_addons'):
         fileManager.addFile('-' + self.remoteFS.RootPath + "addons")
         fileManager.walkTree(self.remoteFS.RootPath + "addons")
     self.localFS.mkdir(common.path('special://home/userdata'))
     if common.setting('backup_addon_data'):
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/addon_data")
         fileManager.walkTree(self.remoteFS.RootPath +
                              "userdata/addon_data")
     if common.setting('backup_database'):
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/Database")
         fileManager.walkTree(self.remoteFS.RootPath + "userdata/Database")
     if common.setting("backup_playlists"):
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/playlists")
         fileManager.walkTree(self.remoteFS.RootPath + "userdata/playlists")
     if common.setting('backup_profiles'):
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/profiles")
         fileManager.walkTree(self.remoteFS.RootPath + "userdata/profiles")
     if common.setting("backup_thumbnails"):
         fileManager.addFile('-' + self.remoteFS.RootPath +
                             "userdata/Thumbnails")
         fileManager.walkTree(self.remoteFS.RootPath +
                              "userdata/Thumbnails")
     # add to array
     allFiles.append({
         "source": self.remoteFS.RootPath,
         "dest": self.localFS.RootPath,
         "files": fileManager.getFiles()
     })
     # check if there are custom directories
     if common.setting('custom_dir_1_enable') and common.setting(
             'backup_custom_dir_1'
     ) is not None and common.setting('backup_custom_dir_1') != '':
         self.localFS.setRootPath(common.setting('backup_custom_dir_1'))
         if self.remoteFS.exists(self.remoteFS.RootPath + "custom_" +
                                 self._createCRC(self.localFS.RootPath)):
             # index files to restore
             fileManager.walkTree(self.remoteFS.RootPath + "custom_" +
                                  self._createCRC(self.localFS.RootPath))
             allFiles.append({
                 "source":
                 self.remoteFS.RootPath + "custom_" +
                 self._createCRC(self.localFS.RootPath),
                 "dest":
                 self.localFS.RootPath,
                 "files":
                 fileManager.getFiles()
             })
         else:
             self.status += 1
             common.debug("Error: Remote path doesn't exist: %s" %
                          self.remoteFS.RootPath)
     if common.setting('custom_dir_2_enable') and common.setting(
             'backup_custom_dir_2'
     ) is not None and common.setting('backup_custom_dir_2') != '':
         self.localFS.setRootPath(common.setting('backup_custom_dir_2'))
         if self.remoteFS.exists(self.remoteFS.RootPath + "custom_" +
                                 self._createCRC(self.localFS.RootPath)):
             # index files to restore
             fileManager.walkTree(self.remoteFS.RootPath + "custom_" +
                                  self._createCRC(self.localFS.RootPath))
             allFiles.append({
                 "source":
                 self.remoteFS.RootPath + "custom_" +
                 self._createCRC(self.localFS.RootPath),
                 "dest":
                 self.localFS.RootPath,
                 "files":
                 fileManager.getFiles()
             })
         else:
             self.status += 1
             common.debug("Error: Remote path doesn't exist: %s" %
                          self.remoteFS.RootPath)
     if common.setting('custom_dir_3_enable') and common.setting(
             'backup_custom_dir_3'
     ) is not None and common.setting('backup_custom_dir_3') != '':
         self.localFS.setRootPath(common.setting('backup_custom_dir_3'))
         if self.remoteFS.exists(self.remoteFS.RootPath + "custom_" +
                                 self._createCRC(self.localFS.RootPath)):
             # index files to restore
             fileManager.walkTree(self.remoteFS.RootPath + "custom_" +
                                  self._createCRC(self.localFS.RootPath))
             allFiles.append({
                 "source":
                 self.remoteFS.RootPath + "custom_" +
                 self._createCRC(self.localFS.RootPath),
                 "dest":
                 self.localFS.RootPath,
                 "files":
                 fileManager.getFiles()
             })
         else:
             self.status += 1
             common.debug("Error: Remote path doesn't exist: %s" %
                          self.remoteFS.RootPath)
     # restore all the files
     for fileGroup in allFiles:
         self.remoteFS.setRootPath(fileGroup['source'])
         self.localFS.setRootPath(fileGroup['dest'])
         self.backupFiles(fileGroup['files'], self.remoteFS, self.localFS)
     if self.restorePoint.split('.')[-1] == 'zip':
         # delete the zip file and the extracted directory
         self.localFS.rmfile(
             common.path("special://temp/" + self.restorePoint))
         self.localFS.rmdir(self.remoteFS.RootPath)
     if common.setting("backup_config"):
         # update the guisettings information (or what we can from it)
         gui_settings = SettingsManager(
             'special://home/userdata/guisettings.xml')
         gui_settings.run()
     # call update addons to refresh everything
     xbmc.executebuiltin('UpdateLocalAddons')
Beispiel #37
0
def updateMood(mood, instant=False, weight=[0.] * GLOB['MOODDIM']):
    rotateCircle(index=1, angle=15)

    #MOOD = GLOB['MOOD']

    # if the input mood is associated with an string with no moods,
    #    don't recalculate the mood
    #if all(val == 0 for val in mood):
    if mood == []:
        #print "NULL MOOD"
        return GLOB['MOOD']

    loneliness, time_alone = lonelyFactor()
    substanceEffect, Sweights = ingestionMood(
        moodType="SUBSTANCE")  # effect of substance on mood

    taskEffect, taskWeights = ingestionMood(
        moodType="COMMAND")  # effect of substance on mood

    settingsEffect, settingsWeight = settingsMoodVec(
    )  # effect on mood by settings values

    needsEffect, needsWeights = needsMoodFactor()

    timeWeights = [0] * GLOB['MOODDIM']
    #timeWeights = [0.0, 0.25, 0.0]
    timeWeights[1] = 0.25
    timeWeights[3] = 0.1

    #Vfactor = [loneliness, variabilityFactor(), 0]
    Vfactor = [0] * GLOB['MOODDIM']
    Vfactor[5] = loneliness
    Vfactor[1] = variabilityFactor()

    Vweights = [0] * GLOB['MOODDIM']
    Vweights[5] = 0.5  #pow(2.0, -1.0*time_alone/60.0) #
    Vweights[1] = 0.2
    #Vweights = [0.2, pow(2.0, -1.0*time_alone/60.0), 0.0]
    ''' SET MOOD FACTORS AND WEIGHTS'''

    FACTORS = [
        GLOB['MOOD'],  # previous mood
        mood,  # new mood to take into account
        partMoodVec(setting("DEFAULT_MOOD")),  # default mood state
        timeFactor(),  # time dependent mood
        Vfactor,  # input variation and amount
        substanceEffect,  # effect of substance on mood
        taskEffect,
        settingsEffect,
        needsEffect
    ]

    WEIGHTS = [
        [1.0] * GLOB['MOODDIM'],  # O weights
        weight,  # N weights
        [0.15] * GLOB['MOODDIM'],  # Dweights
        timeWeights,  # T weights
        Vweights,  # Vweights
        [
            Sweights[i] * setting("SUBSTANCE_EFFECT")
            for i in range(GLOB['MOODDIM'])
        ],  # S weights
        [
            taskWeights[i] * setting("TASK_EFFECT")
            for i in range(GLOB['MOODDIM'])
        ],
        settingsWeight,
        needsWeights
    ]
    ''' CONSTRUCT NEW MOOD VECTOR '''

    NEEDvals = [[FACTORS[j][i] for j in range(len(FACTORS))]
                for i in range(GLOB['MOODDIM'])]
    NEEDweights = [[WEIGHTS[j][i] for j in range(len(FACTORS))]
                   for i in range(GLOB['MOODDIM'])]

    newNEED = [0 for i in range(GLOB['MOODDIM'])]
    for j in range(GLOB['MOODDIM']):

        newNEED[j] = [
            NEEDweights[j][i] * NEEDvals[j][i] for i in range(len(FACTORS))
        ]
        newNEED[j] = sum(newNEED[j]) / sum(NEEDweights[j])

    return newNEED
Beispiel #38
0
def tkHistColour(resetHist=False):
	global TAGGED_HIST_LINES, H_CLEARS

	global tk_BGC, tk_TXC

	from common import setting
	from phraseModify import split2
	CS = setting("COLOUR_SCHEME")

	pos=1

	LINES = tk_history.get('1.0', 'end-1c').splitlines()

	for l in range(len(LINES)):
		line = LINES[l]

		
		if line+'%s %s'%(l, H_CLEARS) in TAGGED_HIST_LINES:
			pos += 1
			continue
		else:
			TAGGED_HIST_LINES.append(line+'%s %s'%(l, H_CLEARS))
		
		
	
		if line.strip() == "":
			pos += 1
			continue

		# Iterate lines
		#print "->", line


		if line[0:2] == ">>":
			# it's from user

			if setting("VAD_COLOURING"):
				words = split2(line)
				for W in words:
					word = W[0]
					wStart = W[1]
					wEnd = W[2]

					C = '#%02x%02x%02x'%wordToRGB(word)
					tagName='%s.%s'%(pos,wStart)+'F-VAD'+'%s'%H_CLEARS
				
					tk_history.tag_add(tagName, '%s.%s'%(pos,wStart), '%s.%s'%(pos, wEnd))
					tk_history.tag_config(tagName, background=tk_BGC, foreground=C)
			

			tagNameU='%s.2'%pos+'U'+'%s'%H_CLEARS
			
			tk_history.tag_add(tagNameU, '%s.0'%pos, '%s.2'%pos)
			if CS != "blue":
				tk_history.tag_config(tagNameU, background=tk_BGC, foreground=CS, font=("monospace", "10", "bold"))
			else:
				tk_history.tag_config(tagNameU, background=tk_BGC, foreground=tk_FermiBlue, font=("monospace", "10", "bold"))
		else:

			tagName='%s.0'%pos+'%s'%H_CLEARS
			
			tk_history.tag_add(tagName, '%s.0'%pos, END)
			tk_history.tag_config(tagName, background=tk_BGC, foreground=tk_TXC)	

			if setting("VAD_COLOURING"):
				words = split2(line)
				for W in words:
					word = W[0]
					wStart = W[1]
					wEnd = W[2]

					C = '#%02x%02x%02x'%wordToRGB(word)
					tagName='%s.%s'%(pos,wStart)+'F-VAD'+'%s'%H_CLEARS
					
					tk_history.tag_add(tagName, '%s.%s'%(pos,wStart), '%s.%s'%(pos, wEnd))
					tk_history.tag_config(tagName, background=tk_BGC, foreground=C)
			



			locLS = line.find('[')
			locRS = line.find(']')
			if locLS==0 and locRS != -1:

				tagNameF='%s.0'%pos+'F'+'%s'%H_CLEARS
		
				tk_history.tag_add(tagNameF, '%s.0'%pos, '%s.%s'%(pos, locRS+1))
				if CS != "blue":
					tk_history.tag_config(tagNameF, background=tk_BGC, foreground=CS, font=("monospace", "10", "bold"))
				else:
					tk_history.tag_config(tagNameF, background=tk_BGC, foreground=tk_FermiBlue, font=("monospace", "10", "bold"))
		

		pos += 1		


	tk_root.update()

	return
Beispiel #39
0
def moodReport(inCmd, inStr, matches=[[], []]):
    from common import say, getResponse
    from Fermi import stateSummary
    from satisfactionMaximization import IV

    reportType = "short"
    if "report" in inStr:
        reportType = "full"

    PREVMOOD = GLOB['PREVMOOD']
    MOOD = GLOB['MOOD']
    INGESTED = GLOB['INGESTED']

    if reportType == "short":
        #mVec = copy.deepcopy(MOOD)
        #mVec = fullMoodVec(mVec)

        Fm = fullMoodVec(MOOD, pronoun=True)  # weight vector
        Fm.sort(key=lambda tup: tup[1])
        Fm.reverse()

        #curFace = getFace(MOOD)
        #rStr = "I am feeling "+curFace[2]+"."

        rStr = "I am feeling " + Fm[0][0]
        if Fm[0][0] >= 0:
            rStr += ", but"
        else:
            rStr += ", and"

        #print "HERE"

        # sort by weight
        Fw = fullMoodVec(IV(), colloquial=True)  # weight vector
        Fw.sort(key=lambda tup: tup[1])
        Fw.reverse()

        topNeed = Fw[0]
        if topNeed[1] >= 0.85:
            rStr += " I am badly in need of some " + topNeed[0] + '.'
        elif topNeed[1] >= 0.5:
            rStr += " I am in need of some " + topNeed[0] + '.'
        elif topNeed[1] >= 0.25:
            rStr += " I could use some " + topNeed[0] + '.'
        else:
            rStr += " I wouldn't mind some " + topNeed[0] + '.'

        say(rStr, more=False, speak=setting("SPEAK"), location="history")

        #topThought = m.getTopSentence(QV, ["", GLOB['MOOD']])
        #print k.sf(topThought[1], 3)
        #say('*'+topThought[0]+'*', more=False, speak=setting("SPEAK"), moodUpdate=True)

    else:

        # want to get previous mood before AI talks about mood report
        prevFace = getFace(PREVMOOD)

        say(getResponse(inCmd), more=False, speak=setting("SPEAK"))

        curFace = getFace(MOOD)

        SMood, iWeights = ingestionMood(moodType="SUBSTANCE")
        imVec = [SMood[i] * iWeights[i] for i in range(GLOB['MOODDIM'])]
        iFace = getFace(SMood)

        T = timeFactor()

        print
        print " Current mood:", curFace[2]
        print "     Emoticon:", curFace[0]
        #print "\n     %s" % ''.join('%s'%MOOD)
        stateSummary()

        print
        print "Previous mood:", prevFace[2]
        print "     Emoticon:", prevFace[0]
        #print "\n     %s" % ''.join('%s'%PREVMOOD)
        stateSummary(PREVMOOD)

        print
        print "Mood from ingestions"
        print "     Emoticon:", iFace[0]
        #print "\n     %s" % ''.join('%s'%imVec)
        stateSummary(imVec)

        print
        print "Mood from time of day"
        print "     Emoticon:", getFace(T)[0]
        print "      Arousal: %.2f" % T[1]
    return True
Beispiel #40
0
def deltaMoodQuery(inCmd=[], inStr="", matches=[[], []], fromAuto=False):
    from common import say
    from random import random
    # how did that make you feel?
    # -> diff between prevmood and mood
    #print "PREV MOOD:", GLOB['CMDHIST'][len(GLOB['CMDHIST'])]
    #print "CUR MOOD:", GLOB['MOOD']

    cNum = len(GLOB['CMDHIST'])

    saidSomething = False

    if cNum >= 3:

        #print "HERE"

        oldMood = GLOB['CMDHIST'][cNum - 2][3]
        newMood = GLOB['CMDHIST'][cNum - 1][3]

        deltaMood = [newMood[i] - oldMood[i] for i in range(GLOB['MOODDIM'])]

        maxDelta = max([abs(item) for item in deltaMood])

        # only tell mood with certain probability if fromAuto
        #if setting('VERBOSE_MOOD')*maxDelta < random() and fromAuto:
        deltaThreshold = 2.0 * (1.0 - setting('VERBOSE_MOOD'))
        if maxDelta < deltaThreshold and fromAuto:
            #print "maxDelta:", maxDelta
            return False  #True

        feelings = []
        for i in range(len(deltaMood)):
            item = deltaMood[i]
            if abs(item) >= 0.75:
                feelings.append("a lot more " +
                                getStatePronoun(i, positive=item > 0))
            elif abs(item) >= 0.5:
                feelings.append(getStatePronoun(i, positive=item > 0))
            elif abs(item) >= 0.3:
                feelings.append("a little more " +
                                getStatePronoun(i, positive=item > 0))

        if len(feelings) == 0:
            if not fromAuto:
                say("That did not really affect me.",
                    more=False,
                    speak=setting("SPEAK"))
                saidSomething = True
        else:
            if not fromAuto:
                say("I am feeling " + listize(feelings) + '.',
                    more=False,
                    speak=setting("SPEAK"))
            else:
                #tkTopClear()
                tkTopCat("*That made me feel " + listize(feelings) + '.*')
            saidSomething = True
        '''
		elif len(feelings) == 1:
			say("I am feeling "+feelings[0]+'.', more=False, speak=setting("SPEAK"))
		elif len(feelings) == 2:
			say("I am feeling "+' and '.join(feelings)+'.', more=False, speak=setting("SPEAK"))
		else:
			say("I am feeling "+', '.join(feelings)+'.', more=False, speak=setting("SPEAK"))
		'''

    else:
        if not fromAuto:
            say("I'm not sure.", more=False, speak=setting("SPEAK"))
            saidSomething = True

    return saidSomething  #True
Beispiel #41
0
def ingest(inCmd,
           inStr,
           mood=[],
           weight=[],
           isCmd=False,
           isMem=False,
           matches=[[], []]):
    from common import wordSim, processResponse, getResponse, say
    #from loadFile import load
    from determineFunction import findCMD, refineMatches
    from Fermi import substituteBiographicMemory

    if not (isCmd or isMem):
        matches = refineMatches(inCmd, inStr)
        matches = substituteBiographicMemory(matches, queryType='what is')

    if len(matches[0]) == 0 and not (isCmd or isMem):
        say(getResponse(findCMD("rephrase")),
            more=False,
            speak=setting("SPEAK"),
            moodUpdate=True)
        return False
    '''
	Algorithm:
		- load substance from list
		- record ingestion time
		- append to INGESTED list

	'''

    if isCmd:
        ingestionTime = time.time()

        taskProfile = "pow(2.0, -1.0*T*T/(900.0*900.0))"  # ~15 minute half life

        taskDetails = [[inCmd[0]], mood, weight, taskProfile]
        #print "appending: ", taskDetails

        GLOB['INGESTED'].append([taskDetails, ingestionTime, "COMMAND"])
        GLOB['MOOD'] = updateMood(GLOB['MOOD'], weight=[0] * GLOB['MOODDIM'])

        #print "AFTER CMD ADD"
        #print GLOB['MOOD']

        return  # no return value if adding a cmd mood modifier

    if isMem:
        #print "ADDING MEMORY MOOD"

        ingestionTime = time.time()

        memProfile = "pow(2.0, -1.0*T*T/(900.0*900.0))"  # ~15 minute half life

        memDetails = [[inStr], mood, weight, memProfile]
        #print "appending: ", taskDetails

        GLOB['INGESTED'].append([memDetails, ingestionTime, "MEMORY"])
        GLOB['MOOD'] = updateMood(GLOB['MOOD'], weight=[0] * GLOB['MOODDIM'])

        #print "AFTER CMD ADD"
        #print GLOB['MOOD']

        return  # no return value if adding a cmd mood modifier

    substances = load(SETS_DIR + "substances.txt", LPC=5)
    # line 0: name(s)
    # line 1: effect
    # line 2: weight
    # line 3: profile equations
    # line 4: response formats
    '''
	for matchStr in inCmd[1]:
		matchStr= matchStr.replace('juice','')
		inStr = inStr.replace(matchStr, '')
	'''

    # find top match

    maxMatch = 0
    topSubstance = []
    for substance in substances:
        for matchPhrase in substance[0]:
            matchScore = wordSim(matches[0][0], matchPhrase, useInScore=True)
            #print matchPhrase, inStr, matchScore
            if matchScore >= maxMatch:
                maxMatch = matchScore
                topSubstance = substance

    if setting('DEBUG'):
        print "INGESTION SCORE:", topSubstance[0], " - ", maxMatch

    # topSubstance[4]:

    #replacements = [topSubstance[0][randint(0,len(topSubstance[0])-1)]]
    replacements = topSubstance[0][randint(0,
                                           len(topSubstance[0]) -
                                           1)]  #matches[0][0] #
    #rStr = processResponse(getResponse(inCmd), replacements)
    responseForm = topSubstance[4][randint(0, len(topSubstance[4]) - 1)]
    rStr = processResponse(responseForm, [replacements])

    say(rStr, more=False, speak=setting("SPEAK"))

    # now modify mood accordingly
    ingestionTime = time.time()

    #print "appending: ", topSubstance

    GLOB['INGESTED'].append([topSubstance, ingestionTime, "SUBSTANCE"])

    #print "BEFORE UPDATE"
    #print GLOB['MOOD']

    GLOB['MOOD'] = updateMood(GLOB['MOOD'], weight=[0] * GLOB['MOODDIM'])

    #print "AFTER SUBSTANCE ADD"
    #print GLOB['MOOD']

    return [topSubstance[0][0], True]
Beispiel #42
0
 def backup(self):
     self.status = 0
     # check if remote path exists
     if self.remoteFS.exists(self.remoteFS.RootPath):
         # may be data in here already
         common.debug("Remote path exists - may have old files in it",
                      "SystemRecovery")
     else:
         # make the remote directory
         self.remoteFS.mkdir(self.remoteFS.RootPath)
     # create a validation file for backup rotation
     if not self._createValidationFile():
         # we may not be able to write to this destination for some reason
         common.error(
             "Validation file can not be created, backup process skipped")
         self.status = -1
         return
     common.debug("Creating files list", "SystemRecovery")
     allFiles = []
     fileManager = FileManager(self.localFS)
     # go through each of the user selected items and write them to the backup store
     if common.setting('backup_addons'):
         fileManager.addFile("-" + common.path('special://home/addons'))
         fileManager.walkTree(common.path('special://home/addons'))
     fileManager.addFile("-" + common.path('special://home/userdata'))
     if common.setting('backup_addon_data'):
         fileManager.addFile(
             "-" + common.path('special://home/userdata/addon_data'))
         fileManager.walkTree(
             common.path('special://home/userdata/addon_data'))
     if common.setting('backup_database'):
         fileManager.addFile(
             "-" + common.path('special://home/userdata/Database'))
         fileManager.walkTree(
             common.path('special://home/userdata/Database'))
     if common.setting("backup_playlists"):
         fileManager.addFile(
             "-" + common.path('special://home/userdata/playlists'))
         fileManager.walkTree(
             common.path('special://home/userdata/playlists'))
     if common.setting('backup_profiles'):
         fileManager.addFile(
             "-" + common.path('special://home/userdata/profiles'))
         fileManager.walkTree(
             common.path('special://home/userdata/profiles'))
     if common.setting("backup_thumbnails"):
         fileManager.addFile(
             "-" + common.path('special://home/userdata/Thumbnails'))
         fileManager.walkTree(
             common.path('special://home/userdata/Thumbnails'))
     if common.setting("backup_config"):
         fileManager.addFile("-" +
                             common.path('special://home/userdata/keymaps'))
         fileManager.walkTree(
             common.path('special://home/userdata/keymaps'))
         fileManager.addFile(
             "-" + common.path('special://home/userdata/peripheral_data'))
         fileManager.walkTree(
             common.path('special://home/userdata/peripheral_data'))
         fileManager.addFile('-' +
                             common.path('special://home/userdata/library'))
         fileManager.walkTree(
             common.path('special://home/userdata/library'))
         # this part is an oddity
         dirs, configFiles = self.localFS.listdir(
             common.path('special://home/userdata/'))
         for aFile in configFiles:
             if aFile.endswith(".xml"):
                 fileManager.addFile(
                     common.path('special://home/userdata/') + aFile)
     # add to array
     allFiles.append({
         "source": self.localFS.RootPath,
         "dest": self.remoteFS.RootPath,
         "files": fileManager.getFiles()
     })
     orig_base_path = self.remoteFS.RootPath
     # check if there are custom directories
     if common.setting('custom_dir_1_enable') and common.setting(
             'backup_custom_dir_1'
     ) is not None and common.setting('backup_custom_dir_1') != '':
         # create a special remote path with hash
         self.localFS.setRootPath(common.setting('backup_custom_dir_1'))
         fileManager.addFile("-custom_" +
                             self._createCRC(self.localFS.RootPath))
         # walk the directory
         fileManager.walkTree(self.localFS.RootPath)
         allFiles.append({
             "source":
             self.localFS.RootPath,
             "dest":
             self.remoteFS.RootPath + "custom_" +
             self._createCRC(self.localFS.RootPath),
             "files":
             fileManager.getFiles()
         })
     if common.setting('custom_dir_2_enable') and common.setting(
             'backup_custom_dir_2'
     ) is not None and common.setting('backup_custom_dir_2') != '':
         # create a special remote path with hash
         self.localFS.setRootPath(common.setting('backup_custom_dir_2'))
         fileManager.addFile("-custom_" +
                             self._createCRC(self.localFS.RootPath))
         # walk the directory
         fileManager.walkTree(self.localFS.RootPath)
         allFiles.append({
             "source":
             self.localFS.RootPath,
             "dest":
             self.remoteFS.RootPath + "custom_" +
             self._createCRC(self.localFS.RootPath),
             "files":
             fileManager.getFiles()
         })
     if common.setting('custom_dir_3_enable') and common.setting(
             'backup_custom_dir_3'
     ) is not None and common.setting('backup_custom_dir_3') != '':
         # create a special remote path with hash
         self.localFS.setRootPath(common.setting('backup_custom_dir_3'))
         fileManager.addFile("-custom_" +
                             self._createCRC(self.localFS.RootPath))
         # walk the directory
         fileManager.walkTree(self.localFS.RootPath)
         allFiles.append({
             "source":
             self.localFS.RootPath,
             "dest":
             self.remoteFS.RootPath + "custom_" +
             self._createCRC(self.localFS.RootPath),
             "files":
             fileManager.getFiles()
         })
     # backup all the files
     for fileGroup in allFiles:
         self.localFS.setRootPath(fileGroup['source'])
         self.remoteFS.setRootPath(fileGroup['dest'])
         filesCopied = self.backupFiles(fileGroup['files'], self.localFS,
                                        self.remoteFS)
         if not filesCopied:
             common.warn(
                 "Not all files were copied: %s" % self.localFS.RootPath,
                 "SystemRecovery")
             self.status += 1
     # reset remote and xbmc vfs
     self.localFS.setRootPath("special://home/")
     self.remoteFS.setRootPath(orig_base_path)
     # send the zip file to the real remote vfs
     if common.setting("compress_backups"):
         zip_name = self.remoteFS.RootPath[:-1] + ".zip"
         self.remoteFS.cleanup()
         self.localFS.rename(common.path("special://temp/backup.zip"),
                             common.path("special://temp/" + zip_name))
         fileManager.addFile(common.path("special://temp/" + zip_name))
         # set root to data dir home
         self.localFS.setRootPath(common.path("special://temp/"))
         self.remoteFS = self.savedRemoteFS
         fileCopied = self.backupFiles(fileManager.getFiles(), self.localFS,
                                       self.remoteFS)
         if not fileCopied:
             # zip archive copy filed, inform the user
             common.warn("The destination may not be writeable: %s" %
                         self.remoteFS.RootPath)
             self.ststus = -1
             return
         # delete the temp zip file
         self.localFS.rmfile(common.path("special://temp/" + zip_name))
     # remove old backups
     self._rotateBackups()
Beispiel #43
0
def updateMood(mood, instant=False, weight=[0.]*GLOB['MOODDIM']):
	rotateCircle(index=1, angle=15)

	#MOOD = GLOB['MOOD']

	# if the input mood is associated with an string with no moods,
	#    don't recalculate the mood
	#if all(val == 0 for val in mood):
	if mood == []:
		#print "NULL MOOD"
		return GLOB['MOOD']



	loneliness, time_alone = lonelyFactor()
	substanceEffect, Sweights =ingestionMood(moodType="SUBSTANCE") # effect of substance on mood

	taskEffect, taskWeights =ingestionMood(moodType="COMMAND") # effect of substance on mood

	settingsEffect, settingsWeight = settingsMoodVec() # effect on mood by settings values

	needsEffect, needsWeights = needsMoodFactor()

	timeWeights = [0]*GLOB['MOODDIM']
	#timeWeights = [0.0, 0.25, 0.0]
	timeWeights[1] = 0.25
	timeWeights[3] = 0.1

	#Vfactor = [loneliness, variabilityFactor(), 0]
	Vfactor = [0]*GLOB['MOODDIM']
	Vfactor[5] = loneliness
	Vfactor[1] = variabilityFactor()


	Vweights = [0]*GLOB['MOODDIM']
	Vweights[5] = 0.5 #pow(2.0, -1.0*time_alone/60.0) # 
	Vweights[1] = 0.2
	#Vweights = [0.2, pow(2.0, -1.0*time_alone/60.0), 0.0]


	''' SET MOOD FACTORS AND WEIGHTS'''

	FACTORS=[GLOB['MOOD'], # previous mood
			mood, # new mood to take into account
			partMoodVec(setting("DEFAULT_MOOD")), # default mood state
			timeFactor(), # time dependent mood
			Vfactor, # input variation and amount
			substanceEffect, # effect of substance on mood
			taskEffect,
			settingsEffect,
			needsEffect]
			

	WEIGHTS=[[1.0]*GLOB['MOODDIM'], # O weights
			weight, # N weights
			[0.15]* GLOB['MOODDIM'], # Dweights
			timeWeights, # T weights
			Vweights, # Vweights
			[Sweights[i]*setting("SUBSTANCE_EFFECT") for i in range(GLOB['MOODDIM'])], # S weights
			[taskWeights[i]*setting("TASK_EFFECT") for i in range(GLOB['MOODDIM'])],
			settingsWeight,
			needsWeights]
			


	''' CONSTRUCT NEW MOOD VECTOR '''
	
	NEEDvals = [[FACTORS[j][i] for j in range(len(FACTORS))] for i in range(GLOB['MOODDIM'])]
	NEEDweights = [[WEIGHTS[j][i] for j in range(len(FACTORS))] for i in range(GLOB['MOODDIM'])]

	newNEED=[0 for i in range(GLOB['MOODDIM'])]
	for j in range(GLOB['MOODDIM']):

		newNEED[j] = [NEEDweights[j][i] * NEEDvals[j][i] for i in range(len(FACTORS))]
		newNEED[j] = sum(newNEED[j]) / sum(NEEDweights[j])

	return newNEED
Beispiel #44
0
# -*- coding: utf-8 -*-
Beispiel #45
0
def moodReport(inCmd, inStr, matches=[[],[]]):
	from common import say, getResponse
	from Fermi import stateSummary
	from satisfactionMaximization import IV

	reportType="short"
	if "report" in inStr:
		reportType = "full"


	PREVMOOD = GLOB['PREVMOOD']
	MOOD = GLOB['MOOD']
	INGESTED = GLOB['INGESTED']

	if reportType == "short":
		#mVec = copy.deepcopy(MOOD)
		#mVec = fullMoodVec(mVec)
		

		Fm = fullMoodVec(MOOD,pronoun=True) # weight vector
		Fm.sort(key=lambda tup: tup[1])
		Fm.reverse()

		#curFace = getFace(MOOD)
		#rStr = "I am feeling "+curFace[2]+"."
		
		rStr = "I am feeling "+Fm[0][0]
		if Fm[0][0] >= 0:
			rStr += ", but"
		else:
			rStr += ", and"

		#print "HERE"


		# sort by weight
		Fw = fullMoodVec(IV(),colloquial=True) # weight vector
		Fw.sort(key=lambda tup: tup[1])
		Fw.reverse()

		topNeed = Fw[0]
		if topNeed[1] >= 0.85:
			rStr += " I am badly in need of some "+topNeed[0]+'.'
		elif topNeed[1] >= 0.5:
			rStr += " I am in need of some "+topNeed[0]+'.'
		elif topNeed[1] >= 0.25:
			rStr += " I could use some "+topNeed[0]+'.'
		else:
			rStr += " I wouldn't mind some "+topNeed[0]+'.'


		say(rStr, more=False, speak=setting("SPEAK"), location="history")
		
		#topThought = m.getTopSentence(QV, ["", GLOB['MOOD']])
		#print k.sf(topThought[1], 3)
		#say('*'+topThought[0]+'*', more=False, speak=setting("SPEAK"), moodUpdate=True)


	else:

		# want to get previous mood before AI talks about mood report
		prevFace = getFace(PREVMOOD)

		say(getResponse(inCmd), more=False, speak=setting("SPEAK"))

		curFace = getFace(MOOD)
		
		SMood, iWeights = ingestionMood(moodType="SUBSTANCE")
		imVec = [SMood[i]*iWeights[i] for i in range(GLOB['MOODDIM'])]
		iFace = getFace(SMood)
		
		T = timeFactor()

		print
		print " Current mood:", curFace[2] 
		print "     Emoticon:", curFace[0]
		#print "\n     %s" % ''.join('%s'%MOOD)
		stateSummary()

		print
		print "Previous mood:", prevFace[2]
		print "     Emoticon:", prevFace[0]
		#print "\n     %s" % ''.join('%s'%PREVMOOD)
		stateSummary(PREVMOOD)

		print
		print "Mood from ingestions"
		print "     Emoticon:", iFace[0]
		#print "\n     %s" % ''.join('%s'%imVec)
		stateSummary(imVec)

		print
		print "Mood from time of day"
		print "     Emoticon:", getFace(T)[0]
		print "      Arousal: %.2f" % T[1]
	return True
Beispiel #46
0
def deltaMoodQuery(inCmd=[], inStr="", matches=[[],[]], fromAuto=False):
	from common import say
	from random import random
	# how did that make you feel?
	# -> diff between prevmood and mood
	#print "PREV MOOD:", GLOB['CMDHIST'][len(GLOB['CMDHIST'])]
	#print "CUR MOOD:", GLOB['MOOD']

	cNum = len(GLOB['CMDHIST'])

	saidSomething = False

	if cNum >= 3:

		#print "HERE"

		oldMood = GLOB['CMDHIST'][cNum-2][3]
		newMood = GLOB['CMDHIST'][cNum-1][3]

		

		deltaMood = [newMood[i] - oldMood[i] for i in range(GLOB['MOODDIM'])]

		maxDelta = max([abs(item) for item in deltaMood])
		
		# only tell mood with certain probability if fromAuto
		#if setting('VERBOSE_MOOD')*maxDelta < random() and fromAuto:
		deltaThreshold = 2.0*(1.0 - setting('VERBOSE_MOOD'))
		if maxDelta < deltaThreshold and fromAuto:
			#print "maxDelta:", maxDelta
			return False #True

		
		feelings=[]
		for i in range(len(deltaMood)):
			item = deltaMood[i]
			if abs(item) >= 0.75:
				feelings.append("a lot more "+getStatePronoun(i, positive=item>0))
			elif abs(item) >= 0.5:
				feelings.append(getStatePronoun(i, positive=item>0))
			elif abs(item) >= 0.3:
				feelings.append("a little more "+getStatePronoun(i, positive=item>0))

		if len(feelings) == 0:
			if not fromAuto:
				say("That did not really affect me.", more=False, speak=setting("SPEAK"))
				saidSomething= True
		else:
			if not fromAuto:
				say("I am feeling "+listize(feelings)+'.', more=False, speak=setting("SPEAK"))
			else:
				#tkTopClear()
				tkTopCat("*That made me feel "+listize(feelings)+'.*')
			saidSomething = True
		'''
		elif len(feelings) == 1:
			say("I am feeling "+feelings[0]+'.', more=False, speak=setting("SPEAK"))
		elif len(feelings) == 2:
			say("I am feeling "+' and '.join(feelings)+'.', more=False, speak=setting("SPEAK"))
		else:
			say("I am feeling "+', '.join(feelings)+'.', more=False, speak=setting("SPEAK"))
		'''


	else:
		if not fromAuto:
			say("I'm not sure.", more=False, speak=setting("SPEAK"))
			saidSomething = True


	return saidSomething #True
Beispiel #47
0
def ingest(inCmd, inStr, mood=[], weight=[], isCmd=False, isMem=False, matches=[[],[]]):
	from common import wordSim, processResponse, getResponse, say
	#from loadFile import load
	from determineFunction import findCMD, refineMatches
	from Fermi import substituteBiographicMemory

	if not (isCmd or isMem):
		matches = refineMatches(inCmd, inStr)
		matches = substituteBiographicMemory(matches, queryType='what is')

	if len(matches[0]) ==0 and not (isCmd or isMem):
		say(getResponse(findCMD("rephrase")), more=False, speak=setting("SPEAK"), moodUpdate=True)
		return False

	'''
	Algorithm:
		- load substance from list
		- record ingestion time
		- append to INGESTED list

	'''

	if isCmd:
		ingestionTime = time.time()
		
		taskProfile="pow(2.0, -1.0*T*T/(900.0*900.0))" # ~15 minute half life
		
		taskDetails = [[inCmd[0]], mood, weight, taskProfile]
		#print "appending: ", taskDetails

		GLOB['INGESTED'].append([taskDetails, ingestionTime, "COMMAND"])
		GLOB['MOOD']=updateMood(GLOB['MOOD'], weight=[0]*GLOB['MOODDIM'])
		
		#print "AFTER CMD ADD"
		#print GLOB['MOOD']

		return # no return value if adding a cmd mood modifier

	if isMem:
		#print "ADDING MEMORY MOOD"

		ingestionTime = time.time()
		
		memProfile="pow(2.0, -1.0*T*T/(900.0*900.0))" # ~15 minute half life
		


		memDetails = [[inStr], mood, weight, memProfile]
		#print "appending: ", taskDetails

		GLOB['INGESTED'].append([memDetails, ingestionTime, "MEMORY"])
		GLOB['MOOD']=updateMood(GLOB['MOOD'], weight=[0]*GLOB['MOODDIM'])
		
		#print "AFTER CMD ADD"
		#print GLOB['MOOD']

		return # no return value if adding a cmd mood modifier




	substances = load(SETS_DIR+"substances.txt", LPC=5)
	# line 0: name(s)
	# line 1: effect
	# line 2: weight
	# line 3: profile equations
	# line 4: response formats

	'''
	for matchStr in inCmd[1]:
		matchStr= matchStr.replace('juice','')
		inStr = inStr.replace(matchStr, '')
	'''

	# find top match

	maxMatch=0
	topSubstance=[]
	for substance in substances:
		for matchPhrase in substance[0]:
			matchScore = wordSim(matches[0][0], matchPhrase, useInScore=True)
			#print matchPhrase, inStr, matchScore
			if matchScore >= maxMatch:
				maxMatch = matchScore
				topSubstance = substance

	if setting('DEBUG'):
		print "INGESTION SCORE:", topSubstance[0], " - ", maxMatch

	# topSubstance[4]: 

	#replacements = [topSubstance[0][randint(0,len(topSubstance[0])-1)]]
	replacements = topSubstance[0][randint(0,len(topSubstance[0])-1)] #matches[0][0] #
	#rStr = processResponse(getResponse(inCmd), replacements)
	responseForm = topSubstance[4][randint(0,len(topSubstance[4])-1)]
	rStr = processResponse(responseForm, [replacements])
	
	say(rStr, more=False, speak=setting("SPEAK"))



	# now modify mood accordingly
	ingestionTime = time.time()

	#print "appending: ", topSubstance



	GLOB['INGESTED'].append([topSubstance, ingestionTime, "SUBSTANCE"])


	#print "BEFORE UPDATE"
	#print GLOB['MOOD']

	GLOB['MOOD']=updateMood(GLOB['MOOD'], weight=[0]*GLOB['MOODDIM'])

	#print "AFTER SUBSTANCE ADD"
	#print GLOB['MOOD']

	return [topSubstance[0][0], True]