/usr/bin/cli-framework is in fso-frameworkd 0.8.5.1-1.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
Interactive console for the freesmartphone.org framework
(C) 2008 Michael 'Mickey' Lauer <mlauer@vanille-media.de>
(C) 2008 Jan 'Shoragan' Lübbe <jluebbe@lasnet.de>
(C) 2008 Openmoko, Inc.
GPLv2 or later
"""
__version__ = "0.9.3.1"
import dbus.service
import dbus.mainloop.glib
from gobject import MainLoop
import os, sys, code, pprint, types, atexit
pp = pprint.PrettyPrinter( indent=4 )
#----------------------------------------------------------------------------#
def dbus_to_python( v ):
#----------------------------------------------------------------------------#
class ObjectPath( object ):
def __init__( self, path ):
self.path = str( path )
def __repr__( self ):
return "op%s" % repr(self.path)
if isinstance(v, dbus.Byte) \
or isinstance(v, dbus.Int64) \
or isinstance(v, dbus.UInt64) \
or isinstance(v, dbus.Int32) \
or isinstance(v, dbus.UInt32) \
or isinstance(v, dbus.Int16) \
or isinstance(v, dbus.UInt16) \
or type(v) == types.IntType:
return int(v)
elif isinstance(v, dbus.Double) or type(v) == types.FloatType:
return float(v)
elif isinstance(v, dbus.String) or type(v) == types.StringType:
return str(v)
elif isinstance(v, dbus.Dictionary) or type(v) == types.DictType:
return dict( (dbus_to_python(k), dbus_to_python(v)) for k,v in v.iteritems() )
elif isinstance(v, dbus.Array) or type(v) == types.ListType:
return [dbus_to_python(x) for x in v]
elif isinstance(v, dbus.Struct) or type(v) == types.TupleType:
return tuple(dbus_to_python(x) for x in v)
elif isinstance(v, dbus.Boolean) or type(v) == types.BooleanType:
return bool(v)
elif isinstance(v, dbus.ObjectPath) or type(v) == ObjectPath:
return ObjectPath(v)
else:
return v
raise TypeError("Can't convert type %s to python object" % type(v))
#----------------------------------------------------------------------------#
def prettyPrint( expression ):
#----------------------------------------------------------------------------#
if expression is not None:
pp.pprint( dbus_to_python(expression) )
#----------------------------------------------------------------------------#
def handler( *args, **kwargs ):
#----------------------------------------------------------------------------#
if kwargs["path"].startswith( "/org/freesmartphone" ):
print "[SIGNAL] %s.%s from " % ( kwargs["interface"], kwargs["member"] ),
print "%s via %s" % ( kwargs["path"], kwargs["sender"] )
for arg in args[:-1]:
print "%s, " % arg,
print "%s" % args[-1]
print ">>> ",
sys.stdout.flush()
#----------------------------------------------------------------------------#
def getObject( busname, objectpath ):
#----------------------------------------------------------------------------#
return bus.get_object( busname, objectpath, follow_name_owner_changes=True )
#----------------------------------------------------------------------------#
def getInterface( busname, objectpath, interface ):
#----------------------------------------------------------------------------#
try:
proxy = getObject( busname, objectpath )
iface = dbus.Interface( proxy, interface )
except dbus.DBusException:
print "DBus Exception. Can't get %s@%s:%s" % ( interface, busname, objectpath )
return None
else:
return iface
#----------------------------------------------------------------------------#
def getObjectsForInterface( busname, interface ):
#----------------------------------------------------------------------------#
try:
paths = dbus_hlid.ListObjectsByInterface( busname, interface, dbus_interface="org.freesmartphone.DBus" )
except dbus.DBusException, e:
print "DBus Exception. dbus-hlid not installed"
paths = []
result = {}
for path in paths:
result[str(path)] = getInterface( busname, path, interface )
return result
dbus.mainloop.glib.DBusGMainLoop( set_as_default=True )
mainloop = MainLoop()
bus = dbus.SystemBus()
# FIXME use introspection
# dbus_hlid object
dbus_hlid = getObject( "org.freesmartphone.DBus", "/org/freesmartphone/DBus" )
# framework object
framework = getObject( "org.freesmartphone.frameworkd", "/org/freesmartphone/Framework" )
# ogsmd device object
gsm = getObject( "org.freesmartphone.ogsmd", "/org/freesmartphone/GSM/Device" )
# ogps device object
gps = getObject( "org.freesmartphone.ogpsd", "/org/freedesktop/Gypsy" )
# usage device object
usage = getObject( "org.freesmartphone.ousaged", "/org/freesmartphone/Usage" )
# network
network = getInterface( \
"org.freesmartphone.onetworkd",
"/org/freesmartphone/Network",
"org.freesmartphone.Network" )
# testing
testing = getInterface( \
"org.freesmartphone.testing",
"/org/freesmartphone/Testing",
"org.freesmartphone.Testing" )
# framework
frameworkiface = getInterface( \
"org.freesmartphone.frameworkd",
"/org/freesmartphone/Framework",
"org.freesmartphone.Framework" )
# odeviced objects
devaudio = getInterface( \
"org.freesmartphone.odeviced",
"/org/freesmartphone/Device/Audio",
"org.freesmartphone.Device.Audio" )
devidle = getInterface( \
"org.freesmartphone.odeviced",
"/org/freesmartphone/Device/IdleNotifier/0",
"org.freesmartphone.Device.IdleNotifier" )
devrtc = getInterface( \
"org.freesmartphone.odeviced",
"/org/freesmartphone/Device/RealTimeClock/0",
"org.freesmartphone.Device.RealTimeClock" )
try:
display = getObjectsForInterface( "org.freesmartphone.odeviced", "org.freesmartphone.Device.Display" ).values()[0]
except IndexError:
pass
try:
bat = getObjectsForInterface( "org.freesmartphone.odeviced", "org.freesmartphone.Device.PowerSupply" ).values()[0]
except IndexError:
pass
leds = getObjectsForInterface( "org.freesmartphone.odeviced", "org.freesmartphone.Device.LED" ).values()
# omuxerd object
muxer = getInterface( \
"org.freesmartphone.omuxerd",
"/org/freesmartphone/GSM/Muxer",
"org.freesmartphone.GSM.MUX" )
# ogsmd device objects
gsmdevice = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.Device" )
gsmsim = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.SIM" )
gsmsms = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.SMS" )
gsmnetwork = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.Network" )
gsmcall = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.Call" )
gsmcb = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.CB" )
gsmpdp = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.PDP" )
gsmmonitor = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.Monitor" )
gsmtest = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.Test" )
gsmdebug = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Device",
"org.freesmartphone.GSM.Debug" )
# ogsmd server objects
gsmdata = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Server",
"org.freesmartphone.GSM.Data" )
gsmhz = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Server",
"org.freesmartphone.GSM.HZ" )
gsmphone = getInterface( \
"org.freesmartphone.ogsmd",
"/org/freesmartphone/GSM/Server",
"org.freesmartphone.GSM.Phone" )
# ogps
gpsaccuracy = getInterface( \
"org.freesmartphone.ogpsd",
"/org/freedesktop/Gypsy",
"org.freedesktop.Gypsy.Accuracy" )
gpsposition = getInterface( \
"org.freesmartphone.ogpsd",
"/org/freedesktop/Gypsy",
"org.freedesktop.Gypsy.Position" )
gpssatellite = getInterface( \
"org.freesmartphone.ogpsd",
"/org/freedesktop/Gypsy",
"org.freedesktop.Gypsy.Satellite" )
gpstime = getInterface( \
"org.freesmartphone.ogpsd",
"/org/freedesktop/Gypsy",
"org.freedesktop.Gypsy.Time" )
ubxdebug = getInterface( \
"org.freesmartphone.ogpsd",
"/org/freedesktop/Gypsy",
"org.freesmartphone.GPS.UBX" )
# usage
usageiface = getInterface( \
"org.freesmartphone.ousaged",
"/org/freesmartphone/Usage",
"org.freesmartphone.Usage" )
# preferences
preferences = getInterface( \
"org.freesmartphone.opreferencesd",
"/org/freesmartphone/Preferences",
"org.freesmartphone.Preferences" )
# events
events = getInterface( \
"org.freesmartphone.oeventsd",
"/org/freesmartphone/Events",
"org.freesmartphone.Events" )
# pim
pim = getInterface( \
"org.freesmartphone.opimd",
"/org/freesmartphone/PIM",
"org.freesmartphone.PIM" )
# pimsources
pims = getInterface( \
"org.freesmartphone.opimd",
"/org/freesmartphone/PIM/Sources",
"org.freesmartphone.PIM.Sources" )
# pimcontacts
pimc = getInterface( \
"org.freesmartphone.opimd",
"/org/freesmartphone/PIM/Contacts",
"org.freesmartphone.PIM.Contacts" )
# pimcontacts
pimcq = getInterface( \
"org.freesmartphone.opimd",
"/org/freesmartphone/PIM/Contacts/Queries",
"org.freesmartphone.PIM.ContactQuery" )
# pimmessages
pimm = getInterface( \
"org.freesmartphone.opimd",
"/org/freesmartphone/PIM/Messages",
"org.freesmartphone.PIM.Messages" )
# pimmessagequeries
pimmq = getInterface( \
"org.freesmartphone.opimd",
"/org/freesmartphone/PIM/Messages/Queries",
"org.freesmartphone.PIM.MessageQuery" )
# bluez
try:
bluez_manager = getInterface( \
"org.bluez",
"/",
"org.bluez.Manager" )
bluez = getInterface( \
"org.bluez",
bluez_manager.DefaultAdapter(),
"org.bluez.Adapter" )
except:
print "failed to connect to bluez"
bus.add_signal_receiver( handler, None, None, None, None,
sender_keyword = "sender",
destination_keyword = "destination",
interface_keyword = "interface",
member_keyword = "member",
path_keyword = "path" )
import rlcompleter, readline, atexit
readline.parse_and_bind( "tab: complete" )
readline.set_history_length(1000)
try:
readline.read_history_file( os.path.expanduser( "~/.framework-history" ) )
except IOError:
pass
atexit.register( readline.write_history_file, os.path.expanduser( "~/.framework-history" ) )
def runmainloop():
try:
mainloop.run()
except KeyboardInterrupt:
mainloop.quit()
sys.exit( 0 )
sys.displayhook = prettyPrint
console = code.InteractiveConsole( locals() )
try:
console.interact( "freesmartphone.org interactive command line" )
except KeyboardInterrupt:
sys.exit( 0 )
|