Exemplo n.º 1
0
    def put(self, id, project_id=None):
        """put."""
        result = DB_SESSION.query(Result).filter_by(id=id).first()
        if result is None:
            response = jsonify({
                'result': None,
                'message': 'No interface defined for URL.'
            })
            return response, 404

        request_json = request.get_json()
        request_result = request_json.get('result')

        name = request_result.get('name', None)
        if name is not None:
            result.name = name

        is_unregistered = request_result.get('isUnregistered', None)
        if is_unregistered is not None:
            result.is_unregistered = is_unregistered

        DB_SESSION.add(result)
        DB_SESSION.commit()

        return jsonify({'result': result.serialize})
Exemplo n.º 2
0
    def create(cls, result_id=None, summary=None, file_modified_at=None):
        """Initialize an instance and save it to db."""
        asset = cls(result_id, summary, file_modified_at)

        DB_SESSION.add(asset)
        DB_SESSION.commit()

        return asset
Exemplo n.º 3
0
    def create(cls, path_name=None, name=None):
        """initialize an instance and save it to db."""

        project = cls(path_name, name)

        DB_SESSION.add(project)
        DB_SESSION.commit()

        collect_results(project, force=True)
Exemplo n.º 4
0
    def create(cls,
               path_name=None,
               name=None,
               project_id=None,
               log_modified_at=None):
        """Initialize an instance and save it to db."""
        result = cls(path_name, name, project_id, log_modified_at)

        DB_SESSION.add(result)
        DB_SESSION.commit()

        crawl_result(result, True)

        return result
Exemplo n.º 5
0
def _register_result(project_id, result_path):
    from chainerui import DB_SESSION
    from chainerui.models.result import Result

    result_path = os.path.abspath(result_path)

    contain_log_file = os.path.isfile(os.path.join(result_path, 'log'))

    if not contain_log_file:
        return False

    result_size = DB_SESSION.query(Result).filter_by(
        path_name=result_path
    ).count()

    if result_size is 0:
        new_result = Result(project_id=project_id, path_name=result_path)
        DB_SESSION.add(new_result)
        DB_SESSION.commit()
Exemplo n.º 6
0
    def put(self, id):
        """put."""

        project = DB_SESSION.query(Project).filter_by(id=id).first()

        if project is None:
            return jsonify({
                'project': None,
                'message': 'No interface defined for URL.'
            }), 404

        request_project = request.get_json().get('project')
        project_name = request_project.get('name', None)

        if project_name is not None:
            project.name = project_name

        DB_SESSION.add(project)
        DB_SESSION.commit()

        return jsonify({'project': project.serialize})