Esempio n. 1
0
def test():

    from profile import Profiles
    from tm_calc import TrustMetric
    from pprint import pprint

    f = FileCertInfo()

    f.add_cert_seed('like', '55')
    f.add_cert_seed('like', 'luke')

    f.add_cert_level('like', 'none', 0)
    f.add_cert_level('like', "don't care", 1)
    f.add_cert_level('like', 'good', 2)
    f.add_cert_level('like', 'best', 3)

    f.set_cert_level_default('like', "don't care")
    f.set_cert_level_min('like', 'none')
    f.set_cert_tmetric_type('like', 'to')

    f.add_cert_seed('hate', 'heather')
    f.add_cert_seed('hate', '10')

    f.add_cert_level('hate', 'none', 0)
    f.add_cert_level('hate', "don't care", 1)
    f.add_cert_level('hate', 'dislike', 2)
    f.add_cert_level('hate', 'looks CAN kill', 3)

    f.set_cert_level_default('hate', "don't care")
    f.set_cert_level_min('hate', 'none')
    f.set_cert_tmetric_type('hate', 'to')

    p = Profiles(FileProfile, FileCertifications)
    r = p.add_profile('luke')
    r.add("name", 0, "luke")
    r.add("name", 1, "kenneth")
    r.add("name", 2, "casson")
    r.add("name", 3, "leighton")
    r.add("info", 0, "likes python a lot - thinks it's really cool")
    r.add("info", 1, "groks network traffic like he has a built-in headsocket")

    p.add_profile('heather')
    p.add_profile('bob')
    p.add_profile('mary')
    p.add_profile('lesser fleas')
    p.add_profile('little fleas')
    p.add_profile('fleas')
    p.add_profile('robbie the old crock pony')
    p.add_profile('tart the flat-faced persian cat')
    p.add_profile('mo the mad orange pony')
    p.add_profile('55')
    p.add_profile('10')
    p.add_profile('2')
    p.add_profile('fleas ad infinitum')

    p.add_cert('luke', 'like', 'heather', 'best')

    p.add_cert('heather', 'like', 'luke', 'best')
    p.add_cert('heather', 'like', 'robbie the old crock pony', 'best')
    p.add_cert('heather', 'like', 'tart the flat-faced persian cat', 'best')
    p.add_cert('heather', 'like', 'mo the mad orange pony', 'best')

    p.add_cert('bob', 'like', 'mary', 'good')
    p.add_cert('bob', 'like', 'heather', 'good')

    p.add_cert('mary', 'like', 'bob', 'good')

    p.add_cert('fleas', 'like', 'little fleas', 'good')
    p.add_cert('little fleas', 'like', 'lesser fleas', 'best')
    p.add_cert('lesser fleas', 'like', 'fleas ad infinitum', 'best')

    p.add_cert('robbie the old crock pony', 'like', 'fleas', 'best')
    p.add_cert('55', 'like', '10', 'none')
    p.add_cert('10', 'like', '2', 'best')

    p.add_cert('heather', 'hate', 'bob', 'dislike')
    p.add_cert('heather', 'hate', 'fleas', 'looks CAN kill')
    p.add_cert('fleas', 'hate', 'mary', 'dislike')
    p.add_cert('10', 'hate', '55', 'looks CAN kill')

    t = TrustMetric(f, p)
    r = t.tmetric_calc('like')
    pprint(r)

    r = t.tmetric_calc('like', ['heather'])
    pprint(r)

    r = t.tmetric_calc('hate')
    pprint(r)
