Baby steps of setting up an AMI?

Edit after many hours:

I found this incredibly helpful: https://youtu.be/u3u8pL9o-as
Anybody as un-web-savvy as I am can benefit a ton from this video.
I’m now able to click the AMI and display a version’s name!

Now onto the next, probably big, question -
Me and a lot of my coworkers work remotely even before the pandemic. What do I need to do to make an AMI available for all of them, who don’t necessarily have shotgun_api3 and flask installed, and probably don’t want to bother downloading my script? Will it ever be as simple as one click for the user?

The answer might be crystal clear to some. I’m late to the game :smiley:

=== THE ORIGINAL POST ===

Hello!

I could use some explain-as-if-I’m-five…

I’m looking to try out action menu items, but I seem to be missing what’s between


and
https://developer.shotgunsoftware.com/python-api/cookbook/examples/ami_handler.html

Like, what exactly do I put into the “URL” field of my AMI, to make it send proper info to my localhost? Right now I have “http://localhost:5000” there. Not sure how to proceed…
(edit after an hour: I think it’s the POST request that I’m supposed to parse, not the URL? Then I’m stuck again not knowing what the POST request looks like.)

I’m pretty familiar with the Python API, so the “juicy part” of the script that actually does the job (e.g. download and package files) doesn’t intimidate me as much.

If someone could kindly explain or point me to helpful resources, I’d be very very happy!

4 Likes

Shotgun uses a custom protocol handler shotgun://

A url would look like shotgun://archiveVersions?id=132&entity_type=...
Where the “path” is the name of your action. So in shotgun your url will be just shotgun://archiveVersions

In order to handle this, on Windows for example you need to set a registry entry.
Here is the documentation

The handler is simply a script, which will dispatch to functions, depending on the selected action.
You use something like urllib to parse the address, query parameters, etc. from the url.

5 Likes

Some update after 10 days:

  1. The answer to what puzzled me for hours turned out to a very simple fact - the URL isn’t the only thing that’s sent from Shotgun to my server / local machine! Apparently the selected entity’s ID, the project’s ID, etc. are all sent in the body of the HTTP message.

    To many, the above image is probably commonsense…

And then this line opened up the world for me:

post_dict = dict(request.form.iterlists())

.

  1. There seems to be a small lag between when you update the URL of your AMI and when that new URL really kicks in.
    What happened to me was that after getting to hello world with http://127.0.0.1:5000/, I changed it http://127.0.0.1:5000/playlist-download/, and then freaked out for a good half an hour because that “playlist-download” part wouldn’t show up in my HTTP message…

  2. To echo @mmoshev 's reply - custom protocol handler seems very tempting at this moment, now that I’ve had some success with the HTTP route.
    I’m on a Mac and will try out registering the custom protocol.

  3. My big question from the original post still stands - how do I make an AMI so that someone can use it without having to install a bunch of Python packages?
    Maybe there are great examples out there and I just need to Google… I’ll surely share my findings if any.

1 Like

Well, you need something to handle the action locally. Now, you can offload some of the work elsewhere, by sending a request to another machine, which will have the more complicated dependencies.

On the other hand, I wonder if the url can be that of another machine, which will do the handling. This raises a lot of extra questions, though, around security, etc.

If your coworkers have Shotgun Desktop installed, then they also have shotgun_api3 somewhere.

Otherwise, consider making something easily installable for them (i.e. single click).

2 Likes