PyQt open urls from custom uri scheme in the same app instance - python

I don't know if this has been answered somewhere on here or not but I can't really find anything that has helped me.
Anyway, I am working with PyQt5 on windows and I created a custom URI scheme that opens my app and then the app parses the command arguments and then does the needed processing. Everything is working as expected but I am trying to figure out how to make everything open in the same app instance.
For example, if I have several custom links such as
foo://bar
foo://bar2
foo://bar3
How can I make them all open in the same instance without opening a new app each time they are executed?

In case anyone is interested, I found what seems to be a pretty good solution, at least for what I need. After a lot of looking around I came across this Answer which is using sockets. I altered it a bit to fit my needs and created a client.exe file that I associate with my custom URI scheme now instead of my main app. So instead of using my main app path in the URL Protocol registry key I now use this instead.
"C:\testapp\client.exe" "--data" "%1"
So now when I click a link such as :
foo://bar
The command is ran and opens client.exe and I simply parse the arguments with argparse and then send the data through the socket to my main app. I don't know if there is a better way to do this but it seems to work well for a simple solution.

Related

How to intercept requests from a specific app?

This is a rather conceptual question than a line of code question.
I'm trying to proxy an android app in order to inspect its API calls, without having root access to the device.
I'm using mitmproxy, and I've managed to create a system wide proxy using this, but I'm quite clueless as to how can I filter the wanted requests from just the given app.
I can tell the bundle id of the app, but how can I target just this app's requests? With root, this can be easy - using iptables, but how can it be done without root?
This app can be third-party, so using heuristics based on domain or header can be a bit problematic since I don't control them. Also, I would actually prefer a solution style iptables, but without root.
Thanks!

Create upload URL using blobstore.create_upload_url()

In my GAE app when the request page is appid.appspot.com/module?action=form using the code snippet below I am getting this ouput appid.appspot.com/_ah/upload/?action=form/fu6YsSdQIK6rzh9e3Q6t...fu6YsSdQIK6rzh9e3Q6t/
blobstore.create_upload_url('module/')
The URL I want to create should be like this
appid.appspot.com/module/_ah/upload/fu6YsSdQIK6rzh9e3Q6t...fu6YsSdQIK6rzh9e3Q6t?action=edit
Is there a standard way to achieve this
No, you have not read the documentation. You don't get to control the upload URL: the parameter you pass is where the browser gets redirected to after the upload. The upload destination is controlled by GAE itself and cannot be changed from your code.
I had the same problem with my deployment. I don't know why it started happening with that setup beyond the fact that I was using a custom domain on the app (and removing it had no effect). In the end, though, it didn't seem to affect anything. Once I had my permissions set up right (oops) uploads worked fine despite the wonky URL.

How to make android widgets using python?

Is there any way to make widgets with Python on Android?
I mean, that I know only Python, HTML, DOM, JS, maybe jQuery and nothing more (not C, Java or something).
Maybe it's simple?
I honestly searched stackoverflow but search returned no answers :(
Help me, please. Give me a hope.
Personally I wrote a google app engine app in python to collect and display the data, and then used an app called "meta widget" that allows you to turn a website's content into a widget. The app pulls the content from my GAE website and shows it in a widget on the android homescreen.
You might be able to do something completely local if you can make something to serve HTTP requests in sl4a python, then have meta widget go to a local http address.
I don't think this could be done.
I've done a quick search in SL4A documentation and there is no API to register broadcast receiver. And Android widgets are just a bunch of Views and code in BroadcastReceiver.
And as far as I know, SL4A is the only way to use Python on Android with UI interaction.
Please check this links:
http://code.google.com/p/android-scripting/
http://google-opensource.blogspot.com/2009/06/introducing-android-scripting.html
Remember that there is a Python implementation on the JVM called Jython.
Edit:
In terms of Android development i should say Jythonroid.
Pyjamas perhaps? Maybe not exactly what you're looking for but it would allow you to at least write some of your code in Python (and compile to JavaScript).

Is it possible to write dynamic web pages in Python with the Really Simple HTTP Server?

I know that with the SimpleHTTPServer I can make my directories accessible by web-browsers via Internet. So, I run just one line of the code and, as a result, another person working on another computer can use his/her browser to see content of my directories.
But I wander if I can make more complicated things. For example, somebody uses his/her browser to load my Python program with a set of parameter (example.py?x=2&y=2) and, as a result, he/she sees the HTML page generated by the Python program (not the Python program).
I also wander if I can process html form submitted to the SimpleHTTPServer.
While it is possible, you have to do pretty much everything yourself (parsing request parameters, handle routing, etc).
If you are not looking to get experience in creating web-frameworks, but just want to create a small site you should probably use a minimalistic framework instead.
Try Bottle, a simple single-file web framework: http://bottlepy.org
Maybe the VerseMatch project and related recipes over at ActiveState is something you would be interested in examining? It implements a small application using the standard library for dynamic running.
have you considered using CGIHTTPServer instead of SimpleHTTPServer? Then you can toss your scripts in cgi-bin and they'll execute. You have to include content-type header and whatnot but if you're looking for quick and dirty it's real convenient

Using Google App Engine to display a Rss/Atom feed

Im thinking of setting up a Google App that simply displays an RSS or Atom feed. The idea is that every once in a while (a cron job or at the push of a magic button) the feed is read and copied into the apps internal data, ready to be viewed. This would be done in Python.
I found this page that seems to explain what I want to do. But that is assuming Im using some of the other Google products as it relies on the Google API.
My idea was more in line that added some new content, hosted it locally on my machine, went to the Google App administration panel, pushed a button and my (locally hosted) feed was read and copied.
My questions now are:
Is the RSS (or Atom, one is enough) format specified enough to handle add/edit/delete?
Are there any flavors or such I should worry about?
Have this been done before? Would save me some work.
One option is to use the universal feed parser library, which will take care of most of these issues for you. Another option would be to use a PubSubHubbub-powered service such as Superfeedr, which will POST updates to you in a pre-sanitized form, eliminating most of your polling and parsing issues.
What about using an additional library, like for instance Feedparser?

Categories

Resources