コード例 #1
0
ファイル: views.py プロジェクト: naumushv/klever
 def post(self, request):
     data = json.loads(request.data['data'])
     messages = []
     if 'preset-jobs' in data:
         PopulatePresets().populate()
         messages.append('Preset jobs were populated!')
     if 'schedulers' in data:
         populuate_schedulers()
         messages.append('Schedulers were populated!')
     if 'safe-tags' in data:
         res = PopulateSafeTags()
         messages.append("{} of {} safe tags were populated".format(res.created, res.total))
     if 'unsafe-tags' in data:
         res = PopulateUnsafeTags()
         messages.append("{} of {} unsafe tags were populated".format(res.created, res.total))
     if 'safe-marks' in data:
         res = PopulateSafeMarks()
         messages.append("{} of {} safe marks were populated".format(res.created, res.total))
     if 'unsafe-marks' in data:
         res = PopulateUnsafeMarks()
         messages.append("{} of {} unsafe marks were populated".format(res.created, res.total))
     if 'unknown-marks' in data:
         res = PopulateUnknownMarks()
         messages.append("{} of {} unknown marks were populated".format(res.created, res.total))
     return Response({'messages': messages})
コード例 #2
0
ファイル: populate.py プロジェクト: ldv-klever/klever
    def handle(self, *args, **options):
        # Preset jobs
        if options['all'] or options['presets']:
            self.stdout.write('Preset jobs population started')
            try:
                PopulatePresets().populate()
            except Exception as e:
                logger.exception(e)
                raise CommandError('Preset jobs population failed: %s' % e)
            self.stdout.write("Preset jobs were populated")

        # Tags
        if options['all'] or options['tags']:
            self.stdout.write('Tags population started')
            try:
                created, total = populate_tags()
            except Exception as e:
                logger.exception(e)
                raise CommandError('Tags population failed: %s' % e)
            self.stdout.write("{} of {} tags were populated".format(
                created, total))

        # Safe marks
        if options['all'] or options['marks'] or options['marks_s']:
            self.stdout.write('Safe marks population started')
            try:
                res = PopulateSafeMarks()
            except Exception as e:
                logger.exception(e)
                raise CommandError('Safe marks population failed: %s' % e)
            self.stdout.write("{} of {} safe marks were populated".format(
                res.created, res.total))

        # Unsafe marks
        if options['all'] or options['marks'] or options['marks_u']:
            self.stdout.write('Unsafe marks population started')
            try:
                res = PopulateUnsafeMarks()
            except Exception as e:
                logger.exception(e)
                raise CommandError('Unsafe marks population failed: %s' % e)
            self.stdout.write("{} of {} unsafe marks were populated".format(
                res.created, res.total))

        # Unknown marks
        if options['all'] or options['marks'] or options['marks_f']:
            self.stdout.write('Unknown marks population started')
            try:
                res = PopulateUnknownMarks()
            except Exception as e:
                logger.exception(e)
                raise CommandError('Unknown marks population failed: %s' % e)
            self.stdout.write("{} of {} unknown marks were populated".format(
                res.created, res.total))

        # Schedulers
        if options['all'] or options['schedulers']:
            populuate_schedulers()
            self.stdout.write('Schedulers were populated!')

        self.stdout.write('Population was successfully finished!')