set_job_attr.py 文件源码

python
阅读 15 收藏 0 点赞 0 评论 0

项目:pfb-network-connectivity 作者: azavea 项目源码 文件源码
def handle(self, *args, **options):
        """ Try to set the attribute on the job.
        Invalid job ID warns, any other error raises """
        try:
            qs = AnalysisJob.objects.filter(pk=options['job_id'])
            # Force qs evaluation to catch invalid job_id errors
            qs.exists()
        except (ValueError, AnalysisJob.DoesNotExist):
            print ("WARNING: Tried to update attribute '{attr}' "
                   "for invalid job {job_id}.".format(**options))
        else:
            try:
                qs.update(**{options['attr']: options['value']})
            except (FieldDoesNotExist, ValueError, TypeError):
                print ("Error trying to update attribute '{attr}' to '{value}' "
                       "for {job_id}.".format(**options))
                raise
            else:
                self.stdout.write("{job_id}: Set '{attr}' to '{value}'".format(**options))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号