Skip to content

Commit

Permalink
Finalized the icons (and names) and started the Persistence area. Add…
Browse files Browse the repository at this point in the history
…ed a couple files to the .gitignore file (files used by LiClipse to set up a project)
  • Loading branch information
Joseph Bryan Gremlich committed Jan 15, 2015
1 parent b0ff04d commit 1b946ca
Show file tree
Hide file tree
Showing 9 changed files with 1,278 additions and 9 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.pyc
*.py~
.project
.pydevproject
4 changes: 2 additions & 2 deletions Ramari.desktop → Marzipan.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/usr/local/Mari2.5v2/Media/Icons/Mari.128x128.png
Name[en_US]=Ramari
Name[en_US]=Marzipan
Exec=/groups/ramshorn/ramshorn-tools/project_mari.sh
Comment[en_US]=Ram's Horn Mari
Name=Ramari
Comment=Ram's Horn Mari
Icon=/usr/local/Mari2.5v2/Media/Icons/Mari.128x128.png
Icon=/users/guest/g/gremlich/Documents/PapaPipe/papa-tools/icons/marzipan_halo.png
4 changes: 2 additions & 2 deletions Ramdini.desktop → Panini.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/opt/hfs.current/houdini_logo.png
Name[en_US]=Ramdini
Name[en_US]=Panini
Exec=/groups/ramshorn/ramshorn-tools/project_houdini.sh
Comment[en_US]=Ram's Horn Mari
Name=Ramari
Comment=Ram's Horn Mari
Icon=/opt/hfs.current/houdini_logo.png
Icon=/users/guest/g/gremlich/Documents/PapaPipe/papa-tools/icons/Panini_halo.png
Comment[en_US.UTF-8]=Ram's Horn Houdini FX
4 changes: 2 additions & 2 deletions Ramaya.desktop → Papaya.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/usr/autodesk/maya/icons/mayaico.png
Name[en_US]=Ramaya
Name[en_US]=Papaya
Exec=/groups/ramshorn/ramshorn-tools/project_maya.sh
Comment[en_US]=Ram's Horn Mari
Name=Ramari
Comment=Ram's Horn Mari
Icon=/usr/autodesk/maya/icons/mayaico.png
Icon=/users/guest/g/gremlich/Documents/PapaPipe/papa-tools/icons/papaya_halo.png
Comment[en_US.UTF-8]=Ram's Horn Maya
4 changes: 2 additions & 2 deletions NukesHorn.desktop → Pazuki.desktop
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ Version=1.0
Type=Application
Terminal=false
Icon[en_US]=/usr/local/Nuke8.0v3/plugins/icons/NukeApp128.png
Name[en_US]=NukesHorn
Name[en_US]=Pazuki
Exec=/groups/ramshorn/ramshorn-tools/project_nuke.sh
Comment[en_US]=Ram's Horn Mari
Name=Ramari
Comment=Ram's Horn Mari
Icon=/usr/local/Nuke8.0v3/plugins/icons/NukeApp128.png
Icon=/users/guest/g/gremlich/Documents/PapaPipe/papa-tools/icons/pizooki_halo.png
Comment[en_US.UTF-8]=Ram's Horn Nuke
142 changes: 142 additions & 0 deletions asset_manager/Persistence/checkoutDAO.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import utilities

#################################################################################
# Checkout
#################################################################################
def _createCheckoutInfoFile(dirPath, coPath, version, timestamp, lock):
"""
Creates a .checkoutInfo file in the directory specified by dirPath
@precondition: dirPath is a valid path
@postcondition: dirPath/.checkoutInfo contains complete [Checkout] section
"""
chkoutInfo = ConfigParser()
chkoutInfo.add_section("Checkout")
chkoutInfo.set("Checkout", "checkedoutfrom", coPath)
chkoutInfo.set("Checkout", "checkouttime", timestamp)
chkoutInfo.set("Checkout", "version", version)
chkoutInfo.set("Checkout", "lockedbyme", str(lock))

_writeConfigFile(os.path.join(dirPath, ".checkoutInfo"), chkoutInfo)

def isCheckedOut(dirPath):
nodeInfo = os.path.join(dirPath, ".nodeInfo")
if not os.path.exists(nodeInfo):
return False
cp = ConfigParser()
cp.read(nodeInfo)
return cp.getboolean("Versioning", "locked")

def checkedOutByMe(dirPath):
nodeInfo = os.path.join(dirPath, ".nodeInfo")
if not os.path.exists(nodeInfo):
return False
cp = ConfigParser()
cp.read(nodeInfo)
return cp.get("Versioning", "lastcheckoutuser") == getUsername()

