def main():
    logger.info('Running Targaryen {0}'.format(machines['instance']['type']))
    if machines['instance']['type'] == 'controller':
        controller()
    elif machines['instance']['type'] == 'server':
        server()
    elif machines['instance']['type'] == 'worker':
        worker()
Exemple #2
0
 def testFunctional2(self):
     rental.resetIDCounter()
     rental.setIDCounter(0)
     mvRepo = repo()
     clRepo = repo()
     rtRepo = repo()
     st = store()
     find = finder(clRepo, mvRepo)
     undoC = undoController()
     clc = clientController(clRepo, undoC)
     mvc = movieController(mvRepo, undoC)
     rtc = rentalController(rtRepo, clRepo, mvRepo, st, undoC)
     rmc = removalController(clRepo, mvRepo, rtRepo, undoC, rtc)
     CL = controller(clc, mvc, rtc, rmc, undoC, find)
     with self.assertRaises(Exception):
         CL.undo()
     with self.assertRaises(Exception):
         CL.redo()
     CL.addClient(["1", "Pop Ion"])
     CL.undo()
     CL.redo()
     CL.addMovie(["1", "Titanic", "nice", "Drama"])
     CL.undo()
     CL.redo()
     CL.rent(["1", "1", "11/11/2017", "14/11/2017"])
     CL.removeMovie(["1"])
     CL.undo()
     CL.redo()
     CL.undo()
     CL.removeClient(["1"])
     CL.undo()
     CL.redo()
     CL.undo()
     CL.updateClient(["1", "Pop Viorel"])
     CL.undo()
     CL.redo()
     CL.updateMovie(["1", "Titanic2", "nice", "Drama"])
     CL.undo()
     CL.redo()
     a = CL.getLateRentals(["15/11/2017"])
     CL.Return(["1", "16/11/2017"])
     CL.undo()
     CL.redo()
     CL.addClient(["2", "Ion Ion"])
     CL.addMovie(["2", "Avatar", "nice", "Sci-Fi"])
     CL.rent(["2", "2", "14/11/2017", "15/11/2017"])
     with self.assertRaises(Exception):
         CL.Return(["a", "11/11/2017"])
     a = CL.getMostActive()
     a = CL.getMostRented()
     CL.writeToFile()
Exemple #3
0
def main():

    clRepo = readFromFile("clientRepo.pickle")
    mvRepo = readFromFile("movieRepo.pickle")
    rtRepo = readFromFile("rentalRepo.pickle")
    st = store()
    find = finder(clRepo, mvRepo)
    undoC = undoController()
    clc = clientController(clRepo, undoC)
    mvc = movieController(mvRepo, undoC)
    rtc = rentalController(rtRepo, clRepo, mvRepo, st, undoC)
    rmc = removalController(clRepo, mvRepo, rtRepo, undoC, rtc)
    CL = controller(clc, mvc, rtc, rmc, undoC, find)
    u = UI(CL)
    u.start()
Exemple #4
0
def tests():
    '''
    test function for controller class
    '''
    b = board
    c = controller(b)
    c.movX(1, 1)
    assert b.getData() == [['0', '0', '0'], ['0', '1', '0'], ['0', '0', '0']]
    c.movO(2, 2)
    assert b.getData() == [['0', '0', '0'], ['0', '1', '0'], ['0', '0', '2']]
    c.replaceX(1, 1, 0, 0)
    assert b.getData() == [['1', '0', '0'], ['0', '0', '0'], ['0', '0', '2']]
    c.replaceO(2, 2, 1, 1)
    assert b.getData() == [['1', '0', '0'], ['0', '2', '0'], ['0', '0', '0']]
    c.movX(0, 1)
    c.movX(0, 2)
    assert c.gw() == True
 def testFunctional(self):
     rental.resetIDCounter()
     mvRepo = repo()
     clRepo = repo()
     rtRepo = repo()
     st = store()
     find = finder(clRepo, mvRepo)
     undoC = undoController()
     clc = clientController(clRepo, undoC)
     mvc = movieController(mvRepo, undoC)
     rtc = rentalController(rtRepo, clRepo, mvRepo, st, undoC)
     rmc = removalController(clRepo, mvRepo, rtRepo, undoC, rtc)
     CL = controller(clc, mvc, rtc, rmc, undoC, find)
     with self.assertRaises(Exception):
         a = CL.find("1")
     CL.addClient(["1", "Pop Vasile"])
     with self.assertRaises(Exception):
         CL.removeMovie(["ds"])
     CL.addMovie(["1", "Titanic", "nice", "Drama"])
     a = CL.listMovies()
     a = CL.listClients()
     a = CL.listRents("")
     CL.rent(["1", "1", "11/11/2017", "13/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["1", "1", "11/11/21", "12"])
     with self.assertRaises(Exception):
         CL.rent(["1", "1", "10/11/2017", "11/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["1", "1", "12/11/2017", "14/11/2017"])
     a = CL.getAllRentals()
     CL.addClient(["10", "Laur"])
     a = str(CL.getAllRentals()[0][0])
     CL.addMovie(["2", "Titanic2", "d", "Drama"])
     with self.assertRaises(Exception):
         CL.rent(["1", "2", "15/11/2017", "16/11/2017"])
     CL.rent(["10", "2", "13/11/2017", "14/11/2017"])
     CL.removeMovie(["2"])
     CL.Return(["1", "14/11/2017"])
     CL.rent(["10", "1", "17/11/2017", "19/11/2017"])
     with self.assertRaises(Exception):
         CL.Return(["1", "13/11/2017"])
     with self.assertRaises(Exception):
         CL.Return(["10", "11/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["10", "1", "13/11/2017", "16/11/2017"])
     self.assertEqual(str(CL.find("Pop")[0]), str(client("1",
                                                         "Pop Vasile")))
     CL.addClient(["3", "Ion"])
     CL.addMovie(["2", "Titanic2", "Nice", "Drama"])
     a = CL.getAllRentals()
     a = CL.getLateRentals(["13/11/2017"])
     a = CL.getMostActive()
     a = CL.getMostRented()
     a = CL.find("1")
     CL.updateClient(["1", "Pop Viorel"])
     CL.updateMovie(["1", "Titanic2", "nice", "Sci-Fi"])
     CL.addClient(["2", "Ion"])
     CL.removeClient(["1"])
     CL.removeMovie(["1"])
     with self.assertRaises(Exception):
         CL.addMovie("")
     with self.assertRaises(Exception):
         CL.removeMovie("")
     with self.assertRaises(Exception):
         CL.updateMovie("")
     with self.assertRaises(Exception):
         CL.addMovie(["c", "Titanic", "nice", "Romance"])
     with self.assertRaises(Exception):
         CL.removeClient("")
     with self.assertRaises(Exception):
         CL.addClient("")
     with self.assertRaises(Exception):
         CL.updateClient("")
     with self.assertRaises(Exception):
         CL.addClient(["c", "Viorel"])
     with self.assertRaises(Exception):
         CL.rent(["2", "1", "11/11/2017", "11/11/2017"])
     CL.removeClient(["2"])
     with self.assertRaises(Exception):
         CL.rent(["3", "1", "11/11/2017", "13/11/2017"])
     with self.assertRaises(Exception):
         CL.rent(["4", "1", "11/11/2017", "13/11/2017"])
     a = CL._clientController.getRepo()
     a = CL._movieController.getRepo()
     a = CL._rentalController.getRepo()
'''
Created on 3 feb. 2018

@author: Catalin
'''
from domain.components import board
from controller.controller import controller
from ui.UI import UI
from gamefile import boardfile

b=board() #initialize a board
c=controller(b) #initialize a controller
u=UI(c) #initialize the user interface

u.main() #run the program
Exemple #7
0
import socket
import select
from _pickle import loads, dumps
import sys, os
from message import message
from controller.controller import controller
from threading import Thread
from model.resource import RESOURCES
from model.interval import VALUE
from time import sleep
from model.scheduler import check_data
from threading import Timer

is_finished = False

control = controller()

timer = check_data(control.teams, control.fields, control.castles, True)


def setFinish():
    """Set game is finished"""
    global is_finished
    is_finished = True


"""Create timer for game time"""
timer_game = Timer(4 * 60 * 60.0, setFinish).start()


serverData = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
Exemple #8
0
from ui.console import console
from repo.repository import repository
from controller.controller import controller
'''
WIRE UP ALL THE CLASSES
'''
dnaRepo = repository()
dnaController = controller(dnaRepo)
dnaConsole = console(dnaController)
dnaConsole.run()
Exemple #9
0
from controller.controller import controller

if __name__ == '__main__':
    print(f'Kiara is alive')
    controller()
Exemple #10
0
def main():
	ct = controller()
	ui = UI(ct)
	ui.start()
Exemple #11
0
class animatedChassis():
  updatesPerSecond = 60
  updatePeriod = 1.0/updatesPerSecond
  cont = controller.controller()

  #For keeping track of update times
  lastUpdateTime = 0

  cp = chassisParams()
  c = chassis(cp)

  #Last actual step:
  lastStepPose = c.chassisPose

  stepRate = 5
  stepSize = 1

  #Reset timers and vars for the beginning of the next step
  def initNextStep(self):
  #Feet to pick up
  pass

  



  #Main Update Loop
  def update(self, time):
    if time-self.lastUpdateTime < updatePeriod: return

    #We are updating this time
    self.lastUpdateTime = time
    controlVector = cont.getControl()
    oldPose = self.c.chassisPose

    newPose = 


  #Calculates the position on a cycloid given the start and end positions
  # the progress of the step [0,1] and the height of the cycloid
  def interpolateStep(startPos, endPos, progress, height):
    #X
    xRadius = (startPos[0]-endPos[0])/2
    xMid = startPos[0]+xRadius
    X = xMid - xRadius*cos(progress*pi)

    #Y
    yRadius = (startPos[1]-endPos[1])/2
    yMid = startPos[1]+yRadius
    Y = yMid - yRadius*cos(progress*pi)

    #Z
    Z = (height/2)*(1-cos(progress*2*pi))+(endPos[2]-startPos[2])*progress

    return (X,Y,Z)

#Get intersection angle of Dyn with Stat
#Dyn is based at origin
#Stat is based on positive X axis
#Angle 0 is down the x axis
def getIntersectionAngle(baseDist, statAng, statWidth, dynWidth, statLen, dynLen):
  if (dynWidth + statWidth) > baseDist:
    print "Legs too wide for base positioning"
    return None

  statEnd = (baseDist + statLen*cos(statAng) + statWidth*cos(statAng+pi/2), statLen*sin(statAng) + statWidth*sin(statAng+pi/2))
  dynRadiusEff = sqrt(dynLen**2+dynWidth**2) #Effective radius of dynamic leg

  statVector = np.array([statWidth, cos(statAng-pi/2)*statLen, sin(statAng-pi/2)*statLen])
  dynEnd = (dynRadiusEff*cos(dynAng),dynRadiusEff*sin(dynAng))
  #This uses the dot product as in perceptron algorithm to get distance between and offset line and a point
  #Solve this for dynAng
  dist = -statWidth + statVector[1]*dynRadiusEff*cos(dynAng) + statVector[2]*dynRadiusEff*sin(dynAng)
from camera.camera import camera
from viewer.world_viewer import quad_viewer
from message_types import msg_state
import parameters.control_parameters as CON

targets = targets()

# initialize the visualization
quad_viewer = quad_viewer(targets)  # initialize the viewer
data_view = data_viewer()  # initialize view of data plots
# sensor_view = data_viewer()  # initialize view of data plots
input_view = input_viewer()

# initialize elements of the architecture
quad = quad_dynamics(SIM.ts_simulation)
ctrl = controller(SIM.ts_simulation)
obs = observer()
cam = camera(targets)
cam.update_state(quad.msg_true_state)
cam.show_image(0)
cam.plot_desired_targets(CON.desired_targets)

# initialize the simulation time
sim_time = SIM.start_time

# main simulation loop
print("Press Command-Q to exit...")
t0 = time.time()
inputs = CON.trim_input
while sim_time < SIM.end_time:
    #------------- reference signal -------------
Exemple #13
0
    def FrameDone(self, dictionaryOfEntrys, dicOfWorkEnt):

        dictionaryForModel = {} # the final dictionary that will be sent to the model.
        listOfStrNum = []       # lists used to aquire all the numbers in the input entry section.
        listOfNumbers = []

        # first lets do a little check!
        counter = 0
        dataFilled = True


        while(counter < len(dictionaryOfEntrys)):   # first lets do a check to see if all entries have been filled, if one of them is equal to 0 then we have nothing in this entry.

            if(len(dictionaryOfEntrys["authIn"+ str(counter)].get()) == 0 or len(dicOfWorkEnt["authIn" + str(counter)].get()) == 0):

                self.errorLabel.config(text = "please fill in all entry items in the Panel!")
                dataFilled = False

            counter += 1

        if(dataFilled):                                     # if the data checks out, then we are green to proceed:

            self.errorLabel.config(text = "")


            for key, value in dictionaryOfEntrys.items():   # count through all the content

                Author = str(dictionaryOfEntrys[key].get())# get the authors.

                numbers = str(dicOfWorkEnt[key].get())      # get all the numbers per each entry.


                listOfStrNum = re.findall('\d+', numbers)   # store them in a list.


                k = 0

                while(k < len(listOfStrNum)):

                    listOfNumbers.append(int(listOfStrNum[k]))  # convert string numbers into Integer numbers.

                    k+=1

                print(listOfNumbers)

                dictionaryForModel[Author] = set(listOfNumbers) # store all the data into dictionary for model.


                listOfStrNum.clear()
                listOfNumbers.clear()



            print("After doing all calculations this is what we got:\n",dictionaryForModel)

            con = controller.controller()                   # tell model, we got some data.


            con.authorBuild(dictionaryForModel, self.dataPath)

            self.withdraw()                                 # move to the next window page.
            newFrame = testingPage(con, self.root)
Exemple #14
0
# con = m.leer_todoscontactos()

# for k in con:
#     print(k.nombre)

# citas = m.leer_todascitas()

# print('*****************')
# for k in citas:
#     print(k.asunto)

# v=View()

# s = m.leer_todoscontactos()
# v.mostar_contactos(s)

# # f,c = m.borrar_contacto(1)

# # if f:
# #     v.borrar_contacto(c)

# # else:
# #     v.contacto_no_existe(1)

# v.mostar_citas(citas)

cont = controller()

cont.start()
 def setUp(self):
     self.__repo = repository()
     self.__controller = controller(self.__repo)
	def testApp(self):
		CT = controller()
		#additions
		a = CT.addition([2, "11100111001110101", "1101111011111"])
		assert str(a) == "11110101001010100"
		a = CT.addition([6, "23045", "100254"])
		assert str(a) == "123343"
		a = CT.addition([16, "54AB6F", "CD097D"])
		assert str(a) == "121B4EC"
		a = CT.addition([3, "2122012", "10112222"])
		assert str(a) == "20012011"
		a = CT.addition([4, "3220013", "22303231"])
		assert str(a) == "32123310"
		a = CT.addition([5, "3401323", "444033"])
		assert str(a) == "4400411"
		a = CT.addition([7, "6543210", "664455"])
		assert str(a) == "10540665"
		a = CT.addition([8, "5677034", "1234567"])
		assert str(a) == "7133623"
		a = CT.addition([16, "ABCDE", "D9037F"])
		assert str(a) == "E3C05D"
		a = CT.addition([2, "1100101011", "11101101"])
		assert str(a) == "10000011000"


		#substractions
		a = CT.substraction([2, "10001100010", "1110111011"])
		assert str(a) == "10100111"
		a = CT.substraction([9, "102387", "64502"])
		assert str(a) == "26785"
		a = CT.substraction([16, "501BA", "32ED"])
		assert str(a) == "4CECD"
		a = CT.substraction([8, "130046", "71257"])
		assert str(a) == "36567"
		a = CT.substraction([7, "210354", "55466"])
		assert str(a) == "121555"
		a = CT.substraction([6, "210354", "44355"])
		assert str(a) == "121555"
		a = CT.substraction([5, "102003", "3333"])
		assert str(a) == "43120"
		a = CT.substraction([4, "102003", "3333"])
		assert str(a) == "32010"
		a = CT.substraction([2, "100111000", "1100111"])
		assert str(a) == "11010001"
		a = CT.substraction([16, "10B009", "A5FCD"])
		assert str(a) == "6503C"
	

		#multiplications
		a = CT.multiplicationWithOneDigit([8, "7023", 5])
		assert str(a) == "43137"
		a = CT.multiplicationWithOneDigit([16, "32001B", 6])
		assert str(a) == "12C00A2"
		a = CT.multiplicationWithOneDigit([7, "12345", 5])
		assert str(a) == "65424"
		a = CT.multiplicationWithOneDigit([6, "12345", 5])
		assert str(a) == "111101"
		a = CT.multiplicationWithOneDigit([5, "31203", 3])
		assert str(a) == "144114"
		a = CT.multiplicationWithOneDigit([4, "31203", 3])
		assert str(a) == "220221"
		a = CT.multiplicationWithOneDigit([8, "21563", 7])
		assert str(a) == "174045"
		a = CT.multiplicationWithOneDigit([16, "A23F4", 11])
		assert str(a) == "6F8B7C"


		#division
		a = CT.divisionWithOneDigit([3, "20101", 2])
		assert str(a[0]) == "10012"
		assert str(a[1]) == "0"
		a = CT.divisionWithOneDigit([16, "1FED0205", 9])
		assert str(a[0]) == "38C1CAB"
		assert str(a[1]) == "2"
		a = CT.divisionWithOneDigit([8, "120456", 6])
		assert str(a[0]) == "15335"
		assert str(a[1]) == "0"
		a = CT.divisionWithOneDigit([7, "120456", 6])
		assert str(a[0]) == "13421"
		assert str(a[1]) == "0"
		a = CT.divisionWithOneDigit([5, "321023", 3])
		assert str(a[0]) == "103322"
		assert str(a[1]) == "2"
		a = CT.divisionWithOneDigit([4, "321023", 3])
		assert str(a[0]) == "103003"
		assert str(a[1]) == "2"
		a = CT.divisionWithOneDigit([16, "2A0F86", 14])
		assert str(a[0]) == "3011B"
		assert str(a[1]) == "C"
		a = CT.divisionWithOneDigit([8, "765433", 4])
		assert str(a[0]) == "175306"
		assert str(a[1]) == "3"


		#conversion
		a = CT.rapidConversion([2, "10000001101100", 8])
		assert str(a) == "20154"
		a = CT.rapidConversion([2, "11110010000001001010", 16])
		assert str(a) == "F204A"
		a = CT.rapidConversion([8, "11024", 2])
		assert str(a) == "1001000010100"
		a = CT.rapidConversion([16, "BC13F", 2])
		assert str(a) == "10111100000100111111"
		a = CT.rapidConversion([4, "1230", 8])
		assert str(a) == "154"
		a = CT.rapidConversion([16, "AB650", 8])
		assert str(a) == "2533120"
		a = CT.rapidConversion([16, "1C3D", 4])
		assert str(a) == "1300331"
		a = CT.rapidConversion([8, "63401", 16])
		assert str(a) == "6701"
		a = CT.conversionWithBase10([10, "3842", 5])
		assert str(a) == "110332"
		a = CT.conversionWithBase10([10, "10379", 7])
		assert str(a) == "42155"
		a = CT.conversionWithBase10([10, "2653", 6])
		assert str(a) == "20141"
		a = CT.conversionWithBase10([10, "222", 2])
		assert str(a) == "11011110"
		a = CT.conversionWithBase10([4, "3210", 10])
		assert str(a) == "228"
		a = CT.conversionWithBase10([5, "3041", 10])
		assert str(a) == "396"
		a = CT.conversionWithBase10([8, "1735", 10])
		assert str(a) == "989"
		a = CT.conversionWithBase10([2, "10111010011", 10])
		assert str(a) == "1491"
		a = CT.substitutionMethod([3, "2122", 5])
		assert str(a) == "241"
		a = CT.substitutionMethod([5, "1043", 7])
		assert str(a) == "301"
		a = CT.substitutionMethod([4, "2013", 6])
		assert str(a) == "343"
		a = CT.substitutionMethod([6, "1054", 16])
		assert str(a) == "FA"
		a = CT.succesiveDivisions([8, "1467", 5])
		assert str(a) == "11243"
		a = CT.succesiveDivisions([7, "2510", 3])
		assert str(a) == "1021202"
		a = CT.succesiveDivisions([9, "7048", 4])
		assert str(a) == "1100123"
		a = CT.succesiveDivisions([16, "BC0D", 6])
		assert str(a) == "1010513"