コード例 #1
0
ファイル: main.py プロジェクト: Orishas/CouchPotatoServer
    def fill(self):

        try:
            db = get_session()

            order = 0
            for q in self.qualities:

                # Create quality
                qual = db.query(Quality).filter_by(identifier = q.get('identifier')).first()

                if not qual:
                    log.info('Creating quality: %s', q.get('label'))
                    qual = Quality()
                    qual.order = order
                    qual.identifier = q.get('identifier')
                    qual.label = toUnicode(q.get('label'))
                    qual.size_min, qual.size_max = q.get('size')

                    db.add(qual)

                # Create single quality profile
                prof = db.query(Profile).filter(
                    Profile.core == True
                ).filter(
                    Profile.types.any(quality = qual)
                ).all()

                if not prof:
                    log.info('Creating profile: %s', q.get('label'))
                    prof = Profile(
                        core = True,
                        label = toUnicode(qual.label),
                        order = order
                    )
                    db.add(prof)

                    profile_type = ProfileType(
                        quality = qual,
                        profile = prof,
                        finish = True,
                        order = 0
                    )
                    prof.types.append(profile_type)

                order += 1

            db.commit()

            time.sleep(0.3) # Wait a moment

            return True
        except:
            log.error('Failed: %s', traceback.format_exc())
            db.rollback()
        finally:
            db.close()

        return False
コード例 #2
0
ファイル: main.py プロジェクト: Akylas/CouchPotatoServer
    def fill(self):

        db = get_session();

        order = 0
        for q in self.qualities:

            # Create quality
            quality = db.query(Quality).filter_by(identifier = q.get('identifier')).first()

            if not quality:
                log.info('Creating quality: %s', q.get('label'))
                quality = Quality()
                db.add(quality)

            quality.order = order
            quality.identifier = q.get('identifier')
            quality.label = toUnicode(q.get('label'))
            quality.size_min, quality.size_max = q.get('size')

            # Create single quality profile
            profile = db.query(Profile).filter(
                    Profile.core == True
                ).filter(
                    Profile.types.any(quality = quality)
                ).all()

            if not profile:
                log.info('Creating profile: %s', q.get('label'))
                profile = Profile(
                    core = True,
                    label = toUnicode(quality.label),
                    order = order
                )
                db.add(profile)

                profile_type = ProfileType(
                    quality = quality,
                    profile = profile,
                    finish = True,
                    order = 0
                )
                profile.types.append(profile_type)

            order += 1
            db.commit()

        #db.close()
        return True
コード例 #3
0
ファイル: main.py プロジェクト: n3sarthin/CouchPotatoServer
    def fill(self):

        db = get_session()

        order = 0
        for q in self.qualities:

            # Create quality
            qual = db.query(Quality).filter_by(identifier=q.get("identifier")).first()

            if not qual:
                log.info("Creating quality: %s", q.get("label"))
                qual = Quality()
                qual.order = order
                qual.identifier = q.get("identifier")
                qual.label = toUnicode(q.get("label"))
                qual.size_min, qual.size_max = q.get("size")

                db.add(qual)

            # Create single quality profile
            prof = db.query(Profile).filter(Profile.core == True).filter(Profile.types.any(quality=qual)).all()

            if not prof:
                log.info("Creating profile: %s", q.get("label"))
                prof = Profile(core=True, label=toUnicode(qual.label), order=order)
                db.add(prof)

                profile_type = ProfileType(quality=qual, profile=prof, finish=True, order=0)
                prof.types.append(profile_type)

            order += 1

        db.commit()

        time.sleep(0.3)  # Wait a moment

        return True
コード例 #4
0
    def fill(self):

        try:
            db = get_session()

            order = 0
            for q in self.qualities:

                # Create quality
                qual = db.query(Quality).filter_by(
                    identifier=q.get('identifier')).first()

                if not qual:
                    log.info('Creating quality: %s', q.get('label'))
                    qual = Quality()
                    qual.order = order
                    qual.identifier = q.get('identifier')
                    qual.label = toUnicode(q.get('label'))
                    qual.size_min, qual.size_max = q.get('size')

                    db.add(qual)

                # Create single quality profile
                prof = db.query(Profile).filter(Profile.core == True).filter(
                    Profile.types.any(quality=qual)).all()

                if not prof:
                    log.info('Creating profile: %s', q.get('label'))
                    prof = Profile(core=True,
                                   label=toUnicode(qual.label),
                                   order=order)
                    db.add(prof)

                    profile_type = ProfileType(quality=qual,
                                               profile=prof,
                                               finish=True,
                                               order=0)
                    prof.types.append(profile_type)

                order += 1

            db.commit()

            time.sleep(0.3)  # Wait a moment

            return True
        except:
            log.error('Failed: %s', traceback.format_exc())
            db.rollback()
        finally:
            db.close()

        return False
コード例 #5
0
ファイル: main.py プロジェクト: Xice/CouchPotato
    def fill(self):

        db = get_session();

        order = 0
        for q in self.qualities:

            # Create quality
            quality = db.query(Quality).filter_by(identifier = q.get('identifier')).first()

            if not quality:
                log.info('Creating quality: %s' % q.get('label'))
                quality = Quality()
                db.add(quality)

            quality.order = order
            quality.identifier = q.get('identifier')
            quality.label = q.get('label')
            quality.size_min, quality.size_max = q.get('size')

            # Create single quality profile
            profile = db.query(Profile).filter(
                    Profile.core == True
                ).filter(
                    Profile.types.any(quality = quality)
                ).all()

            if not profile:
                log.info('Creating profile: %s' % q.get('label'))
                profile = Profile(
                    core = True,
                    label = toUnicode(quality.label),
                    order = order
                )
                db.add(profile)

                profile_type = ProfileType(
                    quality = quality,
                    profile = profile,
                    finish = True,
                    order = 0
                )
                profile.types.append(profile_type)

            order += 1
            db.commit()

        return True