def getFilesCheckoutTime(filePath):
checkoutInfo = os.path.join(filePath, ".checkoutInfo")
#print checkoutInfo
if not os.path.exists(checkoutInfo):
raise Exception("No checkout info available")
cp = ConfigParser()
cp.read(checkoutInfo)
return cp.get("Checkout", "checkouttime")

def canCheckout(coPath):
result = True
if not os.path.exists(os.path.join(coPath, ".nodeInfo")):
result = False
nodeInfo = ConfigParser()
nodeInfo.read(os.path.join(coPath, ".nodeInfo"))
if nodeInfo.get("Versioning", "locked") == "True":
result = False
return result

def getCheckoutDest(coPath):
nodeInfo = ConfigParser()
nodeInfo.read(os.path.join(coPath, ".nodeInfo"))
version = nodeInfo.get("Versioning", "latestversion")
return os.path.join(getUserCheckoutDir(), os.path.basename(os.path.dirname(coPath))+"_"+os.path.basename(coPath)+"_"+("%03d" % int(version)))

def lockedBy(logname):
"""
Returns a tuple containing the logname and the real name
Raises a generic exception if real name cannot be determined.
"""

try: # Throws KeyError exception when the name cannot be found
p = pwd.getpwnam( str(logname) )
except KeyError as ke: # Re-throws KeyError as generic exception
raise Exception( str(ke) )

return p.pw_name, p.pw_gecos # Return lockedBy tuple

def checkout(coPath, lock):
"""
Copies the 'latest version' from the src folder into the local directory
@precondition: coPath is a path to a versioned folder
@precondition: lock is a boolean value
@postcondition: A copy of the 'latest version' will be placed in the local directory
with the name of the versioned folder
@postdondition: If lock == True coPath will be locked until it is released by checkin
"""
#if not os.path.exists(os.path.join(coPath, ".nodeInfo")):
if not isVersionedFolder(coPath):
raise Exception("Not a versioned folder.")

nodeInfo = ConfigParser()
nodeInfo.read(os.path.join(coPath, ".nodeInfo"))
if nodeInfo.get("Versioning", "locked") == "False":
version = nodeInfo.getint("Versioning", "latestversion")
toCopy = os.path.join(coPath, "src", "v"+("%03d" % version))
dest = getCheckoutDest(coPath)

if(os.path.exists(toCopy)):
try:
shutil.copytree(toCopy, dest) # Make the copy
except Exception:
print "asset_mgr_utils, checkout: Could not copy files."
raise Exception("Could not copy files.")
timestamp = time.strftime("%a, %d %b %Y %I:%M:%S %p", time.localtime())
nodeInfo.set("Versioning", "lastcheckoutuser", getUsername())
nodeInfo.set("Versioning", "lastcheckouttime", timestamp)
nodeInfo.set("Versioning", "locked", str(lock))

_writeConfigFile(os.path.join(coPath, ".nodeInfo"), nodeInfo)
_createCheckoutInfoFile(dest, coPath, version, timestamp, lock)
else:
raise Exception("Version doesn't exist "+toCopy)
else:
whoLocked = nodeInfo.get("Versioning", "lastcheckoutuser")
whenLocked = nodeInfo.get("Versioning", "lastcheckouttime")
logname, realname = lockedBy(whoLocked)
whoLocked = 'User Name: ' + logname + '\nReal Name: ' + realname + '\n'
raise Exception("Can not checkout. Folder is locked by:\n\n"+ whoLocked+"\nat "+ whenLocked)
return dest

def unlock(ulPath):

nodeInfo = ConfigParser()
nodeInfo.read(os.path.join(ulPath, ".nodeInfo"))
nodeInfo.set("Versioning", "locked", "False")

toCopy = getCheckoutDest(ulPath)
dirname = os.path.basename(toCopy)
parentPath = os.path.join(os.path.dirname(toCopy), ".unlocked")
if not (os.path.exists(parentPath)):
os.mkdir(parentPath)

os.system('mv -f '+toCopy+' '+parentPath+'/')
_writeConfigFile(os.path.join(ulPath, ".nodeInfo"), nodeInfo)
return 0;

def isLocked(ulPath):
nodeInfo = ConfigParser()
nodeInfo.read(os.path.join(ulPath, ".nodeInfo"))
if nodeInfo.get("Versioning", "locked") == "False":
return False;

return True;
Loading

0 comments on commit 1b946ca

Please sign in to comment.