/usr/bin/orca is in gnome-orca 3.10.3-0ubuntu1.
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 | #!/usr/bin/python3
#
# Orca
#
# Copyright 2010-2012 The Orca Team
# Copyright 2012 Igalia, S.L.
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2.1 of the License, or (at your option) any later version.
#
# This library 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the
# Free Software Foundation, Inc., Franklin Street, Fifth Floor,
# Boston MA 02110-1301 USA.
__id__ = "$Id$"
__version__ = "$Revision$"
__date__ = "$Date$"
__copyright__ = "Copyright (c) 2010-2012 The Orca Team" \
"Copyright (c) 2012 Igalia, S.L."
__license__ = "LGPL"
import argparse
import os
import pyatspi
import signal
import subprocess
import sys
import time
sys.prefix = '/usr'
pythondir = '${prefix}/lib/python3.4/site-packages'.replace('${prefix}', '/usr')
sys.path.insert(1, pythondir)
from orca import debug
from orca import messages
from orca import orca
from orca import orca_console_prefs
from orca import settings
from orca.orca_platform import version
class ListApps(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
try:
apps = filter(lambda x: x != None, pyatspi.Registry.getDesktop(0))
names = [app.name for app in apps]
except:
pass
else:
print("\n".join(names))
parser.exit()
class Settings(argparse.Action):
def __call__(self, parser, namespace, values, option_string=None):
settingsDict = getattr(namespace, 'settings', {})
invalid = getattr(namespace, 'invalid', [])
for value in values.split(','):
item = str.title(value).replace('-', '')
try:
test = 'enable%s' % item
eval('settings.%s' % test)
except AttributeError:
try:
test = 'show%s' % item
eval('settings.%s' % test)
except AttributeError:
invalid.append(value)
continue
settingsDict[test] = self.const
setattr(namespace, 'settings', settingsDict)
setattr(namespace, 'invalid', invalid)
class HelpFormatter(argparse.HelpFormatter):
def __init__(self, prog, indent_increment=2, max_help_position=32,
width=None):
super(HelpFormatter, self).__init__(
prog, indent_increment, max_help_position, width)
class Parser(argparse.ArgumentParser):
def __init__(self, *args, **kwargs):
super(Parser, self).__init__(
epilog=messages.CLI_EPILOG, formatter_class=HelpFormatter)
self.add_argument(
"-v", "--version", action="version", version=version, help=version)
self.add_argument(
"-r", "--replace", action="store_true", help=messages.CLI_REPLACE)
self.add_argument(
"-t", "--text-setup", action="store_true", help=messages.CLI_SETUP)
self.add_argument(
"-l", "--list-apps", action=ListApps, nargs=0,
help=messages.CLI_LIST_APPS)
self.add_argument(
"-e", "--enable", action=Settings, const=True,
help=messages.CLI_ENABLE_OPTION, metavar=messages.CLI_OPTION)
self.add_argument(
"-d", "--disable", action=Settings, const=False,
help=messages.CLI_DISABLE_OPTION, metavar=messages.CLI_OPTION)
self.add_argument(
"-p", "--profile", action="store",
help=messages.CLI_LOAD_PROFILE, metavar=messages.CLI_PROFILE_NAME)
self.add_argument(
"-u", "--user-prefs", action="store",
help=messages.CLI_LOAD_PREFS, metavar=messages.CLI_PREFS_DIR)
self.add_argument(
"--debug-file", action="store",
help=messages.CLI_DEBUG_FILE, metavar=messages.CLI_DEBUG_FILE_NAME)
self.add_argument(
"--debug", action="store_true", help=messages.CLI_ENABLE_DEBUG)
def parse_known_args(self, *args, **kwargs):
opts, invalid = super(Parser, self).parse_known_args(*args, **kwargs)
try:
invalid.extend(opts.invalid)
except:
pass
if invalid:
print((messages.CLI_INVALID_OPTIONS + " ".join(invalid)))
if opts.debug_file:
opts.debug = True
elif opts.debug:
opts.debug_file = time.strftime('debug-%Y-%m-%d-%H:%M:%S.out')
return opts, invalid
def setProcessName(name):
"""Attempts to set the process name to 'orca'."""
sys.argv[0] = 'orca'
# Disabling the import error of setproctitle.
# pylint: disable-msg=F0401
try:
from setproctitle import setproctitle
except ImportError:
pass
else:
setproctitle(name)
return True
try:
from ctypes import cdll, byref, create_string_buffer
libc = cdll.LoadLibrary('libc.so.6')
stringBuffer = create_string_buffer(len(name) + 1)
stringBuffer.value = bytes(name, 'UTF-8')
libc.prctl(15, byref(stringBuffer), 0, 0, 0)
return True
except:
pass
return False
def inGraphicalDesktop():
"""Returns True if we are in a graphical desktop."""
# TODO - JD: Make this desktop environment agnostic
try:
from gi.repository import Gdk
display = Gdk.Display.get_default()
except:
return False
return display != None
def otherOrcas():
"""Returns the pid of any other instances of Orca owned by this user."""
openFile = subprocess.Popen('pgrep -u %s orca' % os.getuid(),
shell=True,
stdout=subprocess.PIPE).stdout
pids = openFile.read()
openFile.close()
orcas = [int(p) for p in pids.split()]
pid = os.getpid()
return [p for p in orcas if p != pid]
def cleanup(sigval):
"""Tries to clean up any other running Orca instances owned by this user."""
orcasToKill = otherOrcas()
debug.println(
debug.LEVEL_INFO, "INFO: Cleaning up these PIDs: %s" % orcasToKill)
def onTimeout(signum, frame):
orcasToKill = otherOrcas()
debug.println(
debug.LEVEL_INFO, "INFO: Timeout cleaning up: %s" % orcasToKill)
for pid in orcasToKill:
os.kill(pid, signal.SIGKILL)
for pid in orcasToKill:
os.kill(pid, sigval)
signal.signal(signal.SIGALRM, onTimeout)
signal.alarm(2)
while otherOrcas():
time.sleep(0.5)
def main():
setProcessName('orca')
parser = Parser()
args, invalid = parser.parse_known_args()
if args.debug:
debug.debugLevel = debug.LEVEL_ALL
debug.eventDebugLevel = debug.LEVEL_OFF
debug.debugFile = open(args.debug_file, 'w')
if args.replace:
cleanup(signal.SIGKILL)
settingsDict = getattr(args, 'settings', {})
if args.text_setup:
orca_console_prefs.showPreferencesUI(settingsDict)
if not inGraphicalDesktop():
print(messages.CLI_NO_DESKTOP_ERROR)
return 1
manager = orca.getSettingsManager()
if not manager:
print(messages.CLI_SETTINGS_MANAGER_ERROR)
return 1
manager.activate(args.user_prefs, settingsDict)
sys.path.insert(0, manager.getPrefsDir())
if args.profile:
try:
manager.setProfile(args.profile)
except:
print(messages.CLI_LOAD_PROFILE_ERROR % args.profile)
manager.setProfile()
if otherOrcas():
print(messages.CLI_OTHER_ORCAS_ERROR)
return 1
return orca.main()
if __name__ == "__main__":
sys.exit(main())
|