带有传感器和Xprofile模块的诺基亚N95和PYS60
题
我制作了一个Python脚本,该脚本应该根据电话位置修改手机的配置文件。在Scriptshell下运行它很棒。
问题在于它悬挂了,既有“ sis”脚本,也没有它。
因此,我的问题是代码有什么问题,以及我是否需要将特殊参数传递给Ensymble?
import appuifw, e32, sensor, xprofile
from appuifw import *
old_profil = xprofile.get_ap()
def get_sensor_data(status):
#decide profile
def exit_key_handler():
# Disconnect from the sensor and exit
acc_sensor.disconnect()
app_lock.signal()
app_lock = e32.Ao_lock()
appuifw.app.exit_key_handler = exit_key_handler
appuifw.app.title = u"Acc Silent"
appuifw.app.menu = [(u'Close', app_lock.signal)]
appuifw.app.body = Canvas()
# Retrieve the acceleration sensor
sensor_type= sensor.sensors()['AccSensor']
# Create an acceleration sensor object
acc_sensor= sensor.Sensor(sensor_type['id'],sensor_type['category'])
# Connect to the sensor
acc_sensor.connect(get_sensor_data)
# Wait for sensor data and the exit event
app_lock.wait()
脚本从启动开始,使用Ensymble和我的开发人员证书。
提前致谢
解决方案
我经常在脚本的顶部使用类似的东西:
import os.path, sys
PY_PATH = None
for p in ['c:\\Data\\Python', 'e:\\Data\\Python','c:\\Python','e:\\Python']:
if os.path.exists(p):
PY_PATH = p
break
if PY_PATH and PY_PATH not in sys.path: sys.path.append(PY_PATH)
其他提示
Xprofile不是标准库,请确保您添加路径。我的猜测是,当按SIS运行时,它找不到Xprofile并挂断电话。发布SIS时,要么指示用户单独安装或在SIS中包含该安装。
您将在哪里安装它,请使用该路径。这是python默认目录作为示例:
# PyS60 1.9.x and above
sys.path.append('c:\\Data\\Python')
sys.path.append('e:\\Data\\Python')
# Pys60 1.4.x or below
sys.path.append('c:\\Python')
sys.path.append('e:\\Python')
顺便说一句,干净出口,这样做:
appuifw.app.menu = [(u'Close', exit_key_handler)]
不隶属于 StackOverflow