How to run wlst script by .py file - python

I'm trying to run wlst script form .py file but it can not be done
Content of .py file :
connect('weblogic','weblogic','t3://localhost:8001')
sca_undeployComposite('http://localhost:8001','Hello','1.0','user='weblogic',partition='myPartition')
sca_deletePartition('myPartition')
sca_createPartition('myPartition')
sca_deployComposite('http://localhost:8001','C:\WLST\Test\Application.zip',user='weblogic',configplan='myPlan.xml', partition='myPartition')
exit()
when i run cmd file to execute script, Only connect() method is execute success. any command bellow it can not be execute. And error message appear: Problem invoking WLST - Traceback (innermost last): File "c:\WLS\script\filname.py", line 2, in ?
Name Error: sca_undeployComposite
Please help me to resolve it. Thanks !

The commands after the connect() line which are not regular WLST commands. They requires sca related libraries into CLASSPATH. if you look into your wlst.cmd or .sh file that is actually calling the environment setup file that could be setWLSEnv.sh/.cmd. If you run that from where you are having the this python script. That script will work, it is simple java CLASSPATH funda nothing else!
Probably you might be running wlst.cmd after navigating to the common bin folder like
cd /oracle/fmwhome/Oracle_SOA1/common/bin/.
instead you can run in your script like this
C:\WLS\script\>/oracle/fmwhome/Oracle_SOA1/common/bin/wlst.cmd filename.py
or
C:\WLS\script\>/oracle/fmwhome/Oracle_SOA1/common/bin/setWLSEnv.cmd
C:\WLS\script\>java weblogic.WLST filename.py
You can also refer for more sca related scripting: WLSTByExamples

Related

Executing python script with pdflatex using PHP on Ubuntu webserver?

I am trying to execute a python script which uses pdflatex using php. Running the python script via command line works well.
But if I try to call it with php, it throws this error:
I can't write on file mylatex.log'. (Press Enter to retry, or
Control-D to exit; default file extension is `.log') Please type
another transcript file name: ! Emergency stop ! ==> Fatal error
occurred, no output PDF file produced!
So there seems to be a permission error.
This is the way I am trying to call the php file:
$command = escapeshellcmd('python3 /home/ubuntu/test.py');
$output = shell_exec($command);
echo $output;
The mylatex.log file has 777 permission as a test.
Is there a way to execute a python script which uses a library like pdflatex?
I solved the error by adding the php file to the same directory as the python file. Then it works. There seems to be a problem to call pdflatex in a different directory. Thanks for the help.

Running python programmes for the command line

I am trying to run a python programme called helloWorld.py from the command line on MacOS.
I am typing into bash:
Ryans-MacBook-Air:~ ryanunderwood$ python3 helloWorld.py
But I am getting the following:
/Library/Frameworks/Python.framework/Versions/3.7/Resources/Python.app/Contents/MacOS/Python: can't open file 'helloWorld.py': [Errno 2] No such file or directory
There is definitely a file with this name in the directory. Why is this programme not running?
Try ./helloworld.py or python3. /hello World.py
And make sure you have the right permissions

Executable .py file with shebang path to which python gives error, command not found

I have a self-installed python in my user directory in a corporate UNIX SUSE computer (no sudo privilege):
which python
<user>/bin/python/Python-3.6.1/python
I have an executable (chmod 777) sample.py file with this line at the top of the file:
#!<user>/bin/python/Python-3.6.1/python
I can execute the file like this:
python sample.py
But when I run it by itself I get an error:
/full/path/sample.py
/full/path/sample.py: Command not found
I have no idea why it's not working. I'm discombobulated as what might be going wrong since the file is executable, the python path is correct, and the file executes if I put a python command in the front. What am I missing?
EDIT:
I tried putting this on top of the file:
#!/usr/bin/env python
Now, I get this error:
: No such file or directory
I tried this to make sure my env is correct
which env
/usr/bin/env
EDIT2:
Yes, I can run the script fine using the shebang command like this:
<user>/bin/python/Python-3.6.1/python /full/path/sample.py
Your file has DOS line endings (CR+LF). It works if you run python sample.py but doesn't work if you run ./sample.py. Recode the file so it has Unix line endings (pure LF at the end of every line).
Try using #!/usr/bin/env python as described in this post. Let the OS do the work.

how to translate a cmd line to a os.system line?

I used to run a program called vina through the cmd line using the following command:
"\Program Files (x86)\The Scripps Research Institute\Vina\vina.exe" --config conf.txt --log log.txt
So, the program takes the config file to run and outputs a log file with the results. I am running the program in python using the os.system module. However, I can't assign the config file or the log file as I did in the cmd. I tried something like this in python:
os.system('C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe' --config conf.txt --log log.txt)
The program opens real quick then closes, maybe because it doesn't run the config file. I have also tried putting the config into a string as follows (I am omiting the log thing until I get the config to work):
os.system('C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe', '--config conf.txt')
In this case I get the error:
TypeError: system() takes at most 1 argument (2 given)
Any ideas on how to specify the config file and the log file output in python lines as I do in cmd?
The correct syntax to replicate the command line command would be
os.system('"C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe" --config conf.txt --log log.txt')
If that doesn't work, try specifying full paths for conf.txt and log.txt
os.system(r'"C:/Program Files (x86)/The Scripps Research Institute/Vina/vina.exe" --config conf.txt --log log.txt')

How to run this .py script correctly?

I downloaded a program called "A ren'py script decompiler," and I cannot for the life of me work out how to run it.
I googled a bit to discover that the files I had downloaded, which were in ".py" format, referred to Python, (yes, this is the level I am on,) so I downloaded it, and after a bit more googling, managed to run the script.
However I have still no idea how to get this thing to actually do what I want, as when I try to copy the commands from the README, it just brings up errors, and half the time I don't even understand what the README is saying in the first place. For example: "You can either use the -b argument to specify the directory in which renpy lies or place the renpy module in your Python module search path." This is gibberish to me.
So I know this is a big ask, but apparently getting this to run is supposed to be pretty simple -- it's just a lightweight program/script/thing that decompiles .rpyc scripts. So does anyone know how I can get it to work?
This is the thing: https://github.com/yuriks/unrpyc
When I run the script in Python it just says:
usage: unrpyc.py [-h] [-c] [-b BASEDIR] [-d]
[--python-screens | --ast-screens | --no-screens | --single-line-screen-kwargs]
file [file ...]
unrpyc.py: error: too few arguments
And then after that I don't know what to type to get it to work anyways.
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
--basedir
NameError: name 'basedir' is not defined
I'm the maintainer of unpryc
The script should be ran with python 2.7. Also I'm glad to tell you that in the more recent version of the decompiler (http://github.com/CensoredUsername/unrpyc) the dependency on renpy has been removed, so you no longer have to fiddle with the --basedir option.
regarding the error:
Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
--basedir
NameError: name 'basedir' is not defined
I'd guess that's caused because you're trying to run the command in a python shell instead of a normal command prompt. If you want to call the script normally open a command prompt (I think you're on windows, so it'd be cmd.exe) and run the command:
path_to_python_executable unrpyc.py script_you_want_to_decompile.rpyc
path_to_python_executable is usually C:\Python27\python.exe
That should work.
You won't need most options; the only one you probably need is the -b switch, and of course the script you want to decompile.
The -b (or --basedir) option tells this script where to find the Ren'Py source code; you need to have that program installed too, and then give the directory where it's Python modules are located to this script. Presumably just downloading the SDK, extracting that somewhere and naming that path with teh -b switch is enough:
unrpyc.py -b /path/to/renpy/modules/directory script_you_want_to_decompile.rpy

Categories