I'm working on a terminal based game that I created in Python. I'm wondering if it's possible to instead of forcing users to download the scripts, if it's possible to run it in a python shell directly in a browser. I know of many sites that allow you to run Python online, but I'm hoping i can add its own website. Any help would be greatly appreciated.
Another thing, would it be possible to prevent the script source from being viewed? This is secondary, but if you know of an easy way I'd love to know.
Thanks!
Related
Im working in an architecture firm where we are trying to use the Python API for ArchiCAD.
It allows us some much needed automation for certain workflows, but we still haven't used it, because we don't know how to limit the users right to execute Pyhton.
We are planning to put some Python Scripts on an internal server and our co-workers would be able to use the "ArchiCAD Palette" to execute the scripts from the Server.
But we are currently worried that a person could write tehir own script and harm our projects etc, or delete data w/e.
So we were thinking about only allowing the Execution of Python scripts from a certain folder.
->The Folder would be read-only for users so they cant throw in their own scripts
Is it possible to do that?
If not, can anyone recommend a way were we can limit our co-workers to use only our self-written scripts but prevent them from running anything harmful?
Thanks for any Help
Kind Regards
Dayiz
I have a web server which I have developed an application on using php and SQL, mainly picked php as I am more comfortable with it.
In short the application automates some of our network tasks .
As part of this I have automated some solarwinds tasks and the library orionsdk doesnt have a php library so I have used python.
It's all working fine but I really need to run these python scripts from my browser .
I have considered using php shell exec and got my python scripts to accept args so I can run them and parse the output.
I know I could also use flask or django but worry I will have a flask app to maintain aswell as a php app.
I think the question is what the best way to achieve this or any way which I haven't mentioned .
Any help would be very much appreciated
So you want PHP to communicate with Python and you've already mentioned using shell commands and http traffic.
I can imagine you could also achieve something similar by connecting up both PHP and Python up to the same database. In that case PHP could write a record in a table and Python could pick that up and do something with the data in there. Python could be either be a long-running process or fired off by a cronjob in this case. If a database seems overkill you could also write a file to some place on disk, which Python can pick up.
Personally I'd go for the shell exec approach if you want to keep it light weight and for a API connection if you want to have a more robust solution which needs to be expanded later on.
I have a website on my local server and I like to execute system commands on my local server with a button press in the html file that is displayed. Is there a way to either execute system commands like gpio write 0 1 or to run python scripts? And how can I get the output of a system command as a string, like /opt/vc/bin/vcgencmd measure_temp| egrep "[0-9.]{4,}" -o output e.g. 44.4?
Thanks
David
You will have to a webserver with some kind of server-side script. There's lots of ways you can do this. If you know PHP, that may be easiest. If you want to use python check out uwsgi.
Here is a pretty simple project I wrote with uwsgi that might help you get started if you go that route. I found a lot of the examples didn't help a lot, so you might have some luck with that code.
Edit: Actually, uwsgi on the pi is a pretty old version, and it does some weird things on ARM if you try to compile it.
I created a proof of concept for you here using gunicorn instead. Just follow the instructions under the Installing section.
I currently simply have a local website on my Mac. I can view the webpage's HTMl and CSS and run the javascript functions in browser on my computer, but the next step I want to take is incorporating python scripts for accessing a MySQL database and returning results.
I am clearly new to this, and would love some guidance. Right now, on my computer, I have MySQL installed and I can run it in the terminal just fine. What else do I need as far as database and server equipment – if anything – to get some dynamic website running locally? My current, albeit incredibly limited, understanding is that I have a MySQL database stored on my machine that can be accessed through a Python script – also on my machine – and a link to this script in the HTML file. Is this even right, or do you recommend certain tutorials to fill in the gaps or teach me from the ground up?
I am sorry I am asking a lot; the few tutorials I have found have seemed to cover what I am hoping to do. Many thanks in advance.
Here you go. https://docs.djangoproject.com/en/1.4/intro/install/
Just follow the installation guide, and you'll be up and running in no time.
If you have MySQL installed on your machine along with Python, get a version of MySQLDb library for Python and have fun with it. Moreover, you can do almost any data operation with these combinations. If you want your website to go live (and do not wish to go through web frameworks) just look for a hosting plan that gives you a Python installed server access.
I have a django site that needs to be rebuilt every night. I would like to check out the code from the Git repo and then begin doing the stuff like setting up the virtual environment, downloading the packages, etc. This would have no manual intervention as this would be run from cron
I'm really confused as to what to use for this. Should I write a Python script or a Shell script? Are there any tools that assist in this?
Thanks.
So what I'm looking for is CI and from what I've seen I'll probably end up using Jenkins or Buildbot for it. I've found the docs to be rather cryptic for someone who's never attempted anything like this before.
Do all CI like Buildbot/Jenkins simply run tests and more test and send you reports or do they actually set up a working Django environment that you can access through your browser?
You'll need to create some sort of build script that does everything but the GIT checkout. I've never used any Python build tools, but perhaps something like: http://www.scons.org/.
Once you've created a script you can use Jenkins to schedule a nightly build and report success/failure: http://jenkins-ci.org/. Jenkins will know how to checkout your code and then you can have it run your script.
There are litterally 100's of different tools to do this. You can write python scripts to be run from cron, you can write shell scripts, you can use one of the 100's of different build tools.
Most python/django shops would likely recommend Fabric. This really is a matter of you running through and making sure you understand everything that needs to be done and how to script it. Do you need to run a test suite before you deploy to ensure it doesn't really break everything? Do you need to run South database migrations? You really need to think about what needs to be done and then you just write a fabric script to do those things.
None of this even touches the fact that overall what you're asking for is continuous integration which itself has a whole slew of tools to help manage that.
What you are asking for is Continuous Integration.
There are many CI tools out there, but in the end it boils down to your personal preferences (like always, hopefully) and which one just works for you.
The Django project itself uses buildbot.
If you would ask me, then I would recommend you continuous.io, which works ouf the box with Django applications.
You can manually set how many times you would like to build your Django project, which is great.
You can, of course, write a shell script which rebuilds your Django project via cron, but you should deserve better than that.