Example #1
0
def aget(said):
    try:
        aid = int(said)
        results = db.artist_get([aid])
        return results[0]
    except ValueError:
        return None
Example #2
0
    def path(self, src=None, dest=None, src_id=None, dest_id=None, skips=None, save='True', _=None):
        log_api_call('path')

        results = get_results()

        if src_id:
            a1 = aget(src_id)
            src = ''
        else:
            a1 = asearch(src)

        save = save.lower() == 'true'

        if not a1:
            return seal_results(results, 'ERROR', "can't find " + src)

        if dest_id:
            a2 = aget(dest_id)
            dest = ''
        else:
            a2 = asearch(dest)

        if not a2:
            return seal_results(results, 'ERROR', "can't find " + dest)

        skipset = None
        if skips:
            try:
                skipset = set([sid for sid in skips.split(',')])
                results['skips'] = db.artist_get(list(skipset))
            except ValueError:
                return seal_results(results, 'ERROR', "bad skiplist " + skips)
        else:
            results['skips'] = []

        results['src'] = a1
        results['dest'] = a2
        path = db.artist_path(a1['id'], a2['id'], skipset=skipset, save=save)
        results['path'] = path
        gc.collect(0)
        self.paths += 1

        if self.paths % 100 == 0:
            gc.collect()
            util.summary_memory_usage()
            util.gc_info()
            print
        return seal_results(results)