Esempio n. 2
0
def test():
    from pprint import pprint
    from profile import Profiles, Profile
    from certs import DictCertifications

    # demonstration showing that numbers can certify and
    # be certified, not just strings.

    p = Profiles(Profile, DictCertifications)

    # p.add_profile('luke')
    # p.add_profile('heather')
    # p.add_profile('bob')
    # p.add_profile('mary')
    # p.add_profile('lesser fleas')
    # p.add_profile('little fleas')
    # p.add_profile('fleas')
    # p.add_profile('robbie the old crock pony')
    # p.add_profile('tart, the flat-faced persian cat')
    # p.add_profile('mo the mad orange pony')
    # p.add_profile(55)
    # p.add_profile(10)
    # p.add_profile(2)
    # p.add_profile('fleas ad infinitum')

    p.add_profile("bob")
    p.add_profile("anna")
    p.add_profile("ogi")
    p.add_profile("mark")

    p.add_cert("bob", "like", "anna", 'best')
    p.add_cert("ogi", 'like', 'mark', 'best')
    p.add_cert("mark", 'like', 'bob', 'good')

    # p.add_cert('luke', 'like', 'heather', 'best')
    #
    # p.add_cert('heather', 'like', 'luke', 'best')
    # p.add_cert('heather', 'like', 'robbie the old crock pony', 'best')
    # p.add_cert('heather', 'like', 'tart, the flat-faced persian cat', 'best')
    # p.add_cert('heather', 'like', 'mo the mad orange pony', 'best')
    #
    # p.add_cert('bob', 'like', 'mary', 'good')
    # p.add_cert('bob', 'like', 'heather', 'good')
    #
    # p.add_cert('mary', 'like', 'bob', 'good')
    #
    # p.add_cert('lesser fleas', 'like', 'fleas ad infinitum', 'good')
    # p.add_cert('little fleas', 'like', 'lesser fleas', 'good')
    # p.add_cert('fleas', 'like', 'little fleas', 'good')
    # p.add_cert('robbie the old crock pony', 'like', 'fleas', 'best')
    # p.add_cert(55, 'like', 10, 'none')
    # p.add_cert(10, 'like', 2, 'best')
    #
    # p.add_cert('heather', 'hate', 'bob', 'dislike')
    # p.add_cert('heather', 'hate', 'fleas', 'looks CAN kill')
    # p.add_cert('fleas', 'hate', 'mary', 'dislike')
    # p.add_cert(10, 'hate', 55, 'looks CAN kill')

    t = TrustMetric(CertInfo(), p)
    r = t.tmetric_calc('like', ['anna'])
    pprint(r)
Esempio n. 3
0
#!/usr/bin/python3.4

from profile import Profiles
from reservation import Reservation
from images import Images
from vm import VirtualMachine
from volume import Volume
import boto

profiles = Profiles()

def connect(name) :
	return boto.connect_ec2_endpoint(profiles[name][0], profiles[name][1], profiles[name][2])

profiles.addProfile("qnope", "https://fcu.eu-west-2.outscale.com")
Esempio n. 4
0
def test():

	from certs import CertInfo

	class TestCertInfo(CertInfo):

		def __init__(self):

			self.info = {}
			self.info['like'] = {'levels': ['none', "don't care", 'good',
			                               'best'],
								 'seeds': ['luke', 55],
								 'min level': 'none',
								 'default level': "don't care",
								 'type': 'to'
								}

			self.info['hate'] = {'levels':
								  ['none', "don't care", 'dislike',
								  'looks CAN kill'],
								 'seeds': ['heather', 10],
								 'min level': 'none',
								 'default level': "don't care",
								 'type': 'to'
								}

		def cert_seeds(self, idxn):
			return self.info[idxn]['seeds']

		def cert_levels(self, idxn):
			return self.info[idxn]['levels']

		def cert_level_default(self, idxn):
			return self.info[idxn]['default level']

		def cert_level_min(self, idxn):
			return self.info[idxn]['min level']

		def cert_tmetric_type(self, idxn):
			return self.info[idxn]['type']

	from pprint import pprint
	from profile import Profiles, Profile
	from certs import DictCertifications

	# demonstration showing that numbers can certify and
	# be certified, not just strings.

	p = Profiles(Profile, DictCertifications)

	p.add_profile('luke')
	p.add_profile('heather')
	p.add_profile('bob')
	p.add_profile('mary')
	p.add_profile('lesser fleas')
	p.add_profile('little fleas')
	p.add_profile('fleas')
	p.add_profile('robbie the old crock pony')
	p.add_profile('tart, the flat-faced persian cat')
	p.add_profile('mo the mad orange pony')
	p.add_profile(55)
	p.add_profile(10)
	p.add_profile(2)
	p.add_profile('fleas ad infinitum')

	p.add_cert('luke', 'like', 'heather', 'best')

	p.add_cert('heather', 'like', 'luke', 'best')
	p.add_cert('heather', 'like', 'robbie the old crock pony', 'best')
	p.add_cert('heather', 'like', 'tart, the flat-faced persian cat', 'best')
	p.add_cert('heather', 'like', 'mo the mad orange pony', 'best' )

	p.add_cert('bob', 'like', 'mary', 'good')
	p.add_cert('bob', 'like', 'heather', 'good')

	p.add_cert('mary', 'like', 'bob', 'good')

	p.add_cert('lesser fleas', 'like', 'fleas ad infinitum', 'good')
	p.add_cert('little fleas', 'like', 'lesser fleas', 'good')
	p.add_cert('fleas', 'like', 'little fleas', 'good')
	p.add_cert('robbie the old crock pony', 'like', 'fleas', 'best')
	p.add_cert(55, 'like', 10, 'none')
	p.add_cert(10, 'like', 2, 'best')

	p.add_cert('heather', 'hate', 'bob', 'dislike' )
	p.add_cert('heather', 'hate', 'fleas', 'looks CAN kill' )
	p.add_cert('fleas', 'hate', 'mary', 'dislike')
	p.add_cert(10, 'hate', 55, 'looks CAN kill')

	t = PymTrustMetric(TestCertInfo(), p)
	r = t.tmetric_calc('like')
	pprint(r)

	r = t.tmetric_calc('like', ['heather'])
	pprint(r)

	r = t.tmetric_calc('hate')
	pprint(r)
