Esempio n. 1
0
def confirm_requirements_exist():
    """
    Confirm that the directories required for Mimic to run do, in fact, exist.
    Confirm that the rigs directory contains something. Confirm that files, such
    as LICENSE and mimic.mod, exist.
    :return:
    """
    # Check required directories
    requirements = [
        'rigs',
        'plug-ins',
        'shelves',
        'scripts',
        'docs/LICENSE.md',
        'mimic.mod',
    ]
    dir_mimic = general_utils.get_mimic_dir()
    for requirement in requirements:
        if '.mod' in requirement:  # not a directory (.md, .mod)
            parent = os.path.abspath(os.path.join(dir_mimic, os.pardir))
            path = '{}/{}'.format(parent, requirement)
        else:
            path = '{}/{}'.format(dir_mimic, requirement)
        try:  # Check that directories all exist
            assert os.path.exists(path)
        except AssertionError:
            if 'LICENSE.md' in path:  # Missing license!
                warning = 'Exception: We noticed that you don\'t have a copy of our LICENSE! ' \
                          'It needs to be in your maya/modules directory at all times! ' \
                          'Download the latest release or clone our GitHub repository!'
                raise Exception(warning)
            else:
                warning = 'Exception: We noticed that you\'re missing the requirement: {}! ' \
                          'Download the latest release or clone our GitHub repository! ' \
                    .format(requirement)
                raise Exception(warning)
        except UnicodeError:
            warning = 'Exception: Sorry! You\'ve encountered a known, but unsolved issue! ' \
                      'The path to the Mimic directory contains unicode characters, which ' \
                      'are sometimes found in usernames, and Mimic gets confused. We\'re ' \
                      'working on this and you\'re welcome to help!'
            raise Exception(warning)
        try:  # Check that the rigs directory has robots
            if requirement == 'rigs':
                items = os.listdir(path)
                subdir_paths = [os.path.join(path, item) for item in items]
                assert any(os.path.isdir(subdir_path) for subdir_path in subdir_paths)
                for subdir_path in subdir_paths:
                    try:
                        items = os.listdir(subdir_path)
                        assert any('.ma' in item for item in items)
                        continue
                    except OSError:  # not a directory (.md)
                        pass
        except AssertionError:
            # Don't block Mimic from running
            warning = 'Warning: We noticed that you don\'t have any robot rigs! ' \
                      'Download the latest rigs from out GitHub repository ' \
                      'and add them to mimic/rigs!'
            raise Exception(warning)
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        """
        """
        super(Toggle, self).__init__(*args, **kwargs)

        # Get the custom button icons from Mimic
        # This is currently dependent on Mimic, but can changed if Analysis
        # module is decoupled from Mimic
        icon_directory = general_utils.get_mimic_dir()
        self.toggle_off_path = icon_directory + '/icons/toggle_button_off.png'
        self.toggle_on_path = icon_directory + '/icons/toggle_button_on.png'

        # Define QPushButton parameters
        self.setCheckable(True)
        self.setChecked(False)

        self.setFixedWidth(26)
        self.setFixedHeight(19)

        # Set styleSheet such that toggle_button_on.png is used if button is
        # checked, and toggle_button_off.png is used if button is unchecked
        self.setStyleSheet('QPushButton {background-image: url('
                                       + self.toggle_off_path + '); ' \
                                        'border: none; ' \
                                        'background-repeat: no-repeat;}'
                         + 'QPushButton:checked {background-image: url('
                                       + self.toggle_on_path + '); ' \
                                        'border: none; '\
                                        'background-repeat: no-repeat;}')
        self.setFlat(False)
Esempio n. 3
0
def add_robot(*args):
    """
    """
    # Get required rigs directories
    dir_mimic = general_utils.get_mimic_dir()
    dir_rigs = dir_mimic + '/rigs'

    mimic_utils.import_robot(dir_rigs)
    mimic_utils.add_hud_script_node()
    mimic_utils.add_mimic_script_node()
Esempio n. 4
0
 def _get_program_directory(self, directory=None):
     """
     Constructs and returns the program template/output directory. If a directory
     is provided and is valid, this function passes it directly out, otherwise it
     uses the default directory instead, coinciding with the type of robot and type
     of processor being used.
     :param directory: Optional, user-defined directory.
     :return:
     """
     try:
         assert os.path.isdir(directory)
     except (TypeError, AssertionError):
         mimic_dir = general_utils.get_mimic_dir()  # dependent on Maya
         template = '{}/scripts/postproc/{}/{}'
         directory = template.format(mimic_dir, self.type_robot,
                                     self.type_processor)
     return directory
Esempio n. 5
0
def _build_add_robot_frame(parent_layout):
    # Create frame layout with one column
    add_robot_frame = pm.frameLayout(label="Add Robot", collapsable=True)
    add_robot_col = pm.columnLayout(adj=True, columnAttach=('both', 5))
    pm.separator(height=5, style='none')

    # Create list of robots
    pm.rowLayout(numberOfColumns=2,
                 adjustableColumn=1,
                 columnAttach=(1, 'left', 3),
                 columnWidth=[(1, 158), (2, 45)],
                 height=20)

    pm.optionMenu('robotImportList')

    rigs = general_utils.get_rigs_dict()
    rig_names = general_utils.get_rigs_names(rigs)
    for rig_name in rig_names:
        pm.menuItem(label=rig_name)

    # Get required rigs directories
    dir_mimic = general_utils.get_mimic_dir()
    dir_rigs = dir_mimic + '/rigs'
    add_robot_command_string = \
        'import mimic_utils; reload(mimic_utils); ' \
        'mimic_utils.import_robot("{}"); ' \
        'mimic_utils.add_mimic_script_node(); ' \
        'mimic_utils.add_hud_script_node()' \
            .format(dir_rigs)

    pm.button(label=' Add ',
              command=add_robot_command_string,
              width=45,
              height=20,
              annotation='Imports selected robot into the scene')

    pm.setParent(add_robot_frame)

    pm.separator(style='none')
    pm.setParent(parent_layout)