Enable the console only when running from source path.

This commit is contained in:
Marco Pesenti Gritti 2006-05-17 00:12:01 -04:00
parent 53ccec5267
commit 2ae62db4cc
4 changed files with 25 additions and 14 deletions

View File

@ -318,8 +318,9 @@ class BrowserShell(dbus.service.Object):
self.__browsers.append(browser)
browser.activity_connect_to_shell()
sys.stdout = LogWriter("Web Browser")
sys.stderr = LogWriter("Web Browser")
if len(sys.argv) > 1 and sys.argv[1] == "--console":
sys.stdout = LogWriter("Web Browser")
sys.stderr = LogWriter("Web Browser")
BrowserShell.get_instance().open_web_activity()
gtk.main()

View File

@ -398,9 +398,10 @@ class ChatShell(dbus.service.Object):
@dbus.service.method('com.redhat.Sugar.ChatShell')
def send_message(self, message):
self._group_chat.send_message(message)
sys.stdout = LogWriter("Chat")
sys.stderr = LogWriter("Chat")
if len(sys.argv) > 1 and sys.argv[1] == "--console":
sys.stdout = LogWriter("Chat")
sys.stderr = LogWriter("Chat")
ChatShell.get_instance().open_group_chat()
gtk.main()

View File

@ -7,12 +7,15 @@ import gtk
from sugar.shell import shell
def start():
def start(console):
shell.main()
print 'aaaa'
activities = ['sugar/chat/chat', 'sugar/browser/browser']
for activity in activities:
os.spawnvp(os.P_NOWAIT, 'python', [ 'python', '-m', activity ])
args = [ 'python', '-m', activity ]
if console:
args.append('--console')
os.spawnvp(os.P_NOWAIT, 'python', args)
gtk.main()

View File

@ -9,18 +9,24 @@ if curdir == '.':
basedir = os.path.dirname(os.getcwd())
else:
basedir = os.path.dirname(curdir)
console = False
if os.path.isfile(os.path.join(curdir, '__uninstalled__.py')):
if basedir == '':
print "Running sugar from current directory..."
print 'Running sugar from current directory...'
else:
print "Running sugar from " + basedir + " ..."
sys.path.append(basedir)
print 'Running sugar from ' + basedir + ' ...'
sys.path.insert(0, basedir)
os.environ['PYTHONPATH'] = basedir
console = True
else:
print "Running the installed sugar..."
print 'Running the installed sugar...'
if console:
print 'Redirecting output to the console, press ctrl+d to open it.'
from sugar.session import session
session.start()
session.start(console)