def addHandler(self, logger): mode = pymel.confirmBox("Logging","Handler Type:", "File", "Script Editor", "Console", "Log Server", "Cancel") if mode=="Cancel": return elif mode=="File": f = pymel.fileDialog(mode=1, dm="Log File: *.log") if not f: return handler = logging.FileHandler(f) elif mode=="Script Editor": handler = logging.StreamHandler() elif mode=="Console": handler = logging.StreamHandler(sys.__stderr__) elif mode=="Log Server": from logServer import SocketHandler, kHostName server = pymel.promptBox("Logging","Log Server Address:", "Connect", "Cancel", tx="%s:%s" % (kHostName, logging.handlers.DEFAULT_TCP_LOGGING_PORT)) host, sep, port = server.partition(":") handler = SocketHandler(host, int(port)) level = pymel.confirmBox("Logging","Log Level:", *logLevelNames) if not level: return handler.setLevel(levelsDict[level]) handler.setFormatter(logging.Formatter(logging.BASIC_FORMAT)) logger.addHandler(handler) logger.info("Added %s-Handler to Logger '%s' at level %s" % (mode, logger.name, level))
def setAttrFromFileDialog(obj, attrname): # get the relative path to project mutil = mpu.MayaProjUtils() projpath = mutil.getProjPath() rpath = projpath # rpath = os.path.join(projpath, 'renderman') text = pm.fileDialog() path = os.path.relpath(text, rpath) path = crutils.normalizePath(path) obj.setAttr(attrname, path)
def setTextBoxText(tb): tb.text = pm.fileDialog() tb.insertText(tb.text)