Skip to content

Using _unswizzled_password - #813

Open
j0yu wants to merge 1 commit into
shotgunsoftware:masterfrom
wwfxuk:fix-string-tranlate-bug
Open

Using _unswizzled_password#813
j0yu wants to merge 1 commit into
shotgunsoftware:masterfrom
wwfxuk:fix-string-tranlate-bug

Conversation

@j0yu

@j0yu j0yu commented Jul 12, 2021

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
Contributor

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

@j0yu

j0yu commented Jul 12, 2021

Copy link
Copy Markdown
Author

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
Copy Markdown
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

j0yu commented Jul 12, 2021

Copy link
Copy Markdown
Author

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