我很困惑。
我编写了这段代码
if __name__ == '__main__':
channel=None
devices = finddevices()
print 'devices %s'%devices
for d in devices:
print d[0]
ser=findservices(addr=d[0],name=None,servicetype=OBEX)
print ser
for s in ser:
print s
if 'OBEX Object Push' in s[2]:
channel=s[1]
obex.sendfile(d[0], channel, '/home/mobile.jar')
如果我在 python shell 中逐行编写它工作正常。
如果我设置断点并调试并使用 F6 键逐步执行所有操作,则可以正常工作。
但是,如果我通过ispython mycode.py
的值在 eclipse 或终端中正常执行它。ser
None
怎么了?
为什么findservices()
在代码的正常执行过程中无法工作?
编辑:
这是service=findservices()
python shell中的输出(在正常运行期间的eclipse中它总是[])
>>> services=findservices()
services [('6C:0E:0D:3A:1F:90', 2, '串口 1'), ('6C:0E:0D:3A:1F:90', 1, '拨号网络') , ('6C:0E:0D:3A:1F:90', 10, 'OBEX SyncML Client'), ('6C:0E:0D:3A:1F:90', 25, '音乐流服务'), ( '6C:0E:0D:3A:1F:90', 23, '远程控制目标服务'), ('6C:0E:0D:3A:1F:90', 23, '远程控制服务'), (' 6C:0E:0D:3A:1F:90', 2, 'SEMC Watch Phone'), ('6C:0E:0D:3A:1F:90', 15, 'PAN 网络接入点'), ('6C :0E:0D:3A:1F:90', 15, 'PAN 用户'), ('6C:0E:0D:3A:1F:90', 5, '免提网关'), ('6C:0E :0D:3A:1F:90', 4, '耳机网关'), ('6C:0E:0D:3A:1F:90', 6, 'OBEX对象推送'), ('6C:0E:0D: 3A:1F:90', 7, 'OBEX 文件传输'),('6C:0E:0D:3A:1F:90', 8, 'OBEX IrMC 同步服务器'), ('6C:0E:0D:3A:1F:90', 17, 'HID 鼠标和键盘'), ('6C:0E:0D:3A:1F:90', 61689, 'SEMC HLA'), ('6C:0E:0D:3A:1F:90', 11, '电话簿访问 PSE')]