0

Importing shotgun module in RV plugin

Starting another RV plugin,...but this time we want to use some pre-existing python code.

To make this work,...in the plugin file, using python, near the top, in the import statements,

I need to add the old reliable statement we've all seen before,..

    from shotgun_api3 import Shotgun

But when I launch RV, it crashes.   Rob@Shotgun told us (many months ago) that in order to prevent, do a

   Shotgun.NO_SSL_VALIDATION = True

but unfortunately it still crashes at launch.  To be fair, Rob's suggestion was in a slightly different context though,

but it seemed like the logical thing to try.

I'm surprised that importing the main Shotgun module would cause a crash, given all the cooperative efforts of Shotgun and Tweak

to have their products co-mingle, so to speak.

 

Can anybody shed any light on how to do this?...or even if it can be done?...and/or alternatives?

We don't want to use ScreeningRoom for this...it's just a pretty simple python plugin for use in the RV player.

Thanks,

 

11 comments

  • 0
    Avatar
    KP

    Hey Jim!

    The ssl validation doesn't live on the Shotgun class itself. Try one of these:

    import shotgun_api3
    shotgun_api3.shotgun.NO_SSL_VALIDATION=True

    Then do your instantiation of the Shotgun connection object. The NO_SSL_VALIDATION is a module-level global in the shotgun.py module. You can see that here: https://github.com/shotgunsoftware/python-api/blob/master/shotgun_api3/shotgun.py#L71

    Since that code block is run when you import shotgun_api3, setting it after the import should override it correctly. Then when you instantiate your Shotgun object, it will setup the config based on that value: https://github.com/shotgunsoftware/python-api/blob/master/shotgun_api3/shotgun.py#L302

    Hope that helps!

     

    cheers,
    kp

    Shotgun Software

     

  • 0
    Avatar
    Jim Polk

    Hey Kevin!..Thanks for your reply...

    Hmmm,..okay, your suggestion is only slightly different than what I was using...but I modified it to use your syntax more exactly,..

    Here's the top portion of my code...

        import os
        import sys
        import os.path

        DEV  = os.getenv("DEV_DEBUG")
        REPO = os.getenv("RGH_REPO")

        sys.path.insert(0, REPO + r'/fac/python/26/site-packages')

        import shotgun_api3
        shotgun_api3.shotgun.NO_SSL_VALIDATION=True

        SERVER_URL   =  'blah blah'
        SCRIPT_LOGIN =  'blah blah'
        SCRIPT_KEY   =  'blah blah'

        SGN = Shotgun(SERVER_URL, SCRIPT_LOGIN, SCRIPT_KEY)

        from rv import rvtypes, commands, extra_commands, runtime

        class Etc,Etc..(rvtypes.MinorMode):
            ...
            ...
            ...

    When I launch, RV will crash..

    If I use the above again,..but this time comment out the connection call, it also crash.

     

    If I comment out the three lines of Shotgun related code, like so:

        #import shotgun_api3
        #shotgun_api3.shotgun.NO_SSL_VALIDATION=True

       ....
        #SGN = Shotgun(SERVER_URL, SCRIPT_LOGIN, SCRIPT_KEY

     

    Then when I launch RV, it will complete the launch...

     

    Any suggestions?

     

    Btw,...I'm testing with RV version 4.0.8, and Python 2.6.6 (Also have 2.7 if need be)

    Looks like v4.0.8 is using Python 2.6.7....don't think the difference between 2.6.6 and 2.6.7 would make a difference...

    Thanks!

    Jim

  • 0
    Avatar
    KP

    Hmm, so just the import is what's crashing RV then?

        import shotgun_api3

  • 0
    Avatar
    Alan Trombla

    Hi guys,

    Jim, can you tell me what platform you're running RV on ?

    Just to eliminate all other variables, can you try importing from the command line  ?  Like this:

    rv -pyeval "import shotgun_api3; print shotgun_api3.__file__"

    (With PYTHONPATH set appropriately, of course.)  Does that crash, or give any error ?

    Thanks,

    Alan

  • 0
    Avatar
    Jim Polk

    Yes,

  • 0
    Avatar
    Jim Polk

    Hey Alan,...

    We're running on Windows 7..

    That command sequence crashed RV...nothing unusual printed out, except for the usual RV vers number and copyright, and 'listening' statement..

    Thanks,

  • 0
    Avatar
    Jim Polk

    Sorry,..forgot to add...that's 64bit Win7

  • 0
    Avatar
    Jim Polk

    hey Alan,...think you'll find this interesting....

    I decided to run your suggestion again,..but this time using 4.0.9 and RV completes launch...

    Hmmm....

    whereas 4.0.8 crashes...

     

    Eventually what I'm doing will be run on 4.0.9 (or 4.0.11)...but I've been using the previous version for plugin testing,..so as not to interfere

    with other studio artists using the latest version,etc...

    Any thoughts?

    Thanks!

     

  • 0
    Avatar
    Alan Trombla

    Thanks, Jim.  I can replicate the crash with 4.0.8 (on windows only) but not with the current release (4.0.11).

    I think the fix might be this one, from 4.0.9 release notes:

    • Importing the python module "hashlib" was crashing RV on windows.

    The hashlib module will certainly be used by the shotgun api.

    Could you please try with the current release from our downloads page ?

    Cheers,

    Alan

  • 0
    Avatar
    Jim Polk

    also....running on 4.0.11 works as well

  • 0
    Avatar
    Jim Polk

    Okay,...understood,...I'll use 4.0.9

    Thanks for taking the time to look at this

    Cheers,

    Jim

     

Please sign in to leave a comment.