Beispiel #1
0
def main(options, files):
    if options('general.tag_name'):
        tagData = tag.listTags(options('general.host'),
                               options('general.cluster'),
                               {'tag_name': options('general.tag_name')},
                               detail=True)[0]
        if tagData['phantom']:
            print 'PHANTOM'

        for f in tagData['files']:
            print '\t'.join(['FILE', f])

        for url in tagData['metadata'].get('urls', []):
            print '\t'.join(['URL', url])

        for k, v in tagData['metadata'].iteritems():
            if k not in ['urls']:
                print '\t'.join(['METADATA', k, str(v)])
    else:
        tags = tag.listTags(options('general.host'), options('general.cluster'), None, False)
        tags.sort(lambda x, y : cmp(x['tag_name'], y['tag_name']))
        for t in tags:
            print '\t'.join(['TAG', t['tag_name'], str(t['file_count'])])
Beispiel #2
0
def tags_is_filetype(tags, filetype):
    if filetype not in FILE_TYPES:
        raise Exception('Unknown file type')

    tagInfo = tag.listTags('localhost',
                           'local',
                           {'$or': [{'tag_name': t} for t in tags]},
                           True)

    for t in tagInfo:
        if t['files']:
            for f in t['files']:
                if not FILE_TYPES[filetype](f):
                    raise Exception('File %s did not pass' % f)
        elif not t['phantom'] and ('urls' not in t['metadata'] or 'urls' in t['metadata'] and t['metadata'].get('urls_realized', False)):
            raise Exception('A none-phantom-none-urls tag with no files is of no type')
Beispiel #3
0
def tags_is_filetype(tags, filetype):
    if filetype not in FILE_TYPES:
        raise Exception('Unknown file type')

    tagInfo = tag.listTags('localhost', 'local',
                           {'$or': [{
                               'tag_name': t
                           } for t in tags]}, True)

    for t in tagInfo:
        if t['files']:
            for f in t['files']:
                if not FILE_TYPES[filetype](f):
                    raise Exception('File %s did not pass' % f)
        elif not t['phantom'] and ('urls' not in t['metadata']
                                   or 'urls' in t['metadata'] and
                                   t['metadata'].get('urls_realized', False)):
            raise Exception(
                'A none-phantom-none-urls tag with no files is of no type')