/usr/lib/2013.com.canonical.certification:checkbox/bin/keyboard_test is in plainbox-provider-checkbox 0.4-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 | #!/usr/bin/env python3
import os
import sys
from gettext import gettext as _
import gettext
def cli_prompt():
import termios
limit = 50
separator = ord("\n")
fileno = sys.stdin.fileno()
saved_attributes = termios.tcgetattr(fileno)
attributes = termios.tcgetattr(fileno)
attributes[3] = attributes[3] & ~(termios.ICANON)
attributes[6][termios.VMIN] = 1
attributes[6][termios.VTIME] = 0
termios.tcsetattr(fileno, termios.TCSANOW, attributes)
sys.stdout.write(_("Enter text:\n"))
input = ""
try:
while len(input) < limit:
ch = str(sys.stdin.read(1))
if ord(ch) == separator:
break
input += ch
finally:
termios.tcsetattr(fileno, termios.TCSANOW, saved_attributes)
def gtk_prompt():
from gi.repository import Gtk, Gdk
# create a new window
window = Gtk.Window()
window.set_type_hint(Gdk.WindowType.TOPLEVEL)
window.set_size_request(200, 100)
window.set_resizable(False)
window.set_title(_("Type Text"))
window.connect("delete_event", lambda w, e: Gtk.main_quit())
vbox = Gtk.VBox()
vbox.set_homogeneous(False)
vbox.set_spacing(0)
window.add(vbox)
vbox.show()
entry = Gtk.Entry()
entry.set_max_length(50)
vbox.pack_start(entry, True, True, 0)
entry.show()
hbox = Gtk.HBox()
hbox.set_homogeneous(False)
hbox.set_spacing(0)
vbox.add(hbox)
hbox.show()
button = Gtk.Button(stock=Gtk.STOCK_CLOSE)
button.connect("clicked", lambda w: Gtk.main_quit())
vbox.pack_start(button, False, False, 0)
button.set_can_default(True)
button.grab_default()
button.show()
window.show()
Gtk.main()
def main(args):
gettext.textdomain("checkbox")
if "DISPLAY" in os.environ:
gtk_prompt()
else:
cli_prompt()
return 0
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
|