Skip to content

Commit

Permalink
some sort of UI or info of who worked on a hip file #1154
Browse files Browse the repository at this point in the history
  • Loading branch information
johnnyquest committed Nov 12, 2020
1 parent 860b450 commit 5743cbd
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 0 deletions.
9 changes: 9 additions & 0 deletions MainMenuMaster.xml
Expand Up @@ -213,6 +213,15 @@ hou.hscript("menurefresh")]]>

<!-- this should be added to the regular Houdini prefs submenu once it's finished -->

<scriptItem id="h.ql_hip_stats">
<label>Current Hip File Stats...</label>
<scriptCode><![CDATA[
import qlibutils
qlibutils.show_hip_stats(kwargs)
]]>
</scriptCode>
</scriptItem>

<scriptItem id="h.ql_prefs_window">
<label>Preferences...</label>
<scriptCode><![CDATA[
Expand Down
72 changes: 72 additions & 0 deletions scripts/python/qlibutils.py
Expand Up @@ -8,13 +8,15 @@

import hou

import collections
import datetime
import glob
import os
import sys
import re
import subprocess
import traceback
from operator import itemgetter

# for paste_clipboard_to_netview()
from hutil import Qt
Expand Down Expand Up @@ -1024,3 +1026,73 @@ def clear_caches(kwargs=None, caches="all"):
print " - result: %s" % str(r[0])



def show_hip_stats(kwargs):
"""Displays some hip file statistics.
"""
R = []
A = R.append
hipfile = hou.hipFile.path()

A("HIP file: %s\n" % hipfile)

if os.path.exists(hipfile):
cre = os.path.getctime(hipfile)
mod = os.path.getmtime(hipfile)
acc = os.path.getatime(hipfile)
size = os.path.getsize(hipfile)

A("Last accessed: %s" % date_string(acc))
A("Modified time: %s" % date_string(mod))
A("Creation time: %s" % date_string(cre))
A("File Size: %s (%d bytes)" % (sizeof_fmt(size), size, ) )
else:
A("(file doesn't exist)")


nodes = hou.node("/").allSubChildren(recurse_in_locked_nodes=True)
# NOTE: this filter could be improved?
nodes = [ c for c in nodes if c.isEditable() and not c.isInsideLockedHDA() ]

A("\nContains %d editable nodes." % len(nodes))

# ( path, cre, mod, author, )
nodes = [ (n.path(), n.creationTime(), n.modificationTime(), get_node_author(n), ) for n in nodes ]

# { "author":node_count, }
authors_nc = collections.Counter([ n[3] for n in nodes ])

A("\nAuthors:")
for a in sorted(authors_nc):
A(" - %s (%d nodes)" % (a, authors_nc[a], ))

nodes = sorted(nodes, key=itemgetter(2), reverse=True)
A("\nLatest Modified:")
for n in nodes[:6]:
A(" %s %s (%s)" % (date_string(n[2]), n[0], n[3], ) )

nodes = sorted(nodes, key=itemgetter(1), reverse=True)
A("Latest Created:")
for n in nodes[:6]:
A(" %s %s (%s)" % (date_string(n[2]), n[0], n[3], ) )

nodes = sorted(nodes, key=itemgetter(1), reverse=False)
A("\nOldest Modified:")
for n in nodes[:6]:
A(" %s %s (%s)" % (date_string(n[2]), n[0], n[3], ) )

nodes = sorted(nodes, key=itemgetter(2), reverse=False)
A("Oldest Created:")
for n in nodes[:6]:
A(" %s %s (%s)" % (date_string(n[2]), n[0], n[3], ) )

R = "\n".join(R)

print(R)

hou.ui.displayMessage(
"Current Hip File Statistics",
details = R,
details_expanded=True)


0 comments on commit 5743cbd

Please sign in to comment.