Shotgun事件驱动的自动化流程

我们在shotgun中的各种操作都会被记录到Eventlog实体当中,所以如果我们一直轮询Eventlog实体通过对比新增变化就可以实现相关的自动化操作。


ShotgunEvents框架

GitHub:ShotgunEvents

ShotgunEvents框架是一个在服务器上运行并监视Shotgun事件流的守护进程,当捕获到事件后,守护程序会将事件交给一系列已注册的插件。每个插件都可以通过匹配事件去执行相应的动作。

++安装ShotgunEvents框架及相关库++

  • 安装Shotgun_api3

如果你已经安装过Shotgun_api3了,可以忽略以下操作。

1.pip安装
pip install git+git://github.com/shotgunsoftware/python-api.git
2.手动安装

可以从Github下载最新版本或将存储库克隆到本地文件系统。只需要将其保存在本地Python可以找到的位置即可。

  • 安装ShotgunEvents

    1.clone 安装
    cd E:/git_codegit clone git://github.com/shotgunsoftware/shotgunEvents.git
    2.手动安装

    直接从GitHub:ShotgunEvents上下载后解压到你想放到的文件夹就行。

  • 安装pywin32

    pip install pywin32

++配置ShotgunEvents框架++

官方配置文档

1.修改shotgunEventDaemon.conf文件

进入ShotgunEvents文件夹,将shotgunEventDaemon.conf.example复制一份为shotgunEventDaemon.conf

[daemon]值是路径的参数,如果你电脑上没有这个路径,必须重新指定一个路径

[daemon]# General daemon operational settings# The pidFile is the location where the daemon will store its process id. If# this file is removed while the daemon is running, it will shutdown cleanly# after the next pass through the event processing loop.pidFile: E:/git_code/shotgunEvents-master/src/logs/shotgunEventDaemon/shotgunEventDaemon.pid# The eventIdFile is the location where the daemon will store the id of the last# processed event. This will allow the daemon to pick up where it left off when# last shutdown thus not missing any events. If you want to ignore any events# since last daemon shutdown, remove this file before daemon startup and the# daemon will process only new events created after startup.eventIdFile: E:/git_code/shotgunEvents-master/src/logs/shotgunEventDaemon/shotgunEventDaemon.id# The logging mode to operate in:# 0 = all log message in the main log file# 1 = one main file for the engine, one file per pluginlogMode: 1# The path where to put log fileslogPath: E:/git_code/shotgunEvents-master/src/logs/shotgunEventDaemon# The name of the daemon log file. The setup is for 10 log files that rotate# every night at midnightlogFile: shotgunEventDaemon# The level of logging that should be sent to the log file. This value is only# applicable to for the main dispatching engine and can be overriden on a per# plugin basis. This value is passed to the logging library. Any positive# integer value is valid but most common cases are:# - 10 - Debug# - 20 - Info# - 30 - Warnings# - 40 - Error# - 50 - Criticallogging: 20# Enable Timing logging# Timing logging is a separate log file that will log timing information regarding# event dispatching and processing run time. This is to help diagnose which plugins# are taking the most amount of time and where any potential queue processing# delay might be coming from. Valid values are `on` or to enable or anything else# to disable.# timing_log: ontiming_log: off# If the connection to shotgun fails, number of seconds to wait until we retry.# This allows for occasional network hiccups, server restarts, application maintenance,# etc.conn_retry_sleep = 60# Number of times to retry connection before logging an error level message (which# sends an email in the default configuration)max_conn_retries = 5# Number of seconds to wait before requesting new events after each batch of events# is done processingfetch_interval = 5# Maimum number of events to fetch at once.max_event_batch_size = 500

[shotgun]里面的参数你必须要提供的参数:

  • Shotgun服务器网址
  • 用于连接Shotgun的脚本的名称和密钥
[shotgun]# Shotgun connection options for the daemon# The Shotgun url the event processing framework should connect to.server: https://kj.shotgunstudio.com # The Shotgun script name the framework should connect with.name: shotgunEventDaemon# The Shotgun api key the framework should connect with. You'll need to replace# this random useless key with the one corresponding to the script you've setup.key: kubmbuqux~xsltvwjsuqgpb1L# The address of the proxy server used to connect to your Shotgun server# in the format 111.222.333.444:8080. Leave this empty if you don't have# a proxy server.proxy_server: # Sets the session_uuid from every event in the Shotgun instance to propagate in# any events generated by plugins. This will allow the Shotgun UI to display# updates that occur as a result of a plugin.## Shotgun server v2.3+ required.# Shotgun API v3.0.5+ requireduse_session_uuid: True

[plugins]里面的参数你必须要提供的参数:

  • 你存放自己开发的插件的地方,框架运行的时候会去你给的目录下寻找
[plugins]# Plugin related settings# A comma delimited list of paths where the framework should look for plugins to# load.paths: E:/git_code/shotgunEvents-master/src/plugins[emails]# Email notification settings. These are used for error reporting because we# figured you wouldn't constantly be tailing the log and would rather have an# active notification system.## Any error above level 40 (ERROR) will be reported via email.## All of these value must be provided for there to be email alerts sent out.# The server that should be used for smtp connections. The username and password# values can be uncommented to supply credentials for the smtp connection. The# smtp port can also be uncommented to supply an alternate port such as 587 for# GMail TLS SMTP. As for the useTLS parameter, it is a True/False value.server: smtp.yourdomain.com#port: 587#useTLS: True#username: yourSMTPUsername#password: yourSMPTPassword# The from address that should be used in emails.from: support@yourdomain.com# A comma delimited list of email addresses to whom these alerts should be sent.to: you@yourdomain.com# An email subject prefix that can be used by mail clients to help sort out# alerts sent by the Shotgun event framework.subject: [SG]

++运行ShotgunEvents框架++

你可以拿一个examplePlugins文件夹里的文件放到你指定的[plugins]路径里面做个测试

E:\git_code\shotgunEvents-master\src>python2 E:\git_code\shotgunEvents-master\src\shotgunEventDaemon.py foreground

关于框架:

  • ShotgunEvent的执行逻辑是通过不断的轮询的方式来获取事件的更新,在网络资源的使用上有些浪费
  • 可以开发脚本进行自动化shotgun的相关操作。
(0)

相关推荐