Simplify redirecting output to the console
This commit is contained in:
parent
f2e9500a9b
commit
03af8bceea
@ -355,9 +355,8 @@ class BrowserShell(dbus.service.Object):
|
|||||||
self.__browsers.append(browser)
|
self.__browsers.append(browser)
|
||||||
browser.activity_connect_to_shell()
|
browser.activity_connect_to_shell()
|
||||||
|
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "--console":
|
log_writer = LogWriter("Web")
|
||||||
sys.stdout = LogWriter("Web")
|
log_writer.start()
|
||||||
sys.stderr = LogWriter("Web")
|
|
||||||
|
|
||||||
gtk.rc_parse(sugar.env.get_data_file('browser.rc'))
|
gtk.rc_parse(sugar.env.get_data_file('browser.rc'))
|
||||||
|
|
||||||
|
@ -696,17 +696,11 @@ class ChatShell(dbus.service.Object):
|
|||||||
def send_text_message(self, message):
|
def send_text_message(self, message):
|
||||||
self._group_chat.send_text_message(message)
|
self._group_chat.send_text_message(message)
|
||||||
|
|
||||||
|
log_writer = LogWriter("Chat")
|
||||||
|
log_writer.start()
|
||||||
|
|
||||||
def main():
|
ChatShell.get_instance().open_group_chat()
|
||||||
if len(sys.argv) > 1 and sys.argv[1] == "--console":
|
try:
|
||||||
sys.stdout = LogWriter("Chat")
|
gtk.main()
|
||||||
sys.stderr = LogWriter("Chat")
|
except KeyboardInterrupt:
|
||||||
|
pass
|
||||||
ChatShell.get_instance().open_group_chat()
|
|
||||||
try:
|
|
||||||
gtk.main()
|
|
||||||
except KeyboardInterrupt:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
|
||||||
main()
|
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
|
||||||
import dbus
|
import dbus
|
||||||
|
|
||||||
class LogWriter:
|
class LogWriter:
|
||||||
@ -7,6 +10,11 @@ class LogWriter:
|
|||||||
proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
|
proxy_obj = bus.get_object('com.redhat.Sugar.Logger', '/com/redhat/Sugar/Logger')
|
||||||
self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')
|
self._logger = dbus.Interface(proxy_obj, 'com.redhat.Sugar.Logger')
|
||||||
|
|
||||||
|
def start(self):
|
||||||
|
if os.environ.has_key('SUGAR_USE_CONSOLE'):
|
||||||
|
sys.stdout = self
|
||||||
|
sys.stderr = self
|
||||||
|
|
||||||
def write(self, s):
|
def write(self, s):
|
||||||
try:
|
try:
|
||||||
self._logger.log(self._application, s)
|
self._logger.log(self._application, s)
|
||||||
|
@ -9,7 +9,7 @@ import gtk
|
|||||||
from sugar.shell import shell
|
from sugar.shell import shell
|
||||||
from sugar import env
|
from sugar import env
|
||||||
|
|
||||||
def start(console):
|
def start():
|
||||||
shell.main()
|
shell.main()
|
||||||
|
|
||||||
activities = []
|
activities = []
|
||||||
@ -34,8 +34,6 @@ def start(console):
|
|||||||
|
|
||||||
for activity in activities:
|
for activity in activities:
|
||||||
args = [ 'python', '-m', activity ]
|
args = [ 'python', '-m', activity ]
|
||||||
if console:
|
|
||||||
args.append('--console')
|
|
||||||
os.spawnvp(os.P_NOWAIT, 'python', args)
|
os.spawnvp(os.P_NOWAIT, 'python', args)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -68,11 +68,12 @@ else:
|
|||||||
append_to_python_path(os.path.expanduser('~/.sugar/activities'))
|
append_to_python_path(os.path.expanduser('~/.sugar/activities'))
|
||||||
|
|
||||||
if console:
|
if console:
|
||||||
|
os.environ['SUGAR_USE_CONSOLE'] = 'yes'
|
||||||
print 'Redirecting output to the console, press ctrl+d to open it.'
|
print 'Redirecting output to the console, press ctrl+d to open it.'
|
||||||
|
|
||||||
from sugar.session import session
|
from sugar.session import session
|
||||||
|
|
||||||
session.start(console)
|
session.start()
|
||||||
|
|
||||||
if dbus_daemon_pid:
|
if dbus_daemon_pid:
|
||||||
stop_dbus(dbus_daemon_pid)
|
stop_dbus(dbus_daemon_pid)
|
||||||
|
Loading…
Reference in New Issue
Block a user