Skip to content
Open

Yo #1

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*$py.class
16 changes: 4 additions & 12 deletions MagicDrawJythonTerminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ class MagicDrawJythonTerminal(JFrame):
terminalOut = TerminalOutputStream(terminalArea)
printStream = PrintStream(terminalOut, True)
# use these if you want writer based output instead of the outputstream
# terminalOut = TerminalWriter(terminalArea)
# printWriter = PrintWriter(terminalOut, True)
terminalOut = TerminalWriter(terminalArea)
printWriter = PrintWriter(terminalOut, True)

def __init__(self):
JFrame.__init__(self, 'MagicDraw Jython Console')
Expand Down Expand Up @@ -113,17 +113,9 @@ def CommandEntered(self, event):
s = 'in : ' + event.source.text
self.printStream.println(s)

# try the embedded interp (the getLocals was just to see if I could interact with it)
# it's not returning anything
a = self.interpreter.getLocals()
self.printWriter.println(a)
self.interpreter.exec(event.source.txt)

# try the main interp (the getLocals was just to see if I could interact with it)
# it's not returning anything
a = getLocals()
self.printWriter.println(a)
exec(event.source.txt)
# eval(event.source.txt)

# set the input text blank and give it focus back. we don't get here if we try to use
# the interpreter, though we do when we don't try to interact with the interpreter
Expand Down Expand Up @@ -156,4 +148,4 @@ def CreateComponents(self):
# Main script
#PythonInterpreter.initialize(System.getProperties(), None, None)
#project = Application.getInstance().getProject()
t = MagicDrawJythonTerminal()
t = MagicDrawJythonTerminal()
504 changes: 504 additions & 0 deletions jythonconsole/COPYING.txt

Large diffs are not rendered by default.

21 changes: 21 additions & 0 deletions jythonconsole/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Jython Console - Jython Interactive Interpreter with Code Completion

Visit http://code.google.com/p/jythonconsole for more information.

Run the code:
* Open a terminal or cmd prompt
* cd jythonconsole-0.0.7
* jython console.py

Hints:
* <TAB> and <ENTER> choose method completion
* remember to use the keyboard not the mouse
* <ESC> makes the popup go away

Author:
Don Coleman <dcoleman@chariotsolutions.com>

License:
Read the COPYING.txt file.


Empty file added jythonconsole/__init__.py
Empty file.
49 changes: 49 additions & 0 deletions jythonconsole/bug_test_case.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import unittest
import introspect
import jintrospect

class BugTestCase(unittest.TestCase):

def testPythonStackOverflow(self):
"""
jythonconsole-0.0.1 has a stack overflow when autocomplete with Jython-2.2b1

import sys
sys. <-- autocomplete starts and then the following stacktrace

Traceback (most recent call last):
File "bug_test_case.py", line 8, in testJython22b1Bug
list = jintrospect.getAutoCompleteList("sys.", locals())
File "/Users/don/jythonconsole/jintrospect.py", line 90, in getAutoCompleteList
attributes = getAttributeNames(object, includeMagic, includeSingle, includeDouble)
File "/Users/don/jythonconsole/introspect.py", line 61, in getAttributeNames
attrdict = getAllAttributeNames(object)
File "/Users/don/jythonconsole/introspect.py", line 125, in getAllAttributeNames
attrdict.update(getAllAttributeNames(klass))
...
File "/Users/don/jythonconsole/introspect.py", line 138, in getAllAttributeNames
attrdict.update(getAllAttributeNames(base))
File "/Users/don/jythonconsole/introspect.py", line 125, in getAllAttributeNames
attrdict.update(getAllAttributeNames(klass))
File "/Users/don/jythonconsole/introspect.py", line 138, in getAllAttributeNames
attrdict.update(getAllAttributeNames(base))
File "/Users/don/jythonconsole/introspect.py", line 125, in getAllAttributeNames
attrdict.update(getAllAttributeNames(klass))
File "/Users/don/jythonconsole/introspect.py", line 101, in getAllAttributeNames
wakeupcall = dir(object)
java.lang.StackOverflowError: java.lang.StackOverflowError
"""
dict = introspect.getAllAttributeNames("sys")
# if the bug is happening you'll never get here
# you'll get a stack overflow instead
self.assert_(len(dict) > 0)

# method completion for python strings was failing in 0.0.2 with python2.b1
def testAutoCompleteString(self):
f = "foo"
list = jintrospect.getAutoCompleteList("f", locals())
self.assert_(len(list) > 0)
self.assert_(list.index("startswith") > 0)

if __name__ == '__main__':
unittest.main()
Loading