Esempio n. 5
0
def test():

	from profile import Profiles
	from tm_calc import PymTrustMetric
	from pprint import pprint

	f = FileCertInfo()

	f.add_cert_seed('like', '55')
	f.add_cert_seed('like', 'luke')

	f.add_cert_level('like', 'none', 0)
	f.add_cert_level('like', "don't care", 1)
	f.add_cert_level('like', 'good', 2)
	f.add_cert_level('like', 'best', 3)

	f.set_cert_level_default('like', "don't care")
	f.set_cert_level_min('like', 'none')
	f.set_cert_tmetric_type('like', 'to')

	f.add_cert_seed('hate', 'heather')
	f.add_cert_seed('hate', '10')

	f.add_cert_level('hate', 'none', 0)
	f.add_cert_level('hate', "don't care", 1)
	f.add_cert_level('hate', 'dislike', 2)
	f.add_cert_level('hate', 'looks CAN kill', 3)

	f.set_cert_level_default('hate', "don't care")
	f.set_cert_level_min('hate', 'none')
	f.set_cert_tmetric_type('hate', 'to')

	p = Profiles(FileProfile, FileCertifications)
	r = p.add_profile('luke')
	r.add("name", 0, "luke")
	r.add("name", 1, "kenneth")
	r.add("name", 2, "casson")
	r.add("name", 3, "leighton")
	r.add("info", 0, "likes python a lot - thinks it's really cool")
	r.add("info", 1, "groks network traffic like he has a built-in headsocket")

	p.add_profile('heather')
	p.add_profile('bob')
	p.add_profile('mary')
	p.add_profile('lesser fleas')
	p.add_profile('little fleas')
	p.add_profile('fleas')
	p.add_profile('robbie the old crock pony')
	p.add_profile('tart the flat-faced persian cat')
	p.add_profile('mo the mad orange pony')
	p.add_profile('55') 
	p.add_profile('10')
	p.add_profile('2')
	p.add_profile('fleas ad infinitum')

	p.add_cert('luke', 'like', 'heather', 'best')

	p.add_cert('heather', 'like', 'luke', 'best')
	p.add_cert('heather', 'like', 'robbie the old crock pony', 'best')
	p.add_cert('heather', 'like', 'tart the flat-faced persian cat', 'best')
	p.add_cert('heather', 'like', 'mo the mad orange pony', 'best' )

	p.add_cert('bob', 'like', 'mary', 'good')
	p.add_cert('bob', 'like', 'heather', 'good')

	p.add_cert('mary', 'like', 'bob', 'good')

	p.add_cert('fleas', 'like', 'little fleas', 'good')
	p.add_cert('little fleas', 'like', 'lesser fleas', 'best')
	p.add_cert('lesser fleas', 'like', 'fleas ad infinitum', 'best')

	p.add_cert('robbie the old crock pony', 'like', 'fleas', 'best')
	p.add_cert('55', 'like', '10', 'none')
	p.add_cert('10', 'like', '2', 'best')

	p.add_cert('heather', 'hate', 'bob', 'dislike' )
	p.add_cert('heather', 'hate', 'fleas', 'looks CAN kill' )
	p.add_cert('fleas', 'hate', 'mary', 'dislike')
	p.add_cert('10', 'hate', '55', 'looks CAN kill')

	t = PymTrustMetric(f, p)
	r = t.tmetric_calc('like')
	pprint(r)

	r = t.tmetric_calc('like', ['heather'])
	pprint(r)

	r = t.tmetric_calc('hate')
	pprint(r)