示例#1
0
文件: ui.py 项目: DominikPott/tasker
 def new_shot(self):
     name, ok = QtWidgets.QInputDialog.getText(self, 'New Shot', 'New Shot:')
     if not(ok and name):
         log.info('No shot name given. Aborted creation!')
         return
     template = self.choose_template(category='shot')
     self._project.new_shot(name=name, template=template)
     self.statusBar().showMessage('Created Shot: {shot_name}'.format(shot_name=name), 5000)
     self.refresh_ui.emit()
示例#2
0
文件: ui.py 项目: DominikPott/tasker
 def new_asset(self):
     asset_name, ok = QtWidgets.QInputDialog.getText(self, 'New Asset', 'New Asset Name:')
     if not(ok and asset_name):
         log.info('No asset name given. Aborted creation!')
         return
     template = self.choose_template(category='asset')
     self._project.new_asset(name=asset_name, template=template)
     self.statusBar().showMessage('Created Asset: {asset_name}'.format(asset_name=asset_name), 5000)
     self.refresh_ui.emit()
示例#3
0
    def _update_self(self, session):
        task_data = session.query(TaskData).filter(
            TaskData.id == self.id).first()
        if not task_data.dependencies:  # No previous task so set state to can_start
            if task_data.state == State.pending:
                task_data.state = State.can_start
                log.info("Starting no dependencie task {task}".format(
                    task=self.name))

        if any(dependencie.state == State.reject
               for dependencie in task_data.dependencies):
            log.info("Locking %s for parent reject" % self.name)
            task_data.state = State.hold
            return

        # all previews task done, start self
        if all(dependencie.state == State.done
               for dependencie in task_data.dependencies):
            # if already worked on shot, set to update
            if task_data.state == State.hold:
                task_data.state = State.to_continue
                log.info("To continue task %s" % self.name)
                return
            if task_data.state != State.pending:
                return
            log.info("Starting task %s" % self.name)
            task_data.state = State.can_start
示例#4
0
    def state(self, state):
        """Change the state of this task.

        Args:
            state (str): name of the state to set this tasks state to.

        """
        with session_scope() as session:
            task_data = session.query(TaskData).filter(
                TaskData.id == self.id).first()
            log.info('{task} set to {state}'.format(task=self.name,
                                                    state=state))
            task_data.state = state
            self._update_self(session=session)
            self.update_depender(session=session)
示例#5
0
def new_user(name):
    """Creates a new user in the databse.
    Creates a new user with the given name in the database. If a user with this name exists already creation is skipped.
    Args:
        name (str): name of the new user.

    """
    user = UserData(name=name)
    with session_scope() as session:
        exists = session.query(UserData).filter_by(name=name).first()
        if exists:
            log.warning('User already exists. Skipping creation.')
            return
        log.info('Created new User {name}'.format(name=name))
        session.add(user)
示例#6
0
def new_project(name):
    """Creates a new project with the given name.

    Create a project to hold tasks, assets and shots.
    Args:
        name (str): name of the new project
    """
    project = ProjectData(name=name)
    with session_scope() as session:
        exists = session.query(ProjectData).filter_by(name=name).first()
        if exists:
            log.warning('Project already exists. Skipping creation.')
            return None
        log.info('Creating new Project {name}'.format(name=name))
        session.add(project)
示例#7
0
    def new_asset(self, name, template):
        """ Creates a new asset with the given name in the project.
        The new shot will use the provided template to generate tasks and dependenciesfor itself.

        Args:
            name (str): name of the new asset. Aborts if an asset with this name already exists.
            template (dict): A configuration file to generate tasks and dependencies for the new asset from.
        """
        log.info('New Asset {name}'.format(name=name))
        asset = AssetData(name=name,
                          tasks=tasks_from_template(template=template))
        with session_scope() as session:
            project = session.query(ProjectData).filter(
                ProjectData.id == self.id).first()
            project.assets.append(asset)
示例#8
0
def tasks_from_template(template):
    """Converts a template to a list of tasks.

    Args:
        template (dict): A configuration file to generate tasks and dependencies for the new asset from.

    Returns:
        list(Task): tasks defined by the given template.
    """
    tasks = []
    for task_name in template['tasks']:
        tasks.append(TaskData(name=task_name, state=State.can_start))
    for task in tasks:
        log.info('Tasks {task}'.format(task=task.name))
        dependencies = []
        for dependency in template['dependencies'][task.name]:
            dependencies.extend([t for t in tasks if t.name == dependency])
        log.info(
            'Dependencies: {d}'.format(d=[dep.name for dep in dependencies]))
        task.dependencies = dependencies
        if dependencies:
            task.state = State.pending
    return tasks