How to run sikuli script through Python script - python

I want to run sikulixIDE-1.1.3 generated script through Python IDLE but don't know how to add in Python script.
I have generated file sikuli_script.sikuli using sikuliXIDE-1.1.3.
Through Python IDLE, I opened application but the next step is I want to call this sikuli script but don't know the way to add it.
from pywinauto.application import Application
>>> app = Application().start(r"C:/Program Files/Keysight/ADS2020/bin/ads.exe")
import os
>>> os.popen('python C:/Users/aakotkar/Desktop/Agile/GUI_Automation/Sikuli_script.sikuli/Sikuli_script.py')
<os._wrap_close object at 0x000001D32063F780>
It should run sikuli script but I know I am calling in wrong way. Any help?

Related

Task Scheduler Not Picking Up Python Files That include Import OS

I’m new to Python and I have written a few python selenium tests. In my main file I have used the main.py to run all my selenium tests by using the import os module. I can execute the main.py through pycharm and python interpretar successfully but I can’t get it to work when trying to set up a schedule in Windows Tasks scheduler.
This is the error I’m getting
“The system cannot execute the specified program”
Any help would be appreciated. Thanks
In my main.py file I have
Import os
os.system (“python C:/Users/………filename.py”)
os.system (“python C:/Users/………filename2.py”)

Can I test a function defined in a file manually in the terminal in vscode?

I have previously only written python code using IDLE but since I am starting to do some more "heavier" programming I figured I should start using Visual Studio Code. I am however having issues doing things that I would like to do while coding to check that my functions are working as intended. The major thing I want to be able to do is if I have saved
def summa(x, y)
return x+y
in a file sum.py, then I would want to test run summa(3, 4) in the terminal.
In IDLE I am used to just running the file containing the function and then use it but I cannot figure out how to do that in Visual Studio Code. However, I realize that it is possible to import the file into a REPL terminal but I would hope that there is some easier way of doing it.
See the answers to this question :
execute python script with function from command line, Linux
You could also use the main function :
if __name__ == '__main__':
summa(sys.argv)
So you just launch the script and it run the function
You can start Python interactively and import your file as a module. Then your function will be available, so you can call it the way you want:
What I did was:
Open new terminal
Type: $ python to start an interactive session
Import module import test or the function from the module: import summa from test
Now I can call summa() and play with it in this manual manner

Python Code to Automate Abaqus Run Script

Error with Subprocess addition
This is the error I get regarding the abaqus module
I'm quite new to python and so please don't mind if this question might seem silly.
So I have python file that does the function of opening an abaqus viewer and I have another python file that describes the functions I want to do in the abaqus viewer.
I need a piece of code that can automate the second script without me having to manually go into file>run script.
Script to Open Abaqus:
import os
import subprocess
os.startfile('Q:/win_apps/scripts/simulia/Abaqus/6.14-3/Use_these_if_not_working/abq6143_viewer.bat')
And then I have a python script that has the code regarding my output requests from abaqus viewer.
What line can I add to the above file to automatically take the second python script and run it?
When running Abaqus with the typical start up scripts you can pass Abaqus/Viewer a script to run from the command line:
abq6143 viewer noGUI=script.py
where you replace script.py with the name of your Python script. This will start up Abaqus/Viewer with no user interface, run the script, and then quit.
If you want the user interface to come up and automatically run your script you can use the script= command instead of noGUI:
abq6143 viewer script=script.py
I see that you're using a custom batch file to start up Abaqus/Viewer. Without seeing those contents I couldn't say exactly how you would integrate the above, but you will probably need to adjust the relevant line in the batch file with the noGUI or script command.

Can't run scripts through console in QPython

I'm using the app QPython, and while it's easy to run scripts from a file, I'm struggling to see how to load a script into the Console so that I can use it there (e.g. to use functions defined in a script).
I'm not very familiar with Python, so I don't know whether I'm having difficulty with Python or with the app. As far as I know in ordinary Python, the command "import script" will import all of the code in the file script.py, which has to be contained in the directory you loaded Python from (this is already concerning as I can't change the directory in QPython).
For the record, the equivalent command in Haskell (which I am familiar with) would be :l script.hs
To import some functions :
from script import functiona, functionb()
To import all functions from a script use :
from script import *
You could just do :
import script
But then you'll have to call your functions like that :
script.myfunction()

How to attach the Eclipse debugger to a python program started from a script?

I'm using Pydev. I want to debug a python program that starts from a bash script called runanki, which is just like this:
#!/usr/bin/env python
import sys
sys.path.insert(0, "/usr/share/anki")
import aqt
aqt.run()
When I tried to debug the program, Eclipse seemed to be looking for the main method, which was futile, of course. So how can I tell Eclipse it could start the program just by executing runanki?

Categories

Resources