本文整理汇总了Python中Data.dataAccess.DataAccess.getUserPreferences方法的典型用法代码示例。如果您正苦于以下问题:Python DataAccess.getUserPreferences方法的具体用法?Python DataAccess.getUserPreferences怎么用?Python DataAccess.getUserPreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.dataAccess.DataAccess
的用法示例。
在下文中一共展示了DataAccess.getUserPreferences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: RobotCommands
# 需要导入模块: from Data.dataAccess import DataAccess [as 别名]
# 或者: from Data.dataAccess.DataAccess import getUserPreferences [as 别名]
class RobotCommands(object):
def __init__(self):
self._dao = DataAccess()
exposed = True
def POST(self, *args, **kwargs):
request = json.loads(cherrypy.request.body.read())
# Send the robot to certain location
if request.has_key('location'):
object = self._dao.getLocationByName(request['location']);
robot = Factory.getCurrentRobot();
robot.setComponentState('tray', request['tray'])
robot.setComponentState('base', [object['xCoord'], object['yCoord'], object['orientation']])
# Send voice command to the robot (espeak software required)
elif request.has_key('speech'):
if self._dao.getUserPreferences()[0]['voice'] == 1:
import subprocess
#subprocess.call(['C:\\Program Files (x86)\\eSpeak\\command_line\\espeak.exe', request['speech']]) #Windows
subprocess.call(['espeak', request['speech']]); #Linux
else:
raise cherrypy.HTTPError(400)
示例2: UserData
# 需要导入模块: from Data.dataAccess import DataAccess [as 别名]
# 或者: from Data.dataAccess.DataAccess import getUserPreferences [as 别名]
class UserData(object):
def __init__(self):
self._dao = DataAccess()
exposed = True
def GET(self, *args, **kwargs):
if len(args) < 1:
raise cherrypy.HTTPError(400)
questionNo = args[0]
if questionNo == 'preferences':
value = self._dao.getUserPreferences()
elif questionNo == 'persona':
value = self._dao.getPersonaValues()
elif questionNo == 'username':
value = self._dao.getActiveUserName()
elif questionNo == 'experimentLocation':
value = self._dao.getActiveExperimentLocation()
cherrypy.response.headers['Content-Type'] = 'application/json'
return json.dumps(value)
def POST(self, *args, **kwargs):
request = json.loads(cherrypy.request.body.read())
if request.has_key('time'):
time = datetime.datetime.now().strftime('%H:%M:%S') #strftime('%Y-%m-%d %H:%M:%S')
self._dao.setSessionControlTime(time)
elif request.has_key('preferences'):
for column, value in request.iteritems():
if column != 'preferences':
print column + " " + value
self._dao.setUserPreferences(column, value)
else:
raise cherrypy.HTTPError(400)