3

Non interactive tank project creation

Hi

I wonder if there is a way to create Tank projects from the API or not ? For the moment, when I want to create a tank project, I use the tank setup_project command line. This launch an interactive bash script where I have to give some answer to create the project. I'd like to create Tank projects from a python script and I haven't found any functions in the API to do that. How can I do ? Is there a way to pass all the arguments to the setup_project command line in one time ? Maybe I have to write my own python file that create the project ?

 

Thanks a lot for your answer !

댓글 8개

  • 0
    Avatar
    Manne Öhrström

    Hello Barbara!

    Great question! We are working on this feature right now and it will be released in the coming weeks! I'll update this thread once it has been released!

    Thanks! 

    Manne

     

  • 0
    Avatar
    Barbara Laigneau

    Hello Manne!

     

    It's great! I'm looking forward to your release!

     

    Thanks a lot!

     

    Barbara

  • 0
    Avatar
    Benoit Leveau

    Ideally it would take the following parameters: the Project id, the different paths to create on disk (for the job and the shotgun code), and the path to take the config from (either another project or a git location, as supported in the new core)

    So it would give something like: (omitting the windows path for the config would set an empty path)

    tank setup_project --projectid=124 --linux_job=/jobs/aaa --mac_job=/jobs/aaa --win_job=M:/jobs/aaa --linux_code=/code/shotgun/aaa --mac_code=/code/shotgun/aaa --config_origin=/code/git/shotgun/sgtk_config.git

    Would that make sense?

  • 0
    Avatar
    Samsher Chahar

    Hi Barbara

     

    Have a look at pexpect python module. It can be used to control and automate terminal commands. It should work for you.

     

    Cheers 

    Samsher

     

  • 0
    Avatar
    Ian Thompson

    We're using the pexpect module to handle this too. However, if any of the output changes (eg. if things are re-worded to make them clearer) we'll be in trouble. There is also an issue of setting the timeout long enough to allow the necessary downloads to complete before hitting the next prompt.

    So pexpect is a good interim solution, but we're also keen to have a command line (or better yet: an API) for project creation. The same goes for the activation script - we like to keep a few tk-core versions around too - is this tool getting the same treatment? Very much looking forward to the coming release anyway.

    Thanks,

    Ian

  • 0
    Avatar
    Manne Öhrström

    Hey all,

    Super interesting thread!

    We were actually thinking about adding API support to setup project rather than adding lots of script parameters to the commands. The plan is to add support so that most common tank commands can be executed this way. This would give you guys the flexibility to integrate it in other python scripts, and of course also create small wrapper scripts if you want to run them from the command line! We were thinking of having two new methods added to the core API: sgtk.list_commands() and sgtk.create_command(command_name). The list method would return a list of strings of all the commands available in the system and the create command would return a instance of a class SgtkSystemCommand on which you could introspect which parameters the command requires, if there are any default settings for parameters, description and other metadata. And of course also a method to execute the command once the parameters have been populated. You can attach your own logger to the command to receive output, or just leave it to use a default logging.

    What do you guys think about that? Curious to hear your thoughts!

  • 0
    Avatar
    Ian Thompson

    I'd perhaps suggest get_command rather than create_command but that sounds wonderful!

    On the subject of creating commands, is there a way for apps to register new commands with a core (or equivalently for the core to discover additional commands defined by apps)? Always wondered. Thanks.

     

  • 0
    Avatar
    Manne Öhrström

    Dear all,

    This just got pushed out in v0.14.37 of the core. Most of the tank commands are now accessible via the API. Hope you find it useful! You can find documentation here: https://support.shotgunsoftware.com/entries/95441117

    Any questions, you know where to find us :)

댓글을 남기려면 로그인하세요.