Example #1
0
 def get_dns_deployment_option(self, option, server=None):
     e = self._soap_client.service.getDNSDeploymentOption(
         self.get_id(), option, 0)
     if not util.has_response(e):
         return None
     else:
         return entity(self, e, self._soap_client)
Example #2
0
 def __init__(self, width, height):
     self.width = width
     self.height = height
     self.origin = np.array([self.width / 2, self.height / 2])
     self.root = entity(
         point(self.origin, np.array([0., 0.]), np.array([0., 0.])),
         np.array([0., 0., 0.]))
     self.cluster = cluster(self.root)
Example #3
0
    def load(self, node):
        super(TransformResponse, self).load(node)

        entities = node.find('Entities')
        if entities == None:
            raise MalformedMessageError("Response requires Entities tag")

        for ent in entities.getchildren():
            self.entities.append( entity.entity( node=ent ) )
Example #4
0
 def create(self, amount):
     e = []
     for i in range(amount):
         p = point(vector.random(self.origin, 300), np.array([0., 0.]),
                   np.array([0., 0.]))
         c = color.random_hue(0, 360)
         ent = entity(p, c)
         e.append(ent)
     self.cluster.add(*e)
    def instantiate_entity(self, e, soap_client):
        """Instantiate an appropriate python class given an entity returned from a SOAP call.

        :param e: SOAP entity.
        :param soap_client: BAM SOAP client connection for the entity instance to use when accessing the API.
        :return: A type specific instance object of the SOAP entity or generic entity object. None if there is no type.
        """
        if 'type' in e:
            t = e['type']
            if t == entity.Configuration:
                return configuration(self, e, soap_client)
            elif t == entity.User:
                return user(self, e, soap_client)
            elif t == entity.Zone:
                return zone(self, e, soap_client)
            elif t == entity.View:
                return view(self, e, soap_client)
            elif t == entity.IP4Block:
                return ip4_block(self, e, soap_client)
            elif t == entity.IP4Network:
                return ip4_network(self, e, soap_client)
            elif t == entity.HostRecord:
                return host_record(self, e, soap_client)
            elif t == entity.AliasRecord:
                return alias_record(self, e, soap_client)
            elif t == entity.MXRecord:
                return mx_record(self, e, soap_client)
            elif t == entity.TXTRecord:
                return text_record(self, e, soap_client)
            elif t == entity.HINFORecord:
                return host_info_record(self, e, soap_client)
            elif t == entity.SRVRecord:
                return srv_record(self, e, soap_client)
            elif t == entity.NAPTRRecord:
                return naptr_record(self, e, soap_client)
            elif t == entity.ExternalHostRecord:
                return external_host_record(self, e, soap_client)
            elif t == entity.GenericRecord:
                return generic_record(self, e, soap_client)
            elif t == entity.EnumZone:
                return enum_zone(self, e, soap_client)
            elif t == entity.EnumNumber:
                return enum_number(self, e, soap_client)
            elif t in deployment_role.roles:
                return deployment_role(self, e, soap_client)
            elif t == entity.IP4Address:
                return ip4_address(self, e, soap_client)
            elif t == entity.Server:
                return server(self, e, soap_client)
            else:
                return entity(self, e, soap_client)
        else:
            return None
Example #6
0
def main_run():

    run = True
    vel_x = 3
    points = 0
    obstacles = []
    displayed_points = points
    collision = False
    pj = entity(60, 500-30-80, 50, 80, acc, timeJumping, timeSliding)

    while run:

        clock.tick(FPS)

        points += vel_x

        pj.action()
        draw_window(screen, obstacles, pj)

        for ind, obs in sorted(enumerate(obstacles)):
            if obs.test_collision(pj):
                end(win_x, 500, screen, displayed_points)
            obs.x -= vel_x
            if obs.x < -30:
                obstacles.remove(obs)

        textsurface = myfont.render('Points:' + str(displayed_points), False, (255, 255, 255))
        screen.blit(textsurface, (win_x - 20 - textsurface.get_width(), 20 + textsurface.get_height()))

        keys = pygame.key.get_pressed()
        if keys[pygame.K_UP] and not pj.isSliding:
            pj.isJumping = True
        if keys[pygame.K_DOWN] and not pj.isJumping:
            pj.isSliding = True

        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                run = False
                pygame.quit()
                sys.exit()
            if event.type == pygame.USEREVENT+1:
                vel_x += 1
            if event.type == pygame.USEREVENT+2:
                displayed_points = points
            if event.type == pygame.USEREVENT+3:
                r = random.randint(0, 1)
                if r == 0:
                    obstacles.append(obstacle(win_x, 500-(30+50), 70, 50))
                elif r == 1:
                    obstacles.append(obstacle(win_x, 0, 40, 395))

        pygame.display.update()
Example #7
0
    def push_bootstrap_to_db(self, db):

        for tid in self.type_order:
            self.log.debug("Inserting type:", tid)
            self.log.debug(repr(self.index["id"][tid]))
            e = entity.entity(rec=self.index["id"][tid], db=db, creator=db.creator_guid)
            if e.errors:
                self.log.debug("ERROR PUSHING TO DB IN INIT", e.errors, self.index["id"][tid])
                raise Exception
            else:
                e.create()
            if e.errors:
                self.log.debug("ERROR PUSHING TO DB IN CREATE", e.errors, self.index["id"][tid])
Example #8
0
 def entity_create(self):
     e = entity.entity(rec=self.q,db=self.db,creator=self.user.id)
     if e.errors:
         self.r["status"]="error"
         self.r["message"]=e.errors
         return False
     else:
         e.create()
         if e.errors:
             self.r["status"]="error"
             self.r["message"]=e.errors
             return False
         else:
             self.r["response"] = e.rec
             return True 
Example #9
0
def querydb():
    question =  request.form['question']

    with sql.connect("watson.db") as con:
        cur = con.cursor()
        cur.execute("INSERT INTO trends (question, asktime, useful) VALUES (?,?,?)",(question.lower(),int(time.time()),1))
        con.commit()
        msg = "Record successfully added"

    con = sql.connect("watson.db")
    con.row_factory = sql.Row
    cur = con.cursor()
    cur.execute("select answer from offline where question like (?)",(question,))

    answer = cur.fetchall()[0]["answer"]
    print(answer)
    if answer is None:
        answer = "Sorry we do not have an answer for this yet."
    yesNo, sentvalue = sentiment(answer)
    print yesNo, sentvalue

    try:
        #New Code
        entityQuestion = entity.entity(question)
        print entityQuestion
        (eat,heal,danger) = text.sentence(text.process(answer),entityQuestion)
        output, eatS, healS, dangerS = entity.score(eat,heal,danger)
        if ((len(output) > 0)):
            answer = ''.join(output)
        print output
        print eatS
        print healS
        print dangerS
        #End of new Code

        if(eatS > sentvalue):
            yesNo = 1
            sentvalue = eastS
        if(healS > sentvalue):
            yesNo = 1
            sentvalue = healS
        if(dangerS > sentvalue):
            yesNo = 0
            sentvalue = dangerS
    except:
        print "Sorry no help from Answer Extraction. Reverting back."

    return json.dumps({'answer': answer, 'sentiment' : yesNo, 'sentper' : sentvalue})
Example #10
0
 def __init__ (self,screen):
     width = 20
     length = 10
     self.tickrate = 10
     curses.curs_set(False)
     self.screen = screen
     self.World = world.world(width,length,self.tickrate)
     self.game_screen = 
     
     entity.player(0,0,self.World)
     entity.sheep(5,5,self.World)
     entity.zombie(7,7,self.World)
     a = entity.entity("D",3,3,25,self.World)
     a.name = "d"
     
     self.game_mode()
Example #11
0
def combine(a,b,op):
    #takes two entities and returns a combo of them.
    c = entity()
    if a.ent == b.contains or op == '-':
        #multiplication or subtraction swap
        t = a
        a = b
        b = t



    for k in a.__dict__:
        if k == "num":
            c.num = "("+str(a.__dict__[k])+op+str(b.__dict__[k])+")"
        else:
            c.__dict__[k]= b.__dict__[k]
    #print(c.__dict__)
    return c
