2024-10-16 17:06:34 -04:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
# N.B. Orca's only use of dbus-python is this logger service which is only
|
|
|
|
# used by the regression tests. It does not introduce a dependency, is not
|
|
|
|
# encountered by end users, and will be removed in favor for pygi once bugs
|
|
|
|
# 656325 and 656330 are resolved.
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import dbus
|
|
|
|
import dbus.service
|
|
|
|
import sys
|
|
|
|
|
2024-10-17 09:20:24 -04:00
|
|
|
from cthulhu import cthulhu
|
2024-10-16 17:06:34 -04:00
|
|
|
from dbus.mainloop.glib import DBusGMainLoop
|
|
|
|
|
|
|
|
class LoggerService(dbus.service.Object):
|
|
|
|
|
|
|
|
def __init__(self, filePrefix):
|
2024-10-17 09:20:24 -04:00
|
|
|
self._logger = cthulhu.getLogger()
|
2024-10-16 17:06:34 -04:00
|
|
|
self._logNames = ['braille', 'speech']
|
|
|
|
self._filePrefix = filePrefix
|
|
|
|
|
|
|
|
DBusGMainLoop(set_as_default=True)
|
|
|
|
busname = dbus.service.BusName('org.gnome.Orca', bus=dbus.SessionBus())
|
|
|
|
dbus.service.Object.__init__(self, busname, '/org/gnome/Orca')
|
|
|
|
|
|
|
|
@dbus.service.method(dbus_interface='org.gnome.Orca.Logger', in_signature='', out_signature='')
|
|
|
|
def startRecording(self):
|
|
|
|
for name in self._logNames:
|
|
|
|
self._logger.clearLog(name)
|
|
|
|
|
|
|
|
@dbus.service.method(dbus_interface='org.gnome.Orca.Logger', in_signature='', out_signature='s')
|
|
|
|
def stopRecording(self):
|
|
|
|
contents = ''
|
|
|
|
for name in self._logNames:
|
|
|
|
content = self._logger.getLogContent(name)
|
|
|
|
contents += content
|
|
|
|
fileName = open('%s.%s' % (self._filePrefix, name), 'a', encoding='utf-8')
|
|
|
|
fileName.writelines(content)
|
|
|
|
fileName.close()
|
|
|
|
|
|
|
|
return contents
|
|
|
|
|
|
|
|
def main():
|
2024-10-17 09:20:24 -04:00
|
|
|
sys.argv[0] = 'cthulhu'
|
2024-10-16 17:06:34 -04:00
|
|
|
|
|
|
|
parser = argparse.ArgumentParser()
|
|
|
|
parser.add_argument("-u", "--user-prefs", action="store")
|
|
|
|
parser.add_argument("--debug-file", action="store")
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
2024-10-17 09:20:24 -04:00
|
|
|
cthulhu.debug.debugFile = open('%s.debug' % args.debug_file, 'w')
|
2024-10-16 17:06:34 -04:00
|
|
|
|
2024-10-17 09:20:24 -04:00
|
|
|
manager = cthulhu.getSettingsManager()
|
2024-10-16 17:06:34 -04:00
|
|
|
manager.activate(args.user_prefs)
|
|
|
|
sys.path.insert(0, manager.getPrefsDir())
|
|
|
|
|
|
|
|
service = LoggerService(args.debug_file)
|
|
|
|
|
2024-10-17 09:20:24 -04:00
|
|
|
return cthulhu.main()
|
2024-10-16 17:06:34 -04:00
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
sys.exit(main())
|