def run(self):
    if self.args.key:
        keys = filter((lambda x: (not self.is_cloned_by_jobkey(x))), self.args.key)
    elif self.args.tag_spider:
        keys = []
        (project_id, tag, spider) = self.args.tag_spider.split('/')
        for job in self.get_project(project_id).jobs.iter(spider=spider, state=['finished'], has_tag=tag):
            if (not self.is_cloned_by_jobkey(job['key'])):
                keys.append(job['key'])
    else:
        self.argparser.error('You must provide either --key or --tag-spider.')
    for job_key in keys:
        try:
            self.clone_job(job_key, self.args.units, self.args.tag)
        except Exception as e:
            _LOG.error('Could not restart job %s: %s', job_key, e)
def run(self):
    if self.args.key:
        keys = filter((lambda x: (not self.is_cloned_by_jobkey(x))), self.args.key)
    elif self.args.tag_spider:
        keys = []
        (project_id, tag, spider) = self.args.tag_spider.split('/')
        for job in self.get_project(project_id).jobs.iter(spider=spider, state=['finished'], has_tag=tag):
            if (not self.is_cloned_by_jobkey(job['key'])):
                keys.append(job['key'])
    else:
        self.argparser.error('You must provide either --key or --tag-spider.')
    for job_key in keys:
        try:
            self.clone_job(job_key, self.args.units, self.args.tag)
        except Exception as e:
            _LOG.error('Could not restart job %s: %s', job_key, e)