#!/usr/bin/env python
import re
import sys
import os, time
from PyQt4 import QtCore, QtGui
from backUpUi import Ui_MainWindow
from shotgun_api3 import Shotgun
def getShotgunObject():
sgServer = "https://abcdsdf.dsfasdfsadfsdf.com"
sgScriptName = "dfsadfsadfsadfdsafd"
sgScriptKey = "dfsad43lkj453-0-if4334lkjlkjx"
sg = Shotgun(sgServer, sgScriptName, sgScriptKey)
return sg
class callerThread
(QtCore.
QThread):
def __init__(self, func, parent=None, *args, **kwargs):
super(callerThread, self).__init__(parent)
self._func = func
self._args = args
self._kwargs = kwargs
def run(self):
self._func(*self._args, **self._kwargs)
updateText = QtCore.pyqtSignal()
def __init__(self, parent=None):
super(Monitor, self).__init__(parent)
self.shotgun = getShotgunObject()
def update_list(self):
t_monitor = callerThread(self.monitor_vector, parent=self)
t_monitor.daemon = True
t_monitor.start()
def monitor_vector(self):
print "... emitting "
self.updateText.emit()
setText = QtCore.pyqtSignal()
"""UI functionality to pack stuff for client"""
def __init__(self,parent=None):
super(backUpMain, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.jobName = os.getenv('JOB')
self.shotgun = getShotgunObject()
self.dept = {}
self.connect(self.ui.okButton, QtCore.SIGNAL("clicked()"), self.startThread)
self.ui.cancelButton.released.connect(sys.exit)
self.ui.selectInFile.clicked.connect(self.selectInputFile)
self.ui.selectOutFile.clicked.connect(self.selectOutputFile)
self.ui.confirmButton.clicked.connect(self.validateAll)
self.ui.clearCheckBox.clicked.connect(self.clearBox)
self.ui.clearAllButton.clicked.connect(self.clearAll)
def getIndPathFromShotgun(self):
projectId = self.getProjectId(self.jobName)
filters = [['project','is',{'type':'Project','id':projectId}]]
field1 = "sg_ind_path_to_frames"
fields = []
fields.append(field1)
indPath = self.shotgun.find("Version", filters, fields)
print " >>>> inside get ind path from shotgun "
return indPath
def _handlebackUp(self):
self.ui.logEdit.clear()
outPutFileName = self.ui.outEdit.text()
inputData = self.getInputContent(self.ui.filePathEdit.text())
print " #### projectId in shotgun ",projectId
self.startThread()
print " #### post start thread "
def getProjectId(self, job):
result = self.shotgun.find_one("Project", [['name', 'is', job]])
prJid = int(result['id'])
return prJid
def startThread(self):
self.monitor = Monitor()
print "in start thread"
self.monitor.updateText.connect(self.getIndPathFromShotgun)
self.monitor.update_list()
print "post start thread"
def getInputContent(self, data):
'''
check if data is file or group of shotnames or blank
'''
# print " data ",data
reg = r'[^a-zA-Z0-9]'
shotList = []
if os.path.isfile(data):
with open(data) as inf:
for line in inf:
shotList.append(line.rstrip("\n"))
# print "shotList ", shotList
elif data == "":
# make backup of all shots
shotList.append(None)
else:
sss = re.findall(reg,data)
if sss == []:
message = "No seperator found. Try again. | or , or any non alpha numeric"
self.ui.logEdit.append(message)
return -1
else:
tmp = data.split(sss[0])
for each in tmp:
shotList.append(each)
return shotList
.
.
.
.
.
def main():
dialog = backUpMain()
dialog.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
#!/usr/bin/env python
import re
import sys
import os, time
from PyQt4 import QtCore, QtGui
from backUpUi import Ui_MainWindow
from shotgun_api3 import Shotgun
def getShotgunObject():
sgServer = "https://abcdsdf.dsfasdfsadfsdf.com"
sgScriptName = "dfsadfsadfsadfdsafd"
sgScriptKey = "dfsad43lkj453-0-if4334lkjlkjx"
sg = Shotgun(sgServer, sgScriptName, sgScriptKey)
return sg
class callerThread(QtCore.QThread):
def __init__(self, func, parent=None, *args, **kwargs):
super(callerThread, self).__init__(parent)
self._func = func
self._args = args
self._kwargs = kwargs
def run(self):
self._func(*self._args, **self._kwargs)
class Monitor(QtCore.QObject):
updateText = QtCore.pyqtSignal()
def __init__(self, parent=None):
super(Monitor, self).__init__(parent)
self.shotgun = getShotgunObject()
def update_list(self):
t_monitor = callerThread(self.monitor_vector, parent=self)
t_monitor.daemon = True
t_monitor.start()
def monitor_vector(self):
print "... emitting "
self.updateText.emit()
class backUpMain(QtGui.QMainWindow):
setText = QtCore.pyqtSignal()
"""UI functionality to pack stuff for client"""
def __init__(self,parent=None):
super(backUpMain, self).__init__(parent)
self.ui = Ui_MainWindow()
self.ui.setupUi(self)
self.jobName = os.getenv('JOB')
self.shotgun = getShotgunObject()
self.dept = {}
self.connect(self.ui.okButton, QtCore.SIGNAL("clicked()"), self.startThread)
self.ui.cancelButton.released.connect(sys.exit)
self.ui.selectInFile.clicked.connect(self.selectInputFile)
self.ui.selectOutFile.clicked.connect(self.selectOutputFile)
self.ui.confirmButton.clicked.connect(self.validateAll)
self.ui.clearCheckBox.clicked.connect(self.clearBox)
self.ui.clearAllButton.clicked.connect(self.clearAll)
def getIndPathFromShotgun(self):
projectId = self.getProjectId(self.jobName)
filters = [['project','is',{'type':'Project','id':projectId}]]
field1 = "sg_ind_path_to_frames"
fields = []
fields.append(field1)
indPath = self.shotgun.find("Version", filters, fields)
print " >>>> inside get ind path from shotgun "
return indPath
def _handlebackUp(self):
self.ui.logEdit.clear()
outPutFileName = self.ui.outEdit.text()
inputData = self.getInputContent(self.ui.filePathEdit.text())
print " #### projectId in shotgun ",projectId
self.startThread()
print " #### post start thread "
def getProjectId(self, job):
result = self.shotgun.find_one("Project", [['name', 'is', job]])
prJid = int(result['id'])
return prJid
def startThread(self):
self.monitor = Monitor()
print "in start thread"
self.monitor.updateText.connect(self.getIndPathFromShotgun)
self.monitor.update_list()
print "post start thread"
def getInputContent(self, data):
'''
check if data is file or group of shotnames or blank
'''
# print " data ",data
reg = r'[^a-zA-Z0-9]'
shotList = []
if os.path.isfile(data):
with open(data) as inf:
for line in inf:
shotList.append(line.rstrip("\n"))
# print "shotList ", shotList
elif data == "":
# make backup of all shots
shotList.append(None)
else:
sss = re.findall(reg,data)
if sss == []:
message = "No seperator found. Try again. | or , or any non alpha numeric"
self.ui.logEdit.append(message)
return -1
else:
tmp = data.split(sss[0])
for each in tmp:
shotList.append(each)
return shotList
.
.
.
.
.
def main():
app = QtGui.QApplication(sys.argv)
dialog = backUpMain()
dialog.show()
sys.exit(app.exec_())
if __name__ == '__main__':
main()
To copy to clipboard, switch view to plain text mode
Bookmarks