Issue2704

classification
Title: wlst jython argparse
Type: Severity: normal
Components: Library Versions: Jython 2.2
Milestone:
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Tig, jeff.allen, stefan.richthofer
Priority: Keywords:

Created on 2018-09-18.07:33:47 by Tig, last changed 2018-09-20.07:36:51 by Tig.

Files
File name Uploaded Description Edit Remove
unnamed Tig, 2018-09-18.15:58:01
unnamed Tig, 2018-09-19.19:43:10
unnamed Tig, 2018-09-20.05:29:44
unnamed Tig, 2018-09-20.06:02:28
unnamed Tig, 2018-09-20.07:36:50
Messages
msg12105 (view) Author: (Tig) Date: 2018-09-18.07:33:46
If I try to import argparse i get syntax error.

#Evidence:

/opt/weblogic$ wlst

Initializing WebLogic Scripting Tool (WLST) ...

Welcome to WebLogic Server Administration Scripting Shell

Type help() for help on available commands

wls:/offline> sys.path.append("/opt/weblogic/jython/Lib")
wls:/offline> import argparse

Traceback (innermost last):
  File "<console>", line 1, in ?
  File "/opt/weblogic/jython/Lib/argparse.py", line 611
                        yield subaction
                              ^
SyntaxError: invalid syntax
msg12106 (view) Author: Stefan Richthofer (stefan.richthofer) Date: 2018-09-18.15:09:07
It seems that I cannot reproduce this with current Jython trunk version. If I simply start Jython the "usual" way, import seems to work fine:

stefan@stefan-y260 /data/workspace/jython/dist $ bin/jython
Jython 2.7.2a1+ (default:134c5c8c2332, Sep 2 2018, 00:37:08) 
[OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_181
Type "help", "copyright", "credits" or "license" for more information.
>>> import argparse
>>> 

Is something wrond with your Lib folder? What Jython version are you using?
msg12107 (view) Author: (Tig) Date: 2018-09-18.15:58:02
Hi Stefan

I do not start Jython! I start WLST, after then I modify the system path,
add the jython libs and import the argparse.

br
Tig

Stefan Richthofer <report@bugs.jython.org> ezt írta (időpont: 2018. szept.
18., K, 17:09):

>
> Stefan Richthofer <stefan.richthofer@gmx.de> added the comment:
>
> It seems that I cannot reproduce this with current Jython trunk version.
> If I simply start Jython the "usual" way, import seems to work fine:
>
> stefan@stefan-y260 /data/workspace/jython/dist $ bin/jython
> Jython 2.7.2a1+ (default:134c5c8c2332, Sep 2 2018, 00:37:08)
> [OpenJDK 64-Bit Server VM (Oracle Corporation)] on java1.8.0_181
> Type "help", "copyright", "credits" or "license" for more information.
> >>> import argparse
> >>>
>
> Is something wrond with your Lib folder? What Jython version are you using?
>
> ----------
> nosy: +stefan.richthofer
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue2704>
> _______________________________________
>
msg12108 (view) Author: Jeff Allen (jeff.allen) Date: 2018-09-19.14:18:15
Tig:

wlst is not a part of Jython. Maybe talk to your sys admin, or installer, or someone who knows how wlst is configured for you.

If you're able to identify something a specific version of Jython is doing incorrectly, we may be able to help. It would be necessary to see:

sys.version
sys.platform
sys.path

It is not normally necessary to add the library explicitly like that. Normally the correct one is already on sys.path, as in Stefan's example.
msg12109 (view) Author: (Tig) Date: 2018-09-19.19:43:11
Hi Jeff,

actually I am the sysadmin the wlst is correct installed, and I hope that
Jython will be part of my system
I will send the sys details tomorrow.

br
Tig
msg12110 (view) Author: (Tig) Date: 2018-09-20.05:29:45
Hi Jeff

so here are the infos:

wls:/offline> sys.version

'2.2.1'

wls:/offline> sys.platform

'java1.8.0_162'

wls:/offline> sys.path.append("/opt/weblogic/jython/Lib")

wls:/offline> sys.path

['.', '/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.internal.thirdparty.jython.jar/Lib',
'__classpath__', '/opt/weblogic/12.2.1.3/wlserver/server/lib/weblogic.jar',
'/opt/weblogic/12.2.1.3/wlserver/common/wlst/modules/jython-modules.jar/Lib',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.scripting.jar/weblogic/management/scripting/utils/modules',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.scripting.jar/weblogic/management/scripting/core/utils/modules',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.scripting.jar/weblogic/management/scripting/utils/modules',
'/opt/weblogic/12.2.1.3/wlserver/common/wlst', '/opt/weblogic/
12.2.1.3/wlserver/common/wlst/lib', '/opt/weblogic/
12.2.1.3/wlserver/common/wlst/modules', '/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.tools.migration.jar/wlstScriptDir',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.tools.migration.jar/wlstScriptDir/lib',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.tools.migration.jar/wlstScriptDir/modules',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.scripting.jar/wlstScriptDir',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.scripting.jar/wlstScriptDir/lib',
'/opt/weblogic/
12.2.1.3/wlserver/modules/com.oracle.weblogic.management.scripting.jar/wlstScriptDir/modules',
'/opt/weblogic/
12.2.1.3/oracle_common/modules/fmwplatform/common/fmwplatform-wlst-dependencies.jar/wlstScriptDir',
'/opt/weblogic/
12.2.1.3/oracle_common/modules/fmwplatform/common/fmwplatform-wlst-dependencies.jar/wlstScriptDir/lib',
'/opt/weblogic/
12.2.1.3/oracle_common/modules/fmwplatform/common/fmwplatform-wlst-dependencies.jar/wlstScriptDir/modules',
'/opt/weblogic/jython/Lib']

wls:/offline>

wls:/offline> import argparse

Traceback (innermost last):

  File "<console>", line 1, in ?

  File "/opt/weblogic/jython/Lib/argparse.py", line 611

                        yield subaction

                              ^

SyntaxError: invalid syntax

BR

Tig

Tig <report@bugs.jython.org> ezt írta (időpont: 2018. szept. 19., Sze,
21:43):

>
> Tig <tigryss.droid@gmail.com> added the comment:
>
> Hi Jeff,
>
> actually I am the sysadmin the wlst is correct installed, and I hope that
> Jython will be part of my system
> I will send the sys details tomorrow.
>
> br
> Tig
>
> Added file: http://bugs.jython.org/file1648/unnamed
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue2704>
> _______________________________________
msg12111 (view) Author: Jeff Allen (jeff.allen) Date: 2018-09-20.05:51:29
That's a very old Jython.

The yield keyword in Python 2.2 was a __future__ feature. (https://docs.python.org/2.2/ref/yield.html)

I've seen documentation somewhere on wlst that led me to believe 2.7.0 is supplied. Is your argparse.py maybe coming from a 2.7 library? Leading to the hope that there's a 2.7 implementation around?
msg12112 (view) Author: (Tig) Date: 2018-09-20.06:02:28
Yes I tried the jython 2.7 lib to add, because wlst doesn't have the
argparse. I imported __future__ then the argparse...

wls:/offline> from __future__ import generators

wls:/offline> import argparse

Traceback (innermost last):

  File "<console>", line 1, in ?

  File "/opt/weblogic/jython/Lib/argparse.py", line 1131

                except IOError as e:

                                      ^

SyntaxError: invalid syntax

Jeff Allen <report@bugs.jython.org> ezt írta (időpont: 2018. szept. 20.,
Cs, 7:51):

>
> Jeff Allen <ja.py@farowl.co.uk> added the comment:
>
> That's a very old Jython.
>
> The yield keyword in Python 2.2 was a __future__ feature. (
> https://docs.python.org/2.2/ref/yield.html)
>
> I've seen documentation somewhere on wlst that led me to believe 2.7.0 is
> supplied. Is your argparse.py maybe coming from a 2.7 library? Leading to
> the hope that there's a 2.7 implementation around?
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue2704>
> _______________________________________
>
msg12113 (view) Author: Jeff Allen (jeff.allen) Date: 2018-09-20.06:23:27
Cool. The syntax of except clauses is also different in 2.7.

The path of least resistance is surely to use a 2.7. This looks useful:
https://blogs.oracle.com/emeapartnerweblogic/how-to-use-wlst-as-a-jython-27-module-by-maarten-smeets
and even mentions argparse as a reason to upgrade.
msg12114 (view) Author: (Tig) Date: 2018-09-20.07:36:51
Cool, thanks!
there is more detail...
https://technology.amis.nl/2015/10/04/how-to-use-wlst-as-a-jython-2-7-module/

Jeff Allen <report@bugs.jython.org> ezt írta (időpont: 2018. szept. 20.,
Cs, 8:23):

>
> Jeff Allen <ja.py@farowl.co.uk> added the comment:
>
> Cool. The syntax of except clauses is also different in 2.7.
>
> The path of least resistance is surely to use a 2.7. This looks useful:
>
> https://blogs.oracle.com/emeapartnerweblogic/how-to-use-wlst-as-a-jython-27-module-by-maarten-smeets
> and even mentions argparse as a reason to upgrade.
>
> ----------
> versions: +Jython 2.2 -Jython 2.7
>
> _______________________________________
> Jython tracker <report@bugs.jython.org>
> <http://bugs.jython.org/issue2704>
> _______________________________________
>
History
Date User Action Args
2018-09-20 07:36:51Tigsetfiles: + unnamed
messages: + msg12114
2018-09-20 06:23:27jeff.allensetmessages: + msg12113
versions: + Jython 2.2, - Jython 2.7
2018-09-20 06:02:28Tigsetfiles: + unnamed
messages: + msg12112
2018-09-20 05:51:29jeff.allensetmessages: + msg12111
2018-09-20 05:29:45Tigsetfiles: + unnamed
messages: + msg12110
2018-09-19 19:43:11Tigsetfiles: + unnamed
messages: + msg12109
2018-09-19 14:18:15jeff.allensetnosy: + jeff.allen
messages: + msg12108
2018-09-18 15:58:02Tigsetfiles: + unnamed
messages: + msg12107
2018-09-18 15:09:07stefan.richthofersetnosy: + stefan.richthofer
messages: + msg12106
2018-09-18 07:33:47Tigcreate