Example #12
0
def newPlayer():
	corpus = {	"R": rotationBody(image = LD("../RESOURCES/RedSquare.png"), center = (100, 100)),
			"B": rotationBody(image = LD("../RESOURCES/BlueSquare.png"), center = (200, 100)),
			"G": rotationBody(image = LD("../RESOURCES/GreenSquare.png"), center = (300, 100)),
			"Y": rotationBody(image = LD("../RESOURCES/YellowSquare.png"), center = (400, 100)),
	}
	
	animations = {
			"RDown":	lambda corpus, moment, duration: boxDown(corpus["R"], moment, duration),
			"BDown":	lambda corpus, moment, duration: boxDown(corpus["B"], moment, duration),
			"GDown":	lambda corpus, moment, duration: boxDown(corpus["G"], moment, duration),
			"YDown":	lambda corpus, moment, duration: boxDown(corpus["Y"], moment, duration),
			"RUp":		lambda corpus, moment, duration: boxUp(corpus["R"], moment, duration),
			"BUp":		lambda corpus, moment, duration: boxUp(corpus["B"], moment, duration),
			"GUp":		lambda corpus, moment, duration: boxUp(corpus["G"], moment, duration),
			"YUp":		lambda corpus, moment, duration: boxUp(corpus["Y"], moment, duration),
			"twistR":	lambda corpus, moment, duration: twistBox(corpus["R"], moment),
			"twistB":	lambda corpus, moment, duration: twistBox(corpus["B"], moment),
			"twistG":	lambda corpus, moment, duration: twistBox(corpus["G"], moment),
			"twistY":	lambda corpus, moment, duration: twistBox(corpus["Y"], moment),
	}
	
	actions = {
			"RDown":	lambda ent, **worldState: pushBox(ent, "R", **worldState),
			"BDown":	lambda ent, **worldState: pushBox(ent, "B", **worldState),
			"GDown":	lambda ent, **worldState: pushBox(ent, "G", **worldState),
			"YDown":	lambda ent, **worldState: pushBox(ent, "Y", **worldState),
			"RUp":		lambda ent, **worldState: pullBox(ent, "R", **worldState),
			"BUp":		lambda ent, **worldState: pullBox(ent, "B", **worldState),
			"GUp":		lambda ent, **worldState: pullBox(ent, "G", **worldState),
			"YUp":		lambda ent, **worldState: pullBox(ent, "Y", **worldState),
			"twistR":	lambda ent, **worldState: startBox(ent, "R", **worldState),
			"twistB":	lambda ent, **worldState: startBox(ent, "B", **worldState),
			"twistG":	lambda ent, **worldState: startBox(ent, "G", **worldState),
			"twistY":	lambda ent, **worldState: startBox(ent, "Y", **worldState),
	}
	
	return entity(	corpus = corpus,
			animations = animations,
			actions = actions,
			brain = brain,
			init = init,
	)
Example #13
0
  def onexecute(self):

    # make an instance of all the functions
    # common.c = common()
    common.inventorytotal = playertotals()
    common.mp = morepanel()
    common.e = event()
    common.ai = ai()
    common.ip = infopanel()
    common.en = entity()
    common.cv = civilization()
    common.g = graphics()
    common.sounds = sounds.sounds()

    # initialize pygame
    pygame.init()


    # Read from config file
    opt = open(os.path.join(common.rootdir, "options.json"), 'r')
    y = json.loads(opt.read())
    common.srclocation = os.path.join("texturepacks", y['texturepack'])
    common.enablesky = bool(y['sky'])
    opt.close()

    # load the window
    common.screen = pygame.display.set_mode( (common.width, common.height), RESIZABLE)
    pygame.display.set_caption(common.name+" v."+str(common.version));
    common.running = True
    common.screen.fill((255,255,255))

    # load all images/resources
    common.g.loadall()
    pygame.display.set_icon(civilization.buildingtextures[0])

    # do cursors
    common.hand = pygame.cursors.compile(hand_str, 'x', '.', "o")
    common.grabber = pygame.cursors.compile(grabber_str, 'x', '.', "o")

    #Starts music
    common.sounds.playmusic("Into_the_Unknown")

    self.fromlauncher()
Example #14
0
def makeentity(tup,deps,s,i,words=None):
    ent,idx,num,lemma,cont= tup
    if ent == "$":
        ent = "dollars"
        lemma = "dollar"
    e = entity(num,ent,i,idx,cont,lemma,deps)
    ws = [x[0] for x in words]
    e.verb = e.verb.strip()
    if e.verb in ws:
        i = ws.index(e.verb)
        if "VB" not in words[i][1]["PartOfSpeech"]:
            e.verb = ''
    else: e.verb = ''


    if e.verb=='':
        verbs = [x[0] for x in words if "VB" in x[1]["PartOfSpeech"] and x[1]["Lemma"] not in ['do','be']]
        #print("VERBS : ",verbs);input()
        e.verb = ' '.join(verbs)
        
    return e
Example #15
0
    def load(self, node):
        super(TransformRequest, self).load(node)

        entities = node.find('Entities')
        if entities == None:
            raise MalformedMessageError('Request requires Entities tag')

        for ent in entities.getchildren():
            self.entities.append( entity.entity( node=ent ) )

        fields = node.find('TransformFields')
        if fields != None:
            for field in fields.getchildren():
                if 'Name' not in field.attrib:
                    raise MalformedMessageError("No Name attribute in Field")
                name = field.attrib['Name']
                value = field.text and field.text.strip() or ''
                self.fields[name] = value

        limit = node.find('Limits')
        if limit != None:
            self.softlimit = limit.attrib.get('SoftLimit', None)
            self.hardlimit = limit.attrib.get('HardLimit', None)
Example #16
0
window.title("SpaceShooter")

# Récupération de la taille de l'écran de l'utilisateur
width = window.winfo_screenwidth()
height = window.winfo_screenheight()

# Création de la fenêtre principale
can = Canvas(window, height = height,  width = width)


can.pack()
can.focus_set()
background.init(can, window)

