Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using _unswizzled_password #813

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

j0yu
Copy link

@j0yu j0yu commented Jul 12, 2021

Issue

Python 3.2 removed Python 2's string.maketrans and translate methods, which were used by tank_cmd.py

Therefore when run with newer Python 3 interpreters, e.g. 3.7.6 from ShotGrid Desktop, calling shotgun_run_action_auth() will fail with

Traceback (most recent call last):
  File "/path/to/pipe-cfg/install/core/scripts/tank_cmd.py", line 1776, in <module>
    install_root, pipeline_config_root, is_localized, cmd_line[1:]
  File "/path/to/pipe-cfg/install/core/scripts/tank_cmd.py", line 643, in shotgun_run_action_auth
    rot13 = string.maketrans(
AttributeError: module 'string' has no attribute 'maketrans'

Fixed

  • Using new _unswizzled_password() for Python 2 and 3 compatible rot-13 translation.

@jfboismenu
Copy link
Contributor

Hi @j0yu , I'm curious how you've run into this. IIRC this code was called from the old browser plugin based Shotgun integrations, which we stopped supporting years ago.

@jfboismenu
Copy link
Contributor

Once reason why we deprecated it was because it was totally unsafe, as you can imagine.

@j0yu
Copy link
Author

j0yu commented Jul 12, 2021

I ran into this trying to replicate the tank call I thought the "Clone this Configuration..." button would run, which resulted in

tank shotgun_run_action_auth __clone_pc "uid:name:linuxPath:macPath:winPath" "primaryCfgID" "userLogin" -

Is there a more modern CLI or API call that I can make to achieve what "Clone this Configuration..." button does?

@jfboismenu
Copy link
Contributor

There's not, no, but I'm surprised you ran into this code. Did you get a prompt asking you for your password when you ran this? Which platform are you running this on? Browser? Are you using the Shotgun Desktop for the browser integration or a super old browser with the java/browser plugin?

@j0yu
Copy link
Author

j0yu commented Jul 12, 2021

I'm currently running this on CentOS 7, Google Chrome 91.
It does prompt when my session token has expired, as per tank_cmd.py:shotgun_run_action_auth() when using - as password (final argument in CLI).

In practice, I'm just running the tank shotgun_run_action_auth ... from a shell, or Python subprocess.Popen, completely bypassing the web browser as I'm able to setup the colon-separated field values myself.

There's not, no, but I'm surprised you ran into this code.

So far as I have looked, this seems to be the most publicly available, dev-friendly way I could find to be able to perform the "Clone this Configuration..." action as described in Clone the Pipeline Configuration you want to add an app to and many of the other, official ShotGrid documentations.

Another option is to have tk-core/scripts and tk-core/python set in PYTHONPATH, then importing tank_cmd as a module:

import tank_cmd
tank_cmd.shotgun_run_action_auth(...)

But both running from shell using tank or through Python module raises errors if the Python interpreter that eventually runs the tank_cmd.py script is newer than, or is, Python 3.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants