how to create a program application in MacOS that is shareable - python

So I have developed a python script which opens Slack app (which is based on Chromium) with a remote-debugging-port, and then injects a JavaScript bundle. Ideally I'd like to instead make a shell script which called the python file (and checked if python was available in the right version etc!) first.
This however would require the user to call the shell script from the terminal
What I'd really like would be a single executable file that contains:
the .sh script file
the .js bundle that gets injected
the .py file that the script calls
bonus, an icon that would show for the program in MacOS
It's been great developing the proof of concept so far, but creating an application is a new step to me. What is a way to create a (double)clickable file that contains the 4 files above and doesn't need to live in a terminal tab? Thanks
PS. This will always remain a simple app so simplicity is probably a key consideration.

Related

run python script from powerautomate when file gets created in OneDrive for business

I need to run a python script when an excel file gets dropped in onedrive for business. The python script needs to read from that file and then do some actions. I have been searching aroud and I see that azure functions app is the way to go. I wanted to know if there are any other options to get this done? I see in powerautomate desktop that it runs python 2 code? I need to use python 3 Anyway around that? Calling Python script with the variable(file in onedrive) using powershell?

ASP.NET webpage on IIS Server does not call Python/run scripts at all

I've developed an ASP.NET website on IIS (virtual Windows Server using Amazon Lightsail) which works as expected for the most part. But one issue with it is with running specialized Python scripts.
In my website, there is a feature where a user (of a certain account level) can upload an image, which is then passed through Python (through Process.Start). After Python does its thing, it sends text output back to the webpage. This works perfectly under the context of IIS Express in my local computer, but on the server, it seems to not run Python at all.
It is noted that I did not receive any warnings or errors. Seems to entirely skip the Process.Start segment.
I suspect that it is due to either of these:
Security access
The application pool
The Process.Start function
Things I tried:
Changing the security settings of the folder with the Python app and the scripts, as well as the Python executable
Changing the application pool of the website to LocalSystem
Disabled dynamic compression
Added a script map for the Python app
Reinstalled Python from Users/Administrator/Local/Appdata... to C:/Python (also changed the required paths in the website code behind) I also made sure that I installed the right Python libraries for the code to work.
Apart from the file paths in the code behind, nothing is changed in the actual ASP.NET website and DLL. Ideally I should not need to change anything else with regards to the website.
The website still does not call Python. I've been scratching my head for the past two days on this single issue.
Also, the folder where the Python scripts and related files are located are within wwwroot.
Any suggestions are much appreciated.
TL;DR: ASP.NET website that calls Python to run an already-coded script as part of its function works great under IIS Express. Python does not run when called under IIS Server.

Run local python script from Google Apps Script

As the title suggests, I'm looking for a way to run local python scripts from the Google Apps Scripts environment. Right now my method is to write a json file from app scripts and save it to a Google Drive directory. The local machine polls the directory via Google Drive File Stream, and runs the necessary code when the file appears in the directory. Not pretty, but it gets the job done. The main concern with this is that File Stream can be fairly latent - could be up to 15 minutes after a file is put in the directory before File Stream catches it and syncs the local machine.
Is anybody aware of other options? I could try re-writing the python code in Apps Script, though the python code relies on a few third party libraries that aren't available in JS. Another idea is setting up a flask server, but that seems like a good bit of work for the return.

Python sample on Bluemix displays source code instead of HTML output - why?

I am trying out Python on Bluemix. To do this I decided to move an example from a book that worked fine on my Windows laptop. I created the Bluemix example app, then replaced the index.html with the html file from the sample and built my directory tree beneath the static directory. The server starts up fine and displays the intro html file as expected, but when I click on a link that should build my html page it displays the page as source code instead of executing it. On Windows this works perfectly. My call to the page looks like this:
My data.
I have heard that on Linux environments you sometimes need to point out the python executable, but what is the right location of that in a Bluemix environment? Another question would be if the .py file is set to executable, but I don't know how you set such a thing in Bluemix.
All help is appreciated.
You can't directly link to a Python file in a Python webapp. You should use something like Flask to serve your application. Flask can do routing for you.
Additionally, in Bluemix and other Platform as a Services' there is only a single binary entry point to your app. You can't have multiple binary entry points.
See this example app on how to deploy a Flask app.
Additionally, you can click the button below to directly deploy the example app to Bluemix.

Executing Python program on web

Can I use os.system() or subprocess.call() to execute a Python program on a webserver?
I mean can I write these functions in a .py script and run it from a web browser and expect the program to be executed?
Thanks a lot.
EDIT:
Sorry for all the confusion, I am giving you more background to my problem.
The reason I am trying to do is this.
I have a Python program that accepts an XML file and returns me TTF file.
I run that program in terminal like this:
ttx somefile.xml
After which it does all the work and generates a ttf file.
Now when I deploy this script as a module on web server. I use a to allow user to browse and select the XML file.
Then I read the file data to temporary file and then pass the file to the module script to be executed like this:
ttx.main([temp_filename])
Is this right way to do it? Because at this point, I don't get any error in the log or in browser. I get blank screen.
When this didn't work, I was going to try os.system or subprocess.call
You do not use os.system or subprocess.call to execute something as a cgi process.
Maybe you should read the Python cgi tutorial here:
http://www.cs.virginia.edu/~lab2q/
If you want your cgi process to communicate with another process on your local machine, you might want to look at "REST frameworks" for Python.
So long as your server is configured to run CGI scripts (Apache's documentation for that is here, for example), yes, you can execute a python script from a webserver. Simply make sure the script is in the appropriate cgi-bin/ directory and that the file has executable permission on the server.
With regards to your comments:
You can, if you really want, explicitly allow other folders on the server to run executable code. I don't know what server you're using, but on Apache this is done by setting Option +ExecCGI for the folder you want. Again, see the docs I linked to.
You need to give an absolute path with respect to the server. As an example, a site I develop has the layout: /public_html/cgi-bin/ When I want to access .cgi or .py files, the url for the site is something like http://chess.narnia.homeunix.com/cgi-bin/index.cgi. You can also set up re-directs to certain files if you want.
One way to pass parameters through your browser is to append them to the URL like an HTTP POST method. Here's a good example of doing that.
Is that what you were looking for with your question, or did you want to actually invoke the python script with os.system()?
Yes, I do it all the time. Import as you would do normally, stick your .py in your cgi-bin folder and make sure the server is capable of handling python.
Another option would be to simply create an application on Google's App Engine. That gives you oodles of resources and APIs for Python execution.
http://code.google.com/appengine
I've done it quite a bit in classic ASP on IIS 5 and above. I would have the ASP engine execute python code (instead of, e.g., vbscript (hearkening back to the old days, here)). Behind those asp pages would be python modules written in straight python that could be imported and could execute pretty much arbitrary code. As others have mentioned, the effective user needs to have execute permission on the thing you're trying to execute.

Categories