# Création des entitées (vaisseau + ennemi)
world.addEntity(entity(can, can.create_image(width * 0.25, height * 0.5, image = images.clone(2)), vector(20, 0), 100))
world.addEntity(entity(can, can.create_image(width * 0.75, height * 0.5, image = images.clone(3)), vector(-20, 0), 100))

# Initialisation des commandes
key_press = {"Left": False, "Right": False, "Up": False, "Down": False, "space":False, "Escape":False}

def press(event):
    key_press[event.keysym] = True

def release(event):
    key_press[event.keysym] = False

for key in ["Up", "Left", "Right", "Down", "space", "Escape"]:
    can.bind('<KeyPress-%s>' %key, press)
    can.bind('<KeyRelease-%s>' %key, release)
Example #17
0
#tester
from entity import entity


# from inventory import inventory


stat = [10, 10, 10, 1000]


itemModifacation = [2,1]
playerModifacation = [1,1,1]

pla = entity("Quinny", stat)
pla.addItem("water", itemModifacation, playerModifacation)
pla.listItems()
print("\n\n")
pla.listItems()

print(pla.itemStats("water", 0))
print(pla.stats(3))
print(pla.name)
Example #18
0
 def add_to_coord(self, x, y):
     pt = point(np.array([x, y], dtype='f'), np.array([0., 0.]),
                np.array([0., 0.]))
     ent = entity(pt, np.array([0., 255., 0.]))
     self.cluster.add(ent)
Example #19
0
from entity import entity
from school import school

from SchoolList import SchoolList

from cv import cv

from work import work
e = entity('p')
e.setStartDate('Jan 1 2005')
s = school('q')
s.setStartDate('Jan 1 2005')
s.setEndDate('Jan 1 2006')

s1 = school('q2')
s1.setStartDate('Jan 1 2005')
s1.setEndDate('May 29  2006')

w = work('w')
w.setStartDate('May 1 2014')

e.printName()
s.printAll()
w.printAll()


sl = SchoolList()

#sl.addSchool(e)
#sl.addSchool(w)
sl.addSchool(s1)
Example #20
0
 def create_node(self, name):
     name = self.clean_entity_name(name)
     return entity(name)
Example #21
0
    ogre.draw(w)

    for obj in entities:
        obj.draw(w)
        if obj.name == 'monster':
            obj.followPlayer(ogre)

    playerInv.draw(w)
    p.display.update()


####### main ############
m = mapp(-3600, -3700)
entities.append(
    entity(-200, 600, -200, 600, 5, 10, 'monster', entity_type='mob'))
entities.append(entity(100, 100, 100, 100, 5, 10, 'monster',
                       entity_type='mob'))
entities.append(entity(-500, 300, -500, 300, 0, 0, 'tree',
                       entity_type='solid'))
playerInv = inventory(900, SCREEN_H - 300, False, False)

items.append(item(1, 'coins', 100, 100))
items.append(item(2, 'globes', 100, 100))

ogre = player(400, 300, 64, 64)
####### main ############

run = True

while run:
Example #22
0
# 聊天对话框

from Tkinter import *
from widgets import dialogbox

class DialogWindow(object):
    def __init__(self,local,remote):
        self.local,self.remote = local,remote

        self._init_window()
    def _init_window(self):
        self.root = Tk()

        self.remotelabel = Label(text='对方是:[%s]' % self.remote.name,anchor=W,font='sans 9 bold')
        self.dialog = dialogbox.DialogBox(self.root)

        self.remotelabel.grid(row=0,column=0,sticky=N+S+W+E,pady=5,padx=3)
        self.dialog.grid(row=1,column=0)

    def showdialog(self):
        self.root.mainloop()

if __name__ == '__main__':
    from entity import entity

    s = entity('a')
    r = entity('b')

    frm = DialogWindow(s,r)
    frm.showdialog()
Example #23
0
def process_data(entity, data):
	func_list = data.split(' ')
	for func_name in func_list:
		if len(func_name) > 0 :
			func = getattr(entity, func_name)
			if not func:
				print 'function %s not found!' % func_name
				continue
			func()

if __name__ == '__main__':
	socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	socket.bind(('127.0.0.1', 4000))
	socket.listen(0)
	socket.setblocking(0)
	entity = entity.entity()
	clients = {}
	while True:
		conn = None
		addr = None
		try:
			conn, addr = socket.accept()
		except:pass
		if conn:
			print 'find new connection'
			clients[addr[0]+str(addr[1])] = conn

		for client_id, client in clients.iteritems():
			data = ''
			while True:
				tmp_data = None
Example #24
0
from sys import argv
from entity import entity

if __name__ == '__main__':
    try:
        table_name = argv[1]
    except:
        print('SyntaxError: invalid syntax')
        print('usage: python dto.py table_name')
        quit()
    entity(table_name, dto=True)