/usr/bin/presage_dbus_python_demo is in presage-dbus 0.8.8-1ubuntu3.
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 | #! /usr/bin/python
##########
# Presage, an extensible predictive text entry system
# ------------------------------------------------------
#
# Copyright (C) 2010 David Pellicer <dpellicer@warp.es>
# Copyright (C) 2010 Matteo Vescovi <matteo.vescovi@yahoo.co.uk>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
import sys
import getopt
import dbus
import dbus.mainloop.glib
PROGRAM_NAME = 'presage_dbus_python_demo'
config = None
presage_service_name = 'org.gnome.presage.beta'
presage_service_path = '/org/gnome/presage/beta'
presage_service_interface = 'org.gnome.presage.beta'
def disclaimer():
print """
Presage dbus python demo
------------------------
This program is intended as a demonstration of Presage ONLY.
The Presage project aims to provide an intelligent predictive text
entry platform.
Its intent is NOT to provide a predictive text entry user interface.
Think of Presage as the predictive backend that sits behind a shiny
user interface and does all the predictive heavy lifting.
"""
def print_version():
print """
%s (%s) version %s
Copyright (C) 2010 Matteo Vescovi.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE,
to the extent permitted by law.
""" % (PROGRAM_NAME, 'presage', '0.8.8')
def print_usage():
print """
Usage: %s [OPTION]...
At the prompt, type in some text. Hit enter to generate a prediction.
Any text input is valid, including no text, a single character, or a long string.
-c, --config CONFIG use config file CONFIG
-h, --help display this help and exit
-v, --version output version information and exit
Direct your bug reports to: %s
""" % (PROGRAM_NAME, 'matteo.vescovi@yahoo.co.uk')
def parse_cmd_line_args():
global config
short_options = "c:s:hv"
long_options = ["config=", "suggestions=", "help", "version"]
try:
opts, args = getopt.getopt(sys.argv[1:], short_options, long_options)
except getopt.GetoptError, err:
print str(err)
sys.exit(1)
for opt, arg in opts:
if opt in ('-v', '--version'):
print_version()
sys.exit()
elif opt in ('-h', '--help'):
print_usage()
sys.exit()
elif opt in ('-c', '--config'):
config = arg
def main():
# gloop to use DBUS
gloop = dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
# Get the path for the Presage object
try:
bus = dbus.SessionBus(gloop)
if config:
presage_object_path = bus.get_object(presage_service_name, presage_service_path).get_presage_object_path(config)
else:
presage_object_path = bus.get_object(presage_service_name, presage_service_path).get_presage_object_path()
# Get the Presage object
presage_object = bus.get_object(presage_service_name, presage_object_path)
print 'D-BUS connection to presage object %s created' % presage_object_path
except Exception, e:
print e
sys.exit(1)
print "Enter text at the prompt (press enter on empty line to exit):"
string = None
buffer = ""
while string != "":
string = raw_input("> ")
buffer += string
results = presage_object.get_prediction(buffer, '')
for result in results:
print str(result)
presage_object.destroy()
print "Goodbye"
if __name__ == '__main__':
parse_cmd_line_args()
disclaimer()
main()
|