Skip to content

Instantly share code, notes, and snippets.

@bohdon
Created April 22, 2023 14:20
Show Gist options
  • Save bohdon/6ced3608df7c4d4b9d6d84fb56a869c3 to your computer and use it in GitHub Desktop.
Save bohdon/6ced3608df7c4d4b9d6d84fb56a869c3 to your computer and use it in GitHub Desktop.
Create a standard p4 workspace using the primary root, sgtk user, and current host name.
# Create a standard workspace using the primary root, sgtk user, and current host name.
# Intended to be run in the Python Console from ShotGrid Desktop.
import os
import socket
from pathlib import Path
import sgtk
p4fw = sgtk.platform.framework.load_framework(engine, engine.get_env(), 'tk-framework-perforce2_v0.x.x')
root_path = tk.roots['primary']
depot = "//" + Path(root_path).parts[-1]
user = sgtk.get_authenticated_user().login
host = socket.gethostname()
p4fw.utils.create_client(root_path, exact_root=True, depot=depot, user=user, host=host)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment