def __prepare(run_id): report_path = __report_path(run_id) try: paths.mkdir_p(report_path) os.mkdir(report_path + "/runtime") os.mkdir(report_path + "/complete") os.mkdir(__run_path(run_id)) except: pass # print "Path exists: " + report_path __create_report_files(report_path)
def __prepare(program_run_id): report_path = __report_path(program_run_id) try: paths.mkdir_p(report_path) except: pass # print "Path exists: " + report_path try: os.mkdir(report_path + "/complete") except: pass # print "Path exists: " + report_path
def checkout_nuke_write_render_before(fileIO, filePath, forceSave=consts.FORCE_SAVE): """ Standard implementation of writing files. Originally built for Nuke but later implements Exceptions in order to make the function agnostic. In every implementation of each software, this function is wrapped in a try/except block which, upon exception, will then handle the issue of blocking or allowing saves. This was an alternative to subclassing out and maintaining separate classes for each application. For a full list of the checks that this function undergoes, see :ref:`fileio#checks_to_allow_access` Examples --------------------------------------------------------------------------- The function is used in mayamanager :ref:`mayamanager`, nukemanager :ref:`nukemanager`, and houdinimanager :ref:`houmanager` .. Note:: This has been largely deprecated because, instead of using subclasses PASsed directly into the function, this function remains generic and simply uses exceptions to escape the script mid-execution when a file is allowed/disallowed access permissions. These exceptions are built directly in to one of the base classes from within fileio. For more information, see: the fileio.controller.checkout module :ref:`fileio`, and the fileio.controller.globerror module for the list of exceptions :ref:`exceptions` Args: fileIO (<FileIO object>): fileIO base object (and be any class as long as it inherits from FileIO) filePath (str): The full path to a file location. This location is where read/write access permission is determined forceSave (bool): Ignores the entire save method and lets the user save .. note:: Using this method does NOT lock the file during save, and is thus unsafe Returns: <IOValidationError or IOValidationPassedError> Technically nothing but will almost always raise some sort of error for exception handling """ # Null - replace later # fileToSave = r"C:\Users\korinkite\Dropbox\Private\my_PROJECT\proj_POP2\Pipeline\the_LATEST_pre_maya_open_close_edits_0001\sys_PY\py_MODULES\fileio\test\test_nuke_project\output\s001_ckenne24_010_MODEL_someDescription.0001.ma" fileToSave = filePath # ::TO DO:: "fileToSave" is redundant. search/replace all in this function to "filePath" LOGGER.info(['AIE1601'], {'file': fileToSave}) global GLOB_ERROR_MSG fileIO = fileIO(fileToSave) # fileIO.allow_save = True # by default, let the user save # if consts.USERNAME == "kerfuffle": # LOGGER.info("FILECHECKOUT: Got the value of true and is going to throw the pass error") # LOGGER.info("ALLOW SAVE WILL SOON BE TRUE") # fileIO.allow_save = True if forceSave == True: fileIO.allow_save = True # exit the script and set the save status if not fileIO.is_registered: LOGGER.warning(['AIE7700', 'match_false'], {'user': getpass.getuser(), 'proj': consts.PROJECT_NAME_LONG}) fileIO.error_msg = "You are not currently registered on the project\n\n"\ "Please contact admin {admins} to get "\ "started!".format(admins=consts.ADMIN_CONTACT_INFO) fileIO.allow_save = False networkManager = NetworkManager() networkManager.file = fileToSave # DEPRECATED - I'm placing this in the consts file, instead # if not networkManager.is_allowed_application(): # LOGGER.warning(['6900', 'match_false'], {'app': os.environ['APP_EXECUTABLE'], 'proj': consts.PROJECT_NAME_LONG}) # fileIO.allow_save = False if networkManager.is_local(): LOGGER.info(['AIE1200']) LOGGER.info(['AIE1201']) fileIO.allow_save = True elif networkManager.is_remote(): # ::TO DO:: You will need to add a FTP protocol here. Or change some variable here # to be used in a future method later LOGGER.critical(['AIE1201']) msg = "Remote access is disabled. Must be on SCAD network in order to work" GLOB_ERROR_MSG = msg fileIO.error_msg = msg LOGGER.error(['AIE7201', 'match_false'], {'ip': socket.gethostbyname(socket.gethostname())}) fileIO.allow_save = False if not networkManager.has_access(): LOGGER.warning(["AIE5601", 'match_false'], {'file': fileIO.fullPath}) contactInfo = networkManager.read_contact_info_from_locked_file() isContInfoMissing = networkManager.is_incomplete_read_contact_info(contactInfo) if isContInfoMissing: msg = "Attempted to get contact info from:\n\n{loc}\n\nbut the user "\ "has bad credentials.\n\nSave this: {dict}\n\n"\ "Please notify admin\n\n{bug}".format(loc=fileToSave, dict=contactInfo, bug=consts.BUG_REPORT_PAGE) else: msg = "Save Location:\n\n{loc}\n\nis lacking permissions for "\ "current account.\nThe current owner of the file is\n"\ "username: {username}\n\n"\ "name: {name}\n\n"\ "ip: {ip}\n"\ "room number: {roomnumber}\n"\ "machine: {machinenumber}\n"\ "time locked: {time}\n"\ "date locked: {date}\n"\ "e-mail: {email}\n"\ "phone number: {phonenumber}\n\n"\ "IMPORTANT: IF THIS IS YOU - Please send a bug report "\ "to the admin immediately.\n\n{bug}\n\nIf it isn't you and "\ "you're in the computer labs, their room number is above. "\ "Otherwise, you can just call them, "\ "too.".format(loc=fileToSave, name=contactInfo["USERFULLNAME"], username=contactInfo["USERNAME"], ip=contactInfo["IP"], roomnumber=contactInfo['ROOM'], machinenumber=contactInfo["MACHINE"], time=contactInfo["TIME"], date=contactInfo["DATE"], email=contactInfo['EMAIL'], phonenumber=contactInfo["PHONENUMBER"], bug=consts.BUG_REPORT_PAGE) GLOB_ERROR_MSG = msg fileIO.error_msg = msg LOGGER.error(['AIE9002', 'match_false'], {'file': fileToSave}) LOGGER.error(msg) fileIO.allow_save = False if fileIO.check_naming_convention(regex=consts.RE_FILENAME_MATCH) is None: LOGGER.warning(["AIE6601", 'match_false'], {'f':fileIO.fullPath, 'convention': consts.MATCH_RE}) for name in consts.FILE_CONVENTION_EXAMPLE['Nuke']: LOGGER.info(['AIE5605'], {'name': name}) msg = "File: {f} does not match any possible naming "\ "conventions".format(f=fileToSave) GLOB_ERROR_MSG = msg fileIO.error_msg = msg fileIO.allow_save = False if fileIO.is_character_limit(): LOGGER.warning(['AIE6500'], {'path': fileIO.fullPath, 'limit': fileIO._sys_character_limit}) msg = "Path: \"{path}\" exceeds character limit \"{limit}\". Please shorten your file", msg = msg.format(path=FileIO.fullPath, limit=FileIO._sys_character_limit) GLOB_ERROR_MSG = msg fileIO.error_msg = msg fileIO.allow_save = False if fileIO.is_farm_character_limit(): LOGGER.warning(['AIE6500'], {'path': fileIO.fullPath, 'limit': fileIO._farm_character_limit}) msg = "Path: \"{path}\" exceeds character limit \"{limit}\". Please shorten your file", msg = msg.format(path=FileIO.fullPath, limit=FileIO._farm_character_limit) GLOB_ERROR_MSG = msg fileIO.error_msg = msg fileIO.allow_save = False if not fileIO.allow_save: # just in case for some reason the script failed to exit, one last check GLOB_ERROR_MSG = msg LOGGER.warning(['AIE9700'], {"file": fileToSave}) fileIO.set_save = False # File survived all check conditions # Lock the file in preparation for saving if it is not already # (if it is already, we presume it's because they're an admin) # (or they are the user that locked it) # if not networkManager.is_locked: LOGGER.info('fileToSave' + str(fileToSave)) # create the nested folder structure for the file folderToSaveInto = os.path.dirname(fileToSave) if not os.path.isdir(folderToSaveInto): if networkManager.is_local(): LOGGER.info(['AIE5606', 'match_false'], {'folder': folderToSaveInto}) else: LOGGER.info(['NET5606', 'match_false'], {'folder': folderToSaveInto}) paths.mkdir_p(folderToSaveInto) networkManager.locked = True # lock the file from external editting lockedUserInfo = networkManager.collect_contact_info() LOGGER.info(['AIE1202'], {"full_name": lockedUserInfo['USERFULLNAME'], "user": lockedUserInfo['USERNAME'], "ip": lockedUserInfo['IP'], "machine": lockedUserInfo['MACHINE'], "email": lockedUserInfo['EMAIL'], "phone": lockedUserInfo['PHONENUMBER']}) LOGGER.info(['AIE1203'], {"f": fileToSave}) fileIO.allow_save = True # exit the script and set the save status