def run(): try: t_tw = cgtw.tw() t_database = t_tw.sys().get_sys_database() t_module = t_tw.sys().get_sys_module() t_id_list = t_tw.sys().get_sys_id() if len(t_id_list) == 0 or isinstance(t_id_list, list) == False: message().error(u"请选项任务") t_maya_data = t_tw.con._send("c_software", "get_path_and_argv_with_type", { "db": t_database, "type": "maya" }) if t_maya_data.has_key('path') == False and t_maya_data.has_key( "argv") == False: message().error(u"读取软件路径失败, 请检查是否有配置nuke类型的软件, 注意:类型是小写的nuke") t_maya_path = t_maya_data["path"].strip() t_argv = re.sub("\s+", " ", t_maya_data["argv"].strip()) t_argv = t_argv.replace("./base", t_base_path) if not os.path.exists(t_maya_path): message().error(u"请确认maya安装路径是否存在") t_filebox_id = t_tw.sys()._get_sys_key("filebox_id") t_file_list = t_tw.sys().get_sys_file() t_file = "" if len(t_file_list) != 0: t_file = t_file_list[0] t_cmd = ' '.join([ t_maya_path, t_argv, t_database, t_module, "id:" + t_id_list[0], t_filebox_id, "False", "file:" + t_file ]) subprocess.call(t_cmd) except Exception, e: message().error(e.message)
def __init__(self): import cgtw try: self._t_tw = cgtw.tw() except: nuke.message('Please open CGteamwork') return False
def __init__(self): import cgtw import cgtw2 try: self._t_tw = cgtw.tw() self._t_tw2 = cgtw2.tw() #cgtw2 api 用来获取 a_flow_id except: nuke.message('Please open CGteamwork') return False
def __init__(self, parent=None): super(GetProjectProgressDialog, self).__init__(parent) self.parent_win = parent # 获取CGTeamWork的实例,用于操作teamwork数据 self.t_tw = cgtw.tw() # 设置窗口样式(无标题) self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) self.label = QLabel('获取项目信息中...') self.label.setFont(QFont('Microsoft YaHei', 18)) self.label.setStyleSheet('''QLabel{color:rgb(155,155,155)}''') self.label.setFixedSize(250, 30) # 设置背景色 self.setStyleSheet('''QDialog{background-color:black}''') # 创建进度条控件 self.pbar = QProgressBar() # 创建时间对象(用于控制进度条) self.timer = QBasicTimer() self.step = 0 self.resize(350, 220) self.setWindowTitle('GETTING_PROJECTS...:') layout = QVBoxLayout() layout.addWidget(self.label, 0, Qt.AlignHCenter) layout.addWidget(self.pbar) layout.setSpacing(0) self.setLayout(layout) layout.setContentsMargins(20, 0, 20, 0) self.pbar.resize(200, 55) self.pbar.setStyleSheet(''' QProgressBar{ border:1px solid rgb(188,188,188); border-radius:10px; text-align:center; color:rgb(74,0,5); background:grey;} QProgressBar::chunk{ border-radius:10px; background:qlineargradient(spread:pad,x1:0,y1:0,x2:1,y2:0,stop:0 rgb(158,98,0),stop:1 rgb(255,0,9)); } ''') # 设置窗口对齐桌面正中 # 获取屏幕坐标系 screen = QDesktopWidget().screenGeometry() # 获取窗口坐标系 size = self.geometry() newLeft = (screen.width() - size.width()) / 2 newTop = (screen.height() - size.height()) / 2 self.move(newLeft, newTop) self.initUI()
def getShotDatasToJSFile(path=r'C:\HOME\.nuke\VCS\DATA'): """ This function is use to get shot data from CGTW with a json file :param path directory for json file path :return: None """ # connect cgtw sys.path.append(r"C:\cgteamwork\bin\base") import cgtw t_tw = cgtw.tw() # get current user account account = t_tw.sys().get_account() # get ready for get shot data ~_~ shotdatalist = [account] # get all projects in a list all_projects = getProjects(t_tw) #Make sure of file path if not os.path.exists(path): os.makedirs(path) filepath = os.path.join(path, 'data.json') for pro in all_projects: project_data_dict = {} # filter shots with project name filter_module = t_tw.task_module(pro, 'shot') # get eps shot and pipeline data from this project project_data_dict[pro] = filter_module.get_with_filter([ 'shot.shot', 'eps.eps_name', 'task.pipeline', 'task.leader_status', 'task.client_status' ], [['task.account', '=', account]]) if len(project_data_dict[pro]) != 0: # Add data to shotDataList shotdatalist.append(project_data_dict) # Save data to Json file jsshotdatalist = json.dumps(shotdatalist) with open(filepath, 'w') as f: f.write(jsshotdatalist)
def __init__(self, config=None): self._config = dict(self.config) self._total_assets_number = -1 if isinstance(config, dict): self._config.update(config) #pprint.pprint(self._config) self._tw = cgtw.tw() self._task_shots = self._tw.task_module(self._config['DATABASE'], self._config['SHOT_TASK_MODULE']) self._assets = self._tw.task_module(self._config['DATABASE'], self._config['ASSET_MODULE']) self._link = self._tw.link(self._config['DATABASE'], self._config['SHOT_TASK_MODULE']) self.check_login() self.get_shot_task_id() self.get_assets() if not self._config['asset_id_list']: print(u'没能从引用获取资产ID, 改为尝试从名称空间获取'.encode(SYS_CODEC)) self.get_assets_from_namespaces() print('') self.link_asset()
def main(): _tw = cgtw.tw() _sys = _tw.sys() _folder = _sys.get_sys_folder() _files = _sys.get_sys_file() or os.listdir(_folder) _database = _sys.get_sys_database() _maya = _tw.software(_database).get_software_path("maya") os.chdir(_folder) for _file in _files: if os.path.splitext(_file)[1] not in ['.ma', '.mb']: continue _log = tempfile.NamedTemporaryFile(delete=False).name _proc = Popen(u'"{maya}" -batch -file "{file}" -command "python \\"import wlf.cgteamwork;wlf.cgteamwork.CGTeamWork().call_script()\\"" -log {log}'.format(maya=_maya, file=_file, log=_log)) _proc.wait() with open(_log) as f: print(f.read()) os.remove(_log) pause()
def __init__( self, parent=None, ): super(InputDialog, self).__init__(parent) # 设置窗口样式(无标题) self.setWindowFlags(Qt.Dialog | Qt.FramelessWindowHint) # debug参数 self.debug1 = 0 self.debug2 = 0 self.debug3 = 0 # 创建一个路径对象,用于设置引用路径 self.path_obj = PathClass() # 设置默认参数 self.proj_list = ['-select-'] self.eps_list = ['-ALL-'] # 获取CGTeamWork的实例,用于操作teamwork数据 self.t_tw = cgtw.tw() # 设置表头显示样式 self.setWindowFlags(Qt.Dialog | Qt.WindowCloseButtonHint) self.setWindowTitle('InputDialog:') # 设置默认大小 self.resize(500, 250) # 设置背景色 self.setStyleSheet('''QDialog{background-color:black}''') # 创建所有要使用的控件 self.head_label = QLabel('请选择要检查的项目') self.head_label.setFont(QFont('Microsoft YaHei', 18, QFont.Bold)) self.head_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.head_label.setStyleSheet('''QLabel{color:red}''') self.proj_label = QLabel('PRO:') self.proj_label.setStyleSheet('''QLabel{color:red}''') self.proj_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.proj_label.setFont(QFont('Microsoft YaHei', 16)) self.proj_combo = QComboBox() self.comboStyle = '''QComboBox{font-size:16px; color:white; border-radius:4; background-color:grey; font-family:Microsoft YaHei; selection-background-color:grey; } QComboBox::drop-down{ image:url(%s/arrow_down_2.png); } QComboBox QAbstractItemView{ color:white; background-color:grey; selection-background-color:rgb(159,5,11); selection-color:white; }''' % self.path_obj.iconPath self.proj_combo.setStyleSheet(self.comboStyle) self.eps_label = QLabel('EPS:') self.eps_label.setStyleSheet('''QLabel{color:red}''') self.eps_label.setSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed) self.eps_label.setFont(QFont('Microsoft YaHei', 16)) self.eps_combo = QComboBox() self.eps_combo.setStyleSheet(self.comboStyle) self.line = QFrame() self.line.setFrameShape(QFrame.HLine) self.line.setLineWidth(2) self.line.setStyleSheet('''QFrame{color:rgb(127,127,127)}''') # 创建底部的INPUT按钮 self.inputButton = QPushButton('INPUT') self.inputButton.setFont(QFont('Microsoft YaHei', 20)) # inputButton 的样式QSS self.inputButton_style = ''' QPushButton{ border-radius:4px;background-color:rgb(185,111,2);color:white; border:1px solid rgb(125,125,125); } QPushButton:hover{ border-radius:4px;background-color:rgb(223,134,3);color:white; } QPushButton:pressed{ border-radius:4px;background-color:rgb(56,104,0);color:red; } ''' # 设置okButton的样式 self.inputButton.setStyleSheet(self.inputButton_style) # 设置鼠标滑过时的鼠标形状 self.inputButton.setCursor(Qt.PointingHandCursor) # 绑定底部按钮的槽函数 self.inputButton.clicked.connect(self.onInputButtonClicked) # 创建布局 # 整体布局 self.main_layout = QVBoxLayout() self.main_layout.setContentsMargins(0, 4, 0, 0) # 用于显示project和eps信息的布局 self.combo_layout = QGridLayout() # 右侧总体纵布局 self.info_layout = QVBoxLayout() # 中间左侧面板 self.midLeftWidget = QWidget() # 中间部分的spliter可拖动边界 self.splitter = QSplitter(Qt.Horizontal) self.splitter.setHandleWidth(2) self.splitter.setStyleSheet( '''QSplitter:handle{background-color:black}''') # 中间右侧面板 self.midRightWidget = QWidget() # 中间右侧面板的组件 self.totalCheckLabel = QLabel('今日任务总数:') self.totalCheckLabel.setStyleSheet( '''QLabel{color:rgb(178,178,178)}''') self.totalCheckLabel.setFont(QFont('Microsoft YaHei', 10, QFont.Bold)) self.waitingForChecker = QLabel('待检查任务总数:') self.waitingForChecker.setStyleSheet( '''QLabel{color:rgb(178,178,178)}''') self.waitingForChecker.setFont(QFont('Microsoft YaHei', 10, QFont.Bold)) self.totalCheckValue = QLabel('...') self.totalCheckValue.setStyleSheet('''QLabel{color:rgb(255,0,9)}''') self.totalCheckValue.setFont(QFont('Microsoft YaHei', 18, QFont.Bold)) self.waitingCheckerValue = QLabel('...') self.waitingCheckerValue.setStyleSheet( '''QLabel{color:rgb(255,152,0)}''') self.waitingCheckerValue.setFont( QFont('Microsoft YaHei', 18, QFont.Bold)) self.aprCheckLabel = QLabel('已通过任务总数:') self.aprCheckLabel.setStyleSheet('''QLabel{color:rgb(178,178,178)}''') self.aprCheckLabel.setFont(QFont('Microsoft YaHei', 10, QFont.Bold)) self.aprCheckerValue = QLabel('...') self.aprCheckerValue.setStyleSheet('''QLabel{color:rgb(124,227,4)}''') self.aprCheckerValue.setFont(QFont('Microsoft YaHei', 18, QFont.Bold)) # 默认状态下隐藏EPS选项 self.eps_label.setHidden(True) self.eps_combo.setHidden(True) # 设置project设置的初始值,用于判定是否设置了project,一旦选择了项目,就把第一个-select-选项去除 self.proj_set_index = 0 self.initUI() self.proj_combo.currentIndexChanged.connect(self.onProjectChange) self.eps_combo.currentIndexChanged.connect(self.onEpsChanged)
import sys,os sys.path.append(r"C:\cgteamwork\bin\base") import cgtw t_tw = cgtw.tw() t_account = t_tw.sys().get_account() t_filter_module = t_tw.task_module('proj_'+u'lah','shot') print t_filter_module.get_with_filter(['shot.shot','eps.eps_name','task.pipeline'],[['task.account','=',t_account]])
@author: Serious Sam ''' from cgtw import tw from barbarian.utils import config IP = "10.1.11.100" ACCOUNT_ID = "get_account_id" ACCOUNT_LOGGED_IN = "get_is_login" ACCOUNT_NAME = "account.name" ACCOUNT_DEPARTMENT = "account.department" tw(IP) def login(user, password): tw.sys().login(user, password, IP) def logout(): tw.sys().logout() def getAccountInfo(arg=ACCOUNT_ID): account_id = tw.sys().get_account_id() if arg == ACCOUNT_ID: return account_id elif arg == ACCOUNT_LOGGED_IN: