cwisbg

Maya Time Tracker v1

Jun 1st, 2015
517
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.28 KB | None | 0 0
  1. # Maya Time Tracker v1.3
  2. # cwisbg
  3. # current output format
  4. # project,theTime,tasks,notes,inOut
  5. # Instructions:
  6. # 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
  7. # when Maya closes.
  8. # To add more tasks, add to line
  9. # Add more tasks here
  10. tasksList = "Modeling","Texturing","Shading","Lighting","Rigging","Animation","Layout","Rendering"
  11. from pymel.core import *
  12. import time
  13. import os
  14. def getTasks(t):
  15.     taskString = ""
  16.     for t in taskList:
  17.         if t[0].getValue():
  18.             taskString += t[1]+","
  19.     return taskString[:-1]
  20. def getTime():
  21.     start = time.clock()
  22.     theTime = time.localtime()
  23.     year = theTime[0]
  24.     month = theTime[1]
  25.     day = theTime[2]
  26.     hr = theTime[3]
  27.     min = theTime[4]
  28.     if min < 10:
  29.         min = "0"+str(min)
  30.     theTimeFormated = str(day)+"/"+str(month)+"/"+str(year)+","+str(hr)+":"+str(min)
  31.     return theTimeFormated
  32. def writeData(inOut,tasks):
  33.     w = workspace(act=1, q=1)
  34.     project = w.split("/")[-1]
  35.     w = "Z:/!Artists/Brandon/00_timeTracking"
  36.     theTime = getTime()# get the time
  37.     wT = w+"/timeTracker_"+project+".txt"
  38.     trackerFile = open(wT,"a+")
  39.     writer = project+","+theTime+","+inOut+","+notes+","+tasks+"\r\n"
  40.     trackerFile.write(str(writer))
  41.     trackerFile.close()    
  42.     print writer  
  43. def buttonPressedIn():
  44.     global notes
  45.  
  46.     notes = noteField.getText().replace(",", "|")
  47.     tasks = getTasks(taskList)# get Tasks
  48.     writeData("in",tasks)
  49.     win.delete()
  50. def buttonPressedOut():
  51.     global notes
  52.     notes = noteField.getText().replace(",", "|")
  53.     tasks = getTasks(taskList)# get Tasks
  54.     writeData("out",tasks)
  55.     if exitJob:
  56.         scriptJob(k=exitJob)
  57.     win.delete()
  58. def exitOut():
  59.     if inOutCheck == "in":
  60.         tasks = ""
  61.         writeData("out",tasks)  
  62.    
  63. def checkInOut():
  64.     w = workspace(act=1, q=1)
  65.     project = w.split("/")[-1]
  66.     w = "Z:/!Artists/Brandon/00_timeTracking"
  67.     wT = w+"/timeTracker_"+project+".txt"
  68.     trackerFile = open(wT,"a+")
  69.     trackerFileRead = trackerFile.readlines()
  70.     lastLine = trackerFileRead[-1:][0]
  71.     print lastLine
  72.     if lastLine:
  73.         lastLine = lastLine.split(",")
  74.         if lastLine[3] == "out":
  75.             return "out"
  76.         else:
  77.             return "in"
  78.     else:
  79.         return "out"
  80. global tasks, win, w,theTime, exitJob, inOutCheck
  81. tasks = []
  82. scriptJob(ka=1)
  83. exitJob = scriptJob(e=["quitApplication",exitOut])
  84. win = window(title= "Gui", s=0,w=10,rtf=1)
  85. mainLayout = rowColumnLayout(nc=1)
  86. taskList = []
  87. for t in tasksList:
  88.     tb = checkBox(l = t)
  89.     add = [tb,t]
  90.     taskList.append(add)
  91. text("Notes")
  92. noteField = textField()
  93. buttonLayout = rowColumnLayout(nc=2,p=mainLayout)
  94. mustOutIn = 1
  95. mustOutColorIn = [.2,.7,.2]
  96. mustOutOut = 1
  97. mustOutColorOut = [.7,.2,.2]
  98. inOutCheck = checkInOut()
  99.  
  100. if inOutCheck == "in":
  101.     print "Did not clock out"
  102.     mustOutIn = 0
  103.     mustOutColorIn = [.5,.5,.5]
  104. else:
  105.     mustOutOut = 0
  106.     mustOutColorOut = [.5,.5,.5]    
  107. buttonIn = button(l="In", command=Callback(buttonPressedIn),p=buttonLayout,w=50,bgc=mustOutColorIn,en=mustOutIn)
  108. buttonOut = button(l="Out", command=Callback(buttonPressedOut),p=buttonLayout,w=50,bgc=mustOutColorOut,en=mustOutOut)
  109. win.show()
Advertisement
Add Comment
Please, Sign In to add comment