Esempio n. 1
0
def run():
    try:
        #course_repository = RepoCourses()
        course_repository = CourseFileRepository()
        #course_repository = CourseRepository()
        course_controller = CourseController(course_repository)
        student_repository = StudentFileRepository()
        #student_repository = StudentRepository()
        student_controller = StudentController(student_repository)
        #grade_repository = GradeRepository()
        grade_repository = GradeFileRepository(course_repository.find_all(),
                                               student_repository.find_all())
        grade_controller = GradeController(course_repository,
                                           student_repository,
                                           grade_repository)
        ui = UI(course_controller, student_controller, grade_controller)
        ui.run()
    except ValueError:
        print("Cannot read file data")
    except StudentError:
        print('Cannot read file data')
Esempio n. 2
0
class App(object):
    def __init__(self, first_message=""):
        """
        The construction for the app. Used for reading the bloc from the file
        """
        self.client_repository = FileClientRepository("clients_new.dat")
        self.movie_repository = FileMovieRepository("movies_new.dat")
        self.rent_repository = FileRentRepository("rents_new.dat")

        self.client_controller = ClientController(self.client_repository)
        self.movie_controller = MovieController(self.movie_repository)
        self.rent_controller = RentController(rent_repository=self.rent_repository,
                                              client_controller=self.client_controller,
                                              movie_controller=self.movie_controller)

        self.ui = UI(self.client_controller, self.movie_controller, self.rent_controller)
        Session.set_message(first_message)

    def run(self):
        """
        Main loop of the application
        """
        # self.load()
        self.ui.display_message()
        self.ui.run()
        # self.save()
        self.exit()

    # def load(self):
    #    """
    #    Load the previous state
    #    """
    #    try:
    #        with open("clients.dat", "r") as fp:
    #            self.client_repository._repository = cPickle.load(fp)
    #    except cPickle.UnpicklingError:
    #        pass
    #    except IOError:
    #        pass
    #
    #    try:
    #        with open("movies.dat", "r") as fp:
    #            self.movie_repository._repository = cPickle.load(fp)
    #    except cPickle.UnpicklingError:
    #        pass
    #    except IOError:
    #        pass
    #
    #    try:
    #        with open("rents.dat", "r") as fp:
    #            self.rent_repository._repository = cPickle.load(fp)
    #    except cPickle.UnpicklingError:
    #        pass
    #    except IOError:
    #        pass
    #
    # def save(self):
    #    """
    #    Saves the current state
    #    """
    #    with open("clients.dat", "w") as fp:
    #        cPickle.dump(self.client_repository._repository, fp)
    #    with open("movies.dat", "w") as fp:
    #        cPickle.dump(self.movie_repository._repository, fp)
    #    with open("rents.dat", "w") as fp:
    #        cPickle.dump(self.rent_repository._repository, fp)

    @staticmethod
    def exit():
        """
        Quits the app, called on 'quit' command
        """
        exit("\nBye Bye :)")
Esempio n. 3
0
def main():
    controller = Controller()
    ui = UI(controller)
    ui.run()
Esempio n. 4
0
def main():
    problem = Problem((2, [[0, 0], [0, 0]]))
    controller = Controller(problem)
    ui = UI(controller)
    ui.run()
Esempio n. 5
0
def main():
    problem = Problem('ant.in')
    controller = Controller('ant-params.in', problem)
    ui = UI(controller)
    ui.run()
Esempio n. 6
0
from ui.ui import UI
from service.Service import Service
from repository.Repository import Repository
repo = Repository("data/polbooks.gml")
serv = Service(repo)
ui = UI(serv)
ui.run()
Esempio n. 7
0
def main():
    finite_automata = FiniteAutomata.from_file('FA.in')
    print(finite_automata)
    ui = UI(finite_automata)
    ui.run()
Esempio n. 8
0
#!/usr/bin/python3
"""
@author: Daniel Butum, Group 911
"""
import sys

import tests
from ui.ui import UI

if __name__ == "__main__":
    if sys.version_info[0] < 3:
        sys.exit("ERROR: Must be using at least Python 3")

    tests.run()
    ui = UI()
    ui.run()