Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Maya Time Tracker v1.3
- # cwisbg
- # current output format
- # project,theTime,tasks,notes,inOut
- # Instructions:
- # Set your project, and run script. Fill in tasks your working on, and/or leave a note. when your done clock out. Will also clock out
- # when Maya closes.
- # To add more tasks, add to line
- # Add more tasks here
- tasksList = "Modeling","Texturing","Shading","Lighting","Rigging","Animation","Layout","Rendering"
- from pymel.core import *
- import time
- import os
- def getTasks(t):
- taskString = ""
- for t in taskList:
- if t[0].getValue():
- taskString += t[1]+","
- return taskString[:-1]
- def getTime():
- start = time.clock()
- theTime = time.localtime()
- year = theTime[0]
- month = theTime[1]
- day = theTime[2]
- hr = theTime[3]
- min = theTime[4]
- if min < 10:
- min = "0"+str(min)
- theTimeFormated = str(day)+"/"+str(month)+"/"+str(year)+","+str(hr)+":"+str(min)
- return theTimeFormated
- def writeData(inOut,tasks):
- w = workspace(act=1, q=1)
- project = w.split("/")[-1]
- w = "Z:/!Artists/Brandon/00_timeTracking"
- theTime = getTime()# get the time
- wT = w+"/timeTracker_"+project+".txt"
- trackerFile = open(wT,"a+")
- writer = project+","+theTime+","+inOut+","+notes+","+tasks+"\r\n"
- trackerFile.write(str(writer))
- trackerFile.close()
- print writer
- def buttonPressedIn():
- global notes
- notes = noteField.getText().replace(",", "|")
- tasks = getTasks(taskList)# get Tasks
- writeData("in",tasks)
- win.delete()
- def buttonPressedOut():
- global notes
- notes = noteField.getText().replace(",", "|")
- tasks = getTasks(taskList)# get Tasks
- writeData("out",tasks)
- if exitJob:
- scriptJob(k=exitJob)
- win.delete()
- def exitOut():
- if inOutCheck == "in":
- tasks = ""
- writeData("out",tasks)
- def checkInOut():
- w = workspace(act=1, q=1)
- project = w.split("/")[-1]
- w = "Z:/!Artists/Brandon/00_timeTracking"
- wT = w+"/timeTracker_"+project+".txt"
- trackerFile = open(wT,"a+")
- trackerFileRead = trackerFile.readlines()
- lastLine = trackerFileRead[-1:][0]
- print lastLine
- if lastLine:
- lastLine = lastLine.split(",")
- if lastLine[3] == "out":
- return "out"
- else:
- return "in"
- else:
- return "out"
- global tasks, win, w,theTime, exitJob, inOutCheck
- tasks = []
- scriptJob(ka=1)
- exitJob = scriptJob(e=["quitApplication",exitOut])
- win = window(title= "Gui", s=0,w=10,rtf=1)
- mainLayout = rowColumnLayout(nc=1)
- taskList = []
- for t in tasksList:
- tb = checkBox(l = t)
- add = [tb,t]
- taskList.append(add)
- text("Notes")
- noteField = textField()
- buttonLayout = rowColumnLayout(nc=2,p=mainLayout)
- mustOutIn = 1
- mustOutColorIn = [.2,.7,.2]
- mustOutOut = 1
- mustOutColorOut = [.7,.2,.2]
- inOutCheck = checkInOut()
- if inOutCheck == "in":
- print "Did not clock out"
- mustOutIn = 0
- mustOutColorIn = [.5,.5,.5]
- else:
- mustOutOut = 0
- mustOutColorOut = [.5,.5,.5]
- buttonIn = button(l="In", command=Callback(buttonPressedIn),p=buttonLayout,w=50,bgc=mustOutColorIn,en=mustOutIn)
- buttonOut = button(l="Out", command=Callback(buttonPressedOut),p=buttonLayout,w=50,bgc=mustOutColorOut,en=mustOutOut)
- win.show()
Advertisement
Add Comment
Please, Sign In to add comment