# Path: vmcatcher/__version__.py

# 
# Path: vmcatcher/listutils.py
# def pairsNnot(list_a,list_b):
#     len_generate_list = len(list_a)
#     len_image_list = len(list_b)
#     ocupies_generate_list = set(range(len_generate_list))
#     ocupies_image_list = set(range(len_image_list))
#     ocupies_pairs = ocupies_image_list.intersection(ocupies_generate_list)
#     diff_a = ocupies_generate_list.difference(ocupies_image_list)
#     diff_b = ocupies_image_list.difference(ocupies_generate_list)
#     arepairs = []
#     for i in ocupies_pairs:
#         arepairs.append([list_a[i],list_b[i]])
#     notpairs_a = []
#     for i in diff_a:
#         notpairs_a.append(list_a[i])
#     notpairs_b = []
#     for i in diff_b:
#         notpairs_b.append(list_b[i])
# 
#     return arepairs,notpairs_a,notpairs_b


from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from smimeX509validation import TrustStore, LoadDirChainOfTrust,smimeX509validation, smimeX509ValidationError
from vmcatcher.__version__ import version
from hepixvmitrust.vmitrustlib import VMimageListDecoder as VMimageListDecoder
from hepixvmitrust.vmitrustlib import time_format_definition as time_format_definition
from vmcatcher.listutils import pairsNnot
from M2Crypto import SMIME, X509, BIO
import vmcatcher.databaseDefinition as model
import os
import logging
import optparse
import vmcatcher
import urllib2
import urllib
import hashlib
import datetime
import vmcatcher.queryby
    import simplejson as json
    import json
import sys
import vmcatcher.outputfacard
        fp = open(path,'w')
        for touple_set in query_image:
            image = touple_set[0]
            image_list = touple_set[1]
            buf = BIO.MemoryBuffer(str(image_list.data))
            sk = X509.X509_Stack()
            p7, data = SMIME.smime_load_pkcs7_bio(buf)
            data_str = data.read()
            fp.write(data_str)
        fp.close()
    def image_by_sha512_display_info(self,ancore,sha512):
        output = []
        query_image = self.session.query(model.ImageInstance,model.ImageListInstance).\
            filter(model.ImageInstance.fkimagelistinstance == model.ImageListInstance.id).\
            filter(model.ImageInstance.sha512 == str(sha512))
        if query_image.count() == 0:
            self.log.warning('Message not found')
            return False
        for query_row in query_image:
            image = query_row[0]
            imagelist = query_row[1]

            print ('dc:identifier=%s' % (image.identifier))
            print ('dc:description=%s' % (image.description))
            print ('hv:hypervisor=%s' % (image.hypervisor))
            print ('sl:checksum:sha512=%s' % (image.sha512))
            print ('hv:uri=%s' % (image.uri))
            print ('sl:os=%s' % (image.os))
            print ('sl:osversion=%s' % (image.osversion ))
            print ('sl:arch=%s' % (image.arch))

# Path: vmcatcher/__version__.py

# 
# Path: vmcatcher/listutils.py
# def pairsNnot(list_a,list_b):
#     len_generate_list = len(list_a)
#     len_image_list = len(list_b)
#     ocupies_generate_list = set(range(len_generate_list))
#     ocupies_image_list = set(range(len_image_list))
#     ocupies_pairs = ocupies_image_list.intersection(ocupies_generate_list)
#     diff_a = ocupies_generate_list.difference(ocupies_image_list)
#     diff_b = ocupies_image_list.difference(ocupies_generate_list)
#     arepairs = []
#     for i in ocupies_pairs:
#         arepairs.append([list_a[i],list_b[i]])
#     notpairs_a = []
#     for i in diff_a:
#         notpairs_a.append(list_a[i])
#     notpairs_b = []
#     for i in diff_b:
#         notpairs_b.append(list_b[i])
# 
#     return arepairs,notpairs_a,notpairs_b


# Path: vmcatcher/vmcatcher_image/controler.py
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from smimeX509validation import TrustStore, LoadDirChainOfTrust,smimeX509validation, smimeX509ValidationError
from vmcatcher.__version__ import version
from hepixvmitrust.vmitrustlib import VMimageListDecoder as VMimageListDecoder
from hepixvmitrust.vmitrustlib import time_format_definition as time_format_definition
from vmcatcher.listutils import pairsNnot
from M2Crypto import SMIME, X509, BIO
import vmcatcher.databaseDefinition as model
import os
import logging
import optparse
import vmcatcher
import urllib2
import urllib
import hashlib
import datetime
import vmcatcher.queryby
    import simplejson as json
    import json
import sys
import vmcatcher.outputfacard

        fp = open(path,'w')
        for touple_set in query_image:
            image = touple_set[0]
            image_list = touple_set[1]
            buf = BIO.MemoryBuffer(str(image_list.data))
            sk = X509.X509_Stack()
            p7, data = SMIME.smime_load_pkcs7_bio(buf)
            data_str = data.read()
            fp.write(data_str)
        fp.close()
    def image_by_sha512_display_info(self,ancore,sha512):
        output = []
        query_image = self.session.query(model.ImageInstance,model.ImageListInstance).\
            filter(model.ImageInstance.fkimagelistinstance == model.ImageListInstance.id).\
            filter(model.ImageInstance.sha512 == str(sha512))
        if query_image.count() == 0:
            self.log.warning('Message not found')
            return False
        for query_row in query_image:
            image = query_row[0]
            imagelist = query_row[1]

            print ('dc:identifier=%s' % (image.identifier))
            print ('dc:description=%s' % (image.description))
            print ('hv:hypervisor=%s' % (image.hypervisor))
            print ('sl:checksum:sha512=%s' % (image.sha512))
            print ('hv:uri=%s' % (image.uri))
            print ('sl:os=%s' % (image.os))
            print ('sl:osversion=%s' % (image.osversion ))
            print ('sl:arch=%s' % (image.arch))

            print ('hv:version=%s' % (image.version))