I have set up a windows server on AWS and have set it up to run python. I'm trying to get this to run on a regular basis but I'm not sure is schtasks will work to run the python code. Could you give some advice around this please.
Also, the reason I didn't set this up on a native python friendly OS is because I was having some issues installing the libraries I needed.
Any help or advice is hugely appreciated.
'schtasks' is just an executable. You can always launch that within python script, using subprocess for example. You need to keep in mind for the following though:
It could require elevation. If your script is within ordinary process, you could get UAC prompt, and will need a way to deal with it.
If you'd like to create a task running without user logging on, you need to manage user/password.
If you create a bunch of tasks, you need to manage them, query/pause/stop/delete???
That's all I can think of right now...
Related
I am really new to Jenkins and Python so when I have initially researched for this problem, there has been a limit to my understanding. I am looking to write a Python script and for it to be run on Jenkins as part of some automated testing I wish to do. My script interacts with an API and hence imports the 'requests' module on Python. It works fine using the Python interpreter on my local machine but I have had issues when I have tried using the Jenkins Python script builder and so I am looking for a way around this.
As I mentioned, I have looked around the internet for solutions but as my knowledge on this topic is limited I have found it difficult to understand certain ideas that have been mentioned on the web. One lead I have had is related to the use of virtual environments on Jenkins, but as its something I've never used, I have struggled implementing it. I have installed the ShiningPanda Plugin on Jenkins, but I am unsure how to use it.
Any help given is greatly appreciated :)
Thanks
I've been searching a lot for this problem, but I didnt find any valuable answer.
I want to make a script (lets say it is a library) which runs some functions at reboot. Inside my library, there will be a function like
def randomfunction():
print("randomtext")
After loading this function, everytime a call for randomfunction() in any python run (I will .py as cgi scripts) will return me "randomtext".
Is that possible or I miss something?
It is working on python idle if I use exec, but I want this exec to be on system. That would be for a linux OS.
Don't you need some kind of Interprocess Communication for this?
Might be worth taking a look at these docs: Python IPC
Also,
this SO post might help you. I think it offers a solution to what you are looking for.
I am accessing a linux server (telnet) and then running commands on it using python.
I am meant to automate some processes using python including one in which many errors appear and I must type xoff to stop the errors from appearing so I can continue entering more commands.
This works when I do it manually, although when I do it through python, the command just doesn't work. I use pexpect module and use this code: child.sendline("xoff"). Don't worry, child is defined already.
Next I type child.expect(".*") and then print(child.after) which prints the output, which still is the errors that were meant to have stopped by using xoff.
Any suggestions on how to fix this?
BTW I am using Python 2.7.8
For ANY questions you ask, or any more information you need feel free to ask me and I will reply as quick as possible.
Thanks in advance.
I need to send code to remote clients to be executed in them but security is a concern for me right now. I don't want unsafe code to be executed there so I would like to control what a program is doing. I mean for example, know if is making connections, where is connecting to, if is reading local files, etc. Is this possible with Python?
EDIT: I'm thinking in something similar to Android permission system. I want to know what a code will do and if it does something different, stop it.
You could use a different Python runtime:
if you run your script using Jython; you can exploit Java's permission system
with Pypy's sandboxed version you can choose what is allowed to run in your controller script
There used to be a module in Python called bastian, but that was deprecated as it wasn't that secure. There's also I believe something called RPython, but I don't know too much about that.
I would in this case use Pyro and write the code on the target server. That way you know clients can only execute written and tested code.
edit - it's probably worth noting that Pyro also supports http://en.wikipedia.org/wiki/Privilege_separation - although I've not had to use it for that.
I think you are looking for a sandboxed python. There used to be an effort to implement this, but it has been abolished a couple of years ago.
Sandboxed python in the python wiki offers a nice overview of possible options for your usecase.
The most rigourous (but probably the slowest) way is to run Python on a bare OS in an emulator.
Depending on the OS you use, there are several ways of running programs with restrictions, but without the overhead of an emulator:
FreeBSD has a nice integrated solution in the form of jails.
These grew out of the chroot system call.
Linux-VServer aims to do more or less the same on Linux.
So, I've been searching the topic for quite a while, but I am unable to find out whether it is possible or not. I suspect not, but I need to be sure.
What I'm doing:
I am building a fancy web app that uses xml, xsl and javascript. However, I need to do some transformation to a text file to convert it into a proper xml file. To do this, I use a python script.
What I need:
I am working to make as easy as possible the use of the app, but this gets kind of destroyed when the user has to execute a terminal script before anything. I need a graphical IDE for python, but I just don't have time to learn how to make one, and I would love that the entire app would work within the same web environment, much more intuitive for the user. Then, a really easy way to do that would be to use Firefox as the IDE, for example choosing the file to be transformed through it, and launching from there the python script.
What I require:
I need compatibility only with Firefox. But of course any system capable to install Python and Firefox should work as well. The user would happily install both programs, as long as they have interest in the app.
What I don't know:
Is that possible, to execute an external python script? If not, for security reasons I imagine, is there any way for the user to allow it? Maybe through the installation of a plugin?
maybe http://mozex.mozdev.org/ is what I am looking for?
Thanks!
Gerard
Yes, It is possible to execute an external python script. You can use a simpleServer (example) that receives a (Ajax) request from your page and calls a subprocess or os.startfile to launch the script. In fact, you can call the function itself from within the server and return the result (e.g. as json) to the page and use your javascript to handle it.
If you're after actually using python in firefox, rather than having the server side written in python (although the webserver can of course be running locally), I would guess pythonext (used to be pyxpcomext) is what you need.