[Maya/Python] - Ripping raw python code from web - urllib?

Hey all.

I’m trying to figure out how to store my raw python code on a website to be read by a small .PY program ran inside of Maya. Would working with urllib be the best solution for this or would anyone else have any other suggestions?

Example:

Run local python script on computer. Have it connect to website. Pull all raw python code from that website, and run it in the buffer without having to save the raw code on the computer.

Thanks for any information,
9k

i would use the requests lib for this just out of simplicity of its api, though you can do this with urllib as well. Other than that, just eval the response?

Just curious, what is this being used for?

[QUOTE=TheMaxx;29249]i would use the requests lib for this just out of simplicity of its api, though you can do this with urllib as well. Other than that, just eval the response?

Just curious, what is this being used for?[/QUOTE]

Thanks for the response. I will check into what you suggested (probably will have the time tomorrow). I was also told the following from another community -

"use requests. Requests: HTTP for Humans™ — Requests 2.32.3 documentation
then all you need to do is this:

mycode = requests.get(“http://example.com/code.txt”)
exec mycode"

I’ll look into both solutions. Now what it’s for…

I’m writing a library of custom scripts for a pipeline. I do not want the meat and potatoes of the scripts set locally on users machines for updating purposes. I’m not looking to have a lot of iterations of this script floating around for organizational purposes. So, although I could call upon the script via local server, I want to be able to call upon it via website URL. (scripts will also be used throughout a team).

Everything is owned by yours truly, so no shady business. I just want to create an online DB of my own scripts/tools that can be pulled from.

why not just put it on a network share?
What happens if the webserver has an error or goes down?

Very well could do that and point to it as well. Should be about the same process I suppose.

I also am partial to having it under my own URL for other reasons (short term freelancing at studio reasons). If I get hired out for a few months to work a job and have custom scripts that I’ve generated outside of the scope of the contract with the company (before the hire), then I don’t need to worry about leaving any personally owned scripting tools behind on any of their systems.

Furthermore, it might be a possibility that I’d look into saving preferences for Maya onto the URL Lib as well. Land a short term job, bring one tiny pointer script with me, and be able to call upon all of my settings/scripts from a URL.

Extra layer of security.

I have an old blog post about using a custom module finder to load code via http from a server - It looks like blogger lost the code samples though. I’ll try to revive it tonight.

Thanks again Theodox. Starting to recognize your Team Fortress profile pic on my posts, haha. Thanks again for all the help guys! I will be ripping off of a square space hidden page that is password protected. I’m excited to get this up and running. Will initially be ripping about 1400 lines of python (deving a UI for the script I wrote right now).

here’s the hastily fixed link: Tech Art Survival Guide: Your weekly moment of Python-is-awesome

So I think I should of been a bit more specific as to exactly what I’m trying to do (I’ve learned a few things since the original post)…

I’m trying to run Python code off a website without having to install any custom modules manually… since PIP only came bundled with Python 2.7.9 and Maya comes standard now with 2.7.6 I am stuck with the modules that come with it. So I’ll play around with Urllib since that already comes standard with Maya’s version of Python.

edit: Checking link now Theodox. Thank you for digging that up for me.

edit edit: And I’m using squarespace to store all this shit. lol. The hole gets dug deeper.

@Theodox - Holy shit. That is exactly what I was looking for. Your example worked out great. I can’t thank you enough man! Great help.

Just remember the notes in there about lack of security / authentication etc. Remember all your traffic is unencrypted and anybody who wants can download and inspect the code

[QUOTE=Theodox;29269]Just remember the notes in there about lack of security / authentication etc. Remember all your traffic is unencrypted and anybody who wants can download and inspect the code[/QUOTE]

I’ll definitely take that into consideration. Right now I’m working on reverse engineering your scripting to get it to fire the one script I have uploaded to my temporary squarespace site at -

http://clayton-krause.squarespace.com/tempdump

There are already some differences between how Squarespace is handling the .py file and how your example was handling the .py file (you could simply open up the Example.py file in the browser as opposed to what Squarespace is doing which is treating it as a download file).

I’ll keep on hammering on this. Most of what is in your example is over my head. Thank you.