带有传感器和 xprofile 模块的诺基亚 N95 和 PyS60

发布于 2024-07-21 08:14:33 字数 1003 浏览 5 评论 0原文

我制作了一个 python 脚本,它应该根据手机位置修改手机的配置文件。 在 ScriptShell 下运行它效果很好。

问题是它挂起,无论是在“启动”时运行“sis”脚本还是没有运行“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 和我的开发人员证书。

提前致谢

I've made a python script which should modify the profile of the phone based on the phone position. Runned under ScriptShell it works great.

The problem is that it hangs, both with the "sis" script runned upon "boot up", as well as without it.

So my question is what is wrong with the code, and also whether I need to pass special parameters to 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()

The script starts at boot, using ensymble and my developer certificate.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

木有鱼丸 2024-07-28 08:14:33

我经常在脚本顶部使用类似的内容:

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)

I often use something like that at the top of my scripts:

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)
淡看悲欢离合 2024-07-28 08:14:33

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')

顺便说一句,make clean exit,执行以下操作:


    appuifw.app.menu = [(u'Close', exit_key_handler)]

xprofile is not a standard library, make sure you add path to it. My guess is that when run as SIS, it doesn't find xprofile and hangs up. When releasing your SIS, either instruct that users install that separately or include inside your SIS.

Where would you have it installed, use that path. Here's python default directory as sample:


    # 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')

Btw make clean exit, do this:


    appuifw.app.menu = [(u'Close', exit_key_handler)]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文