Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion release/scripts/mgear/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
"""Utilitie functions"""
"""Utility functions"""


import os
import sys
import timeit
from functools import wraps
import datetime
import getpass

from maya import cmds
import mgear.pymaya as pm
Expand Down Expand Up @@ -441,3 +443,17 @@ def get_maya_path():
maya_path = os.environ['MAYA_LOCATION']
maya_path = os.path.normpath(os.path.join(maya_path,"bin"))
return maya_path


def get_user_metadata():
"""
:return: User metadata including username, date, Maya version, and mGear version.
:rtype: dict[str, str]
"""
data = {
"user": getpass.getuser(),
"date": str(datetime.datetime.now()),
"maya_version": str(mel.eval("getApplicationVersionAsFloat")),
"gear_version": mgear.getVersion(),
}
return data
19 changes: 11 additions & 8 deletions release/scripts/mgear/shifter/guide.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Built-in
import datetime
import getpass
import json
import os
import sys
Expand Down Expand Up @@ -628,17 +627,17 @@ def addParameters(self):
# --------------------------------------------------
# Comments
self.pComments = self.addParam("comments", "string", "")
self.pUser = self.addParam("user", "string", getpass.getuser())
self.pDate = self.addParam(
"date", "string", str(datetime.datetime.now())
)

user_metadata = utils.get_user_metadata()
self.pUser = self.addParam("user", "string", user_metadata["user"])
self.pDate = self.addParam("date", "string", user_metadata["date"])
self.pMayaVersion = self.addParam(
"maya_version",
"string",
str(pm.mel.eval("getApplicationVersionAsFloat")),
user_metadata["maya_version"],
)
self.pGearVersion = self.addParam(
"gear_version", "string", mgear.getVersion()
"gear_version", "string", user_metadata["gear_version"]
)

# --------------------------------------------------
Expand Down Expand Up @@ -1073,6 +1072,11 @@ def get_guide_template_dict(self, meta=None):

return self.guide_template_dict

def refresh_user_metadata(self):
for k, v in utils.get_user_metadata().items():
attr = self.model.attr(k)
attr.set(v)

def addOptionsValues(self):
"""Gather or change some options values according to some others.

Expand Down Expand Up @@ -3810,7 +3814,6 @@ def data_collector_pathEmbbeded(self, *args):
)



# Backwards compatibility aliases
MainGuide = Main
RigGuide = Rig
Expand Down
13 changes: 9 additions & 4 deletions release/scripts/mgear/shifter/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,19 @@ def _get_file(write=False):


def export_guide_template(filePath=None, meta=None, conf=None, *args):
"""Export the guide templata to a file
"""Export the guide template to a file.

Args:
filePath (str, optional): Path to save the file
meta (dict, optional): Arbitraty metadata dictionary. This can
be use to store any custom information in a dictionary format.
filePath (str, optional): Path to save the file.
meta (dict, optional): Arbitrary metadata dictionary. This can
be used to store any custom information in a dictionary format.
"""
if not conf:
selection = pm.selected()
if selection:
rig = shifter.Rig()
rig.guide.setFromHierarchy(selection[0])
rig.guide.refresh_user_metadata()
conf = get_template_from_selection(meta)
if conf:
data_string = json.dumps(conf, indent=4, sort_keys=True)
Expand Down
Loading