Skip to content

Instantly share code, notes, and snippets.

View kporangehat's full-sized avatar
🏠
Working from home

KP kporangehat

🏠
Working from home
View GitHub Profile
@kporangehat
kporangehat / dialog.py
Created February 9, 2023 20:44
SGTK App with QScrollArea tabs example
# Copyright (c) 2013 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.
@kporangehat
kporangehat / transfer_worker.py
Created November 23, 2021 20:34
adding Group from addressings to the context in Create Shipment
# We use the Project context, not the app context, to evaluate the root for all local copies, which shouldn't be
# dependent on individual Versions. This allow as well to have a template defined as a `path` template
# instead of a `string` template and not having TK failing for a missing path on the file system.
project_context = self._app.sgtk.context_from_entity_dictionary(
self._app.context.project
)
field_data = project_context.as_template_fields(
template,
)
@kporangehat
kporangehat / filter_publishes.py
Last active April 8, 2021 23:08
Shotgun Toolkit filter_publishes hook for tk-multi-workfiles2. This hook ensures path cache entries are generated for any publishes that were generated using `register_publish()` for entities that may not have folders created yet.
import os
import re
import sgtk
HookClass = sgtk.get_hook_baseclass()
class FilterPublishes(HookClass):
"""
@kporangehat
kporangehat / sgtk_user_auth_interactive.py
Last active September 25, 2017 23:38
Shotgun Toolkit Authentication examples
# Import Toolkit so we can access to Toolkit specific features.
import sgtk
# Import the ShotgunAuthenticator from the tank_vendor.shotgun_authentication
# module. This class allows you to authenticate either programmatically or, in this
# case, interactively.
from tank_vendor.shotgun_authentication import ShotgunAuthenticator
# Instantiate the CoreDefaultsManager. This allows the ShotgunAuthenticator to
# retrieve the site, proxy and optional script_user credentials from shotgun.yml
@kporangehat
kporangehat / register_publish.py
Created March 15, 2016 00:42
Shotgun Toolkit register_publish() example
"""
Bootstrap script to use for registering a publish. Includes authentication and assumes file
is already in the correct location in the directory structure and is named correctly to match
an appropriate template.
"""
import sys
# Append path to your studio core location so sgtk can be imported. If you don't have a studio
# core, you can use the project-specific core location for the files you're publishing.
sys.path.append("/sgtk/software/shotgun/studio/install/core/python")
import sgtk
@kporangehat
kporangehat / mitmproxy_error.md
Last active March 10, 2016 21:47
This is an error I received in the `mitmproxy` event log while running a python script to connect to our server over `HTTPS`.

Summary

This is an error I received in the mitmproxy event log while running a python script to connect to our server over HTTPS. The script uses httplib2 (we need to support old Python versions :/).

Issue details
  • Python 2.7.10 (using pyenv)
  • OS X 10.11
  • ssl module compiled against OpenSSL v0.9.8zg
  • HTTPS connection fails with the following error from the event log in mitmproxy
Error
@kporangehat
kporangehat / 0_reuse_code.js
Created March 9, 2016 21:59
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@kporangehat
kporangehat / method_perms.rb
Last active December 28, 2015 05:39
#23277
# PRODUCTION
# ----------
# Admin (admin)
# API Admin (api_admin)
# Manager (manager)
# Artist (artist)
# Admin Defaults (admin_system_default)
# Script Defaults (api_admin_system_default)
# Manager Defaults (manager_system_default)
# Artist Defaults (artist_system_default)
# Takes 2 PermissionRuleSet code values and does a comparison of all
# entity-level and field-level rules.
#
# The diff is calculated by running PermissionRuleSet.allow? on each
# type of rule and storing the result in a hash for that ruleset. Then
# a diff is run on the two tables to generate the result.
#
# If a field is missing on the current instance, the call to allow? should
# still return the correct result as if the field existed. Missing fields
# are designated with an * before the field name. The ruleset that references
@kporangehat
kporangehat / gist:4588193
Last active December 11, 2015 10:38
Shotgun production log format

Overview

The production log can be useful for installed clients who want to monitor, diagnose, or report on the granular usage of Shotgun. Because the production log is a log file located on the Shotgun server itself, this is only available for installed clients.

This format may change without warning
This format may (and probably will) change from time to time as we adjust and tweak the output to better match the needs of our clients. Please keep this in mind if you write tools for parsing, etc. We will make every attempt to keep this document up to date, but changes might not be documented immediately. So rely on this at your own peril ;)

General Log Format