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