Forums

Suggestions for a PythonAnywhere utils library?

@jgmdavies made the excellent suggestion that there could be a PythonAnywhere utilities library that would provide useful stuff specifically for people running programs here.

So far we have one suggestion for a thing that could go in there:

  • A function that you could call from within a Python program that would make sure you only ever have one instance of it running on the PythonAnywhere servers.

But there must be other stuff. Any ideas?

How about functions to get the current PA account type, remaining CPU quota, etc.?

And maybe an 'Is_Address_Reachable' (or Valid or ...?) function, where the result depends on the current whitelist and account type?

So, functions which interact wth the PA system itself would need some sort of underlying API, alhough some simple JSON rendering on top of the existing website would probably be enough. So, it seems to make sense to keep that notion distinct from a generic "utility" library of stuff which could be applicable anywhere but happens to be specifically useful here.

Perhaps a MySQL connection pool which does The Right Thing(tm) might be useful, although it's true that the larger frameworks tend to come with their own solutions. Also, sending email seems to have caused an amount of difficulty in the past so perhaps an easy wrapper around that, using Gmail, might be handy to reduce potential support questions from both free and paid accounts. Specifically for free accounts, it might be useful to make the code do a proper multi-A lookup and attempt to connect to several addresses to try and cope with the case that the list of whitelisted Gmail IPs needs updating again.

Further thoughts along the 'API' line:

  • Methods to get remote (i.e. PAW) file info from Python code running on a user's local machine.
  • Methods to copy files up/down.

This would allow 'synch' apps to be written.

I guess I'm thinking of a virtualization approach, where a local Python app on a user's machine can access resources at PAW, e.g. for a local file manager or dashboard?

I'd also like to have a local GUI connecting to Python code running at PAW, for dev / test / fiddling. I've looked at things like BTL's Container as a possible way of intercepting Tkinter's canvas output, but I don't see a way yet without a lot of work by 'someone' (!).

Great suggestions. We do have the beginnings of a REST-ful file access API, I'll bump that up on the priority list.

Hi everyone, we do have a first cut of the API ready for testing (see blog). Drop us an email to support@pythonanywhere.com if you'd like us to switch it on for your account.

Be aware that the api is an early beta release, and we reserve the right to change it or break it at any time, so it's really just for playing around with at this stage. Don't go building anything important with it!