Esempio n. 1
0
    def get_context_data(self, **kwargs):
        if not self.request.user.can_create_jobs:
            raise BridgeException(code=407)
        preset_job = get_object_or_404(
            PresetJob.objects.exclude(type=PRESET_JOB_TYPE[0][0]),
            pk=self.kwargs['preset_id'])

        if settings.DEBUG:
            # Populate preset job first
            preset_population = PopulatePresets()
            if preset_job.type == PRESET_JOB_TYPE[2][0]:
                preset_population.populate_preset(preset_job.parent)
            else:
                if preset_population.populate_preset(preset_job):
                    # Reload preset job from DB if it has changed
                    preset_job = PresetJob.objects.get(id=preset_job.id)

        return {
            'title': _('Job Creating'),
            'job_roles': JOB_ROLES,
            'cancel_url': reverse('jobs:tree'),
            'confirm': {
                'title': _('Create'),
                'url': reverse('jobs:api-create-job'),
                'method': 'POST'
            },
            'initial': {
                'name': get_unique_job_name(preset_job),
                'preset_dirs': get_preset_dir_list(preset_job),
                'roles': json.dumps(get_roles_form_data(), ensure_ascii=False),
            }
        }
Esempio n. 2
0
 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})
Esempio n. 3
0
 def handle(self, *args, **options):
     PopulatePresets().populate()
     if options['verbosity'] >= 1:
         self.stdout.write(
             "Preset jobs and files were successfully populated.")
Esempio n. 4
0
    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!')