Reply
Thread Tools
Posts: 187 | Thanked: 41 times | Joined on May 2010
#1
Hi guys , how can i convert the following statement to python + dbus ?

dbus-send --system --type=method_call --print-reply --dest=com.nokia.phone.SIM /com/nokia/phone/SIM Phone.Sim.get_imsi
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#2
Check the current Healthcheck code - it was done in python and uses dbus as well as terminal commands

(It will be replaced with a c++ version shortly though!)

But here's an example of using dbus from within python

Code:
def funcDevOri():
        print "** Start Function - Device Orientation **"
        bus = dbus.SystemBus()             
        accel = bus.get_object('com.nokia.mce','/com/nokia/mce/request','com.nokia.mce.request') 

        orientation , stand , face , x , y , z = accel.get_device_orientation()
        return orientation

Or.....
(This is the one you want, as it gets the IMEI, so not too far from what you need!!)
Code:
def funcIMEI():
        print "** Start Function - Device IMEI **"
        b = os.popen('run-standalone.sh dbus-send --system --print-reply --type=method_call --dest=com.nokia.phone.SIM /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei').read()
        b = str(b)
        b = b.strip()
        b = str(b)[-27:]
        b = b.strip()
        b = str(b)[:-12]
        return b
or

Code:
def FMTxPropertiesInterfaceConnect():
	bus = dbus.SystemBus()
	dbus_object = bus.get_object('com.nokia.FMTx', '/com/nokia/fmtx/default', False)
	dbus_interface = dbus.Interface(dbus_object, dbus_interface='org.freedesktop.DBus.Properties')
	return dbus_interface
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 

The Following 2 Users Say Thank You to noobmonkey For This Useful Post:
Posts: 187 | Thanked: 41 times | Joined on May 2010
#3
Originally Posted by noobmonkey View Post
Check the current Healthcheck code - it was done in python and uses dbus as well as terminal commands

(It will be replaced with a c++ version shortly though!)

But here's an example of using dbus from within python

Code:
def funcDevOri():
        print "** Start Function - Device Orientation **"
        bus = dbus.SystemBus()             
        accel = bus.get_object('com.nokia.mce','/com/nokia/mce/request','com.nokia.mce.request') 

        orientation , stand , face , x , y , z = accel.get_device_orientation()
        return orientation

Or.....
(This is the one you want, as it gets the IMEI, so not too far from what you need!!)
Code:
def funcIMEI():
        print "** Start Function - Device IMEI **"
        b = os.popen('run-standalone.sh dbus-send --system --print-reply --type=method_call --dest=com.nokia.phone.SIM /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei').read()
        b = str(b)
        b = b.strip()
        b = str(b)[-27:]
        b = b.strip()
        b = str(b)[:-12]
        return b
or

Code:
def FMTxPropertiesInterfaceConnect():
	bus = dbus.SystemBus()
	dbus_object = bus.get_object('com.nokia.FMTx', '/com/nokia/fmtx/default', False)
	dbus_interface = dbus.Interface(dbus_object, dbus_interface='org.freedesktop.DBus.Properties')
	return dbus_interface

isn't there a way to conver this statement to a python+dbus call...
Calling dbus-send sometimes blocks and i get zombie proccesses.

dbus-send --system --print-reply --type=method_call --dest=com.nokia.phone.SIM /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#4
Hi colchaodemola,

not sure what you mean?
There are 3 different ways to do it above and the middle one will output the imei exactly as yuo want it in python?
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 187 | Thanked: 41 times | Joined on May 2010
#5
Hi noobmonkey, it is better i explain with examples:
i can turn this dbus-send call

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"message"

IN

import dbus
bus = dbus.SystemBus()
iface = dbus.Interface(bus.get_object('org.freedesktop.Not ifications',
'/org/freedesktop/Notifications'),
'org.freedesktop.Notifications')
iface.SystemNoteInfoprint('message')


but how can i convert bus-send --system --print-reply --type=method_call --dest=com.nokia.phone.SIM /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei' in to that second way ?
 
noobmonkey's Avatar
Posts: 3,203 | Thanked: 1,391 times | Joined on Nov 2009 @ Worthing, England
#6
Originally Posted by colchaodemola View Post
Hi noobmonkey, it is better i explain with examples:
i can turn this dbus-send call

dbus-send --type=method_call --dest=org.freedesktop.Notifications /org/freedesktop/Notifications org.freedesktop.Notifications.SystemNoteInfoprint string:"message"

IN

import dbus
bus = dbus.SystemBus()
iface = dbus.Interface(bus.get_object('org.freedesktop.Not ifications',
'/org/freedesktop/Notifications'),
'org.freedesktop.Notifications')
iface.SystemNoteInfoprint('message')


but how can i convert bus-send --system --print-reply --type=method_call --dest=com.nokia.phone.SIM /com/nokia/phone/SIM/security Phone.Sim.Security.get_imei' in to that second way ?
import dbus
bus = dbus.SystemBus()
iface = dbus.Interface(bus.get_object('com.nokia.phone.SIM ',
'/com/nokia/phone/SIM/security Phone.Sim.Security.get_imei'),
iface.SystemNoteInfoprint('get_imei')

i think, not sure though, will take alook tonight
__________________
----------- Follow me on Twitter here
----------- My Photography Website and Blog is here
----------- Author of the N900 Health Check Application ----------- New Version in Extras Devel (Dec 2010 - 2.9.10)
----------- Are you on the N900 World Map? - http://pininthemap.com/maemo - masterpin: shotgun
----------- What apps do you want to see on the n900 or in MeeGo in the future? -
 
Posts: 3 | Thanked: 2 times | Joined on Dec 2010
#7
import dbus

bus = dbus.SystemBus()
imsiObj = bus.get_object('com.nokia.phone.SIM', '/com/nokia/phone/SIM')
imsiiface = dbus.Interface(imsiObj, 'Phone.Sim')
print imsiiface.get_imsi()[0]
 

The Following 2 Users Say Thank You to salatiel For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 21:58.