예제 #1
0
class App(QApplication):
    def __init__(self):
        QApplication.__init__(self, sys.argv)
        DB().conectar()

    def start(self):
        # self.show_form_login()
        self.show_main_window()
        sys.exit(app.exec_())

    def show_form_login(self):
        self.form_login = LoginController(Login())
        self.form_login.show_view()
        self.form_login.loginUser.connect(self.show_main_window)

    def show_main_window(self):
        self.main_window = MainWindowController(MainWindow())
        self.main_window.show_view()

    def show_form_socio_window(self):
        self.form_socio = FormSocioController(FormSocio())
        self.form_socio.show_view()

    def show_form_alumno_window(self):
        self.form_alumno = FormAlumnoController(FormAlumno())
        self.form_alumno.show_view()
예제 #2
0
파일: main.py 프로젝트: voneiden/ropeclient
class Connection(object):
    def __init__(self, websocket, address):
        """
        Connection object that is created when a new client connects.

        :param websocket: Websocket bound to the connection
        :param address: Address of the connection
        :return:
        """
        self.account = None
        self.websocket = websocket
        self.address = address
        self.controller = LoginController(self, runtime)
        logging.info("Connection established to address [{}]".format(str(address)))

    def send(self, payload):
        """
        Send a raw payload in the websocket

        :param payload: Payload to be sent
        :type payload: str
        :return:
        """
        logging.info("Queueing payload [{payload}] to address [{address}]".format(payload=payload, address=self.address))
        asyncio.ensure_future(self.websocket.send(payload))

    @asyncio.coroutine
    def recv(self):
        """
        Ready to receive data from the websocket. Passes the data to a controller handler.

        :return:
        """
        logging.info("Handling requests from " + self.address)
        while True:
            try:
                raw_message = yield from self.websocket.recv()
            except wex.ConnectionClosed:
                logging.info("Connection closed to address {address}".format(address=self.address))
                break
            if not raw_message:
                break
            logging.info("Received payload from address [{address}]: {message}".format(address=self.address, message=raw_message))
            try:
                message = json.loads(raw_message)
            except ValueError:
                logging.error("Unable to parse message")
                continue
            self.controller.handle(message)
            if message is None:
                break

        self.controller.stop()
예제 #3
0
def add_update_user():
    if not LoginController.athenticate_user():
        return redirect(url_for("google.login"))

    resp = google.get("/oauth2/v2/userinfo")
    email = resp.json()["email"]

    message = "User created/updated successfully."
    form = UserForm()
    if form.validate_on_submit():
        username = form.username.data
        dept_id = form.dept_id.data
        login_ip = form.login_ip.data

        user = UserModel.find_by_username(username)
        if user:
            user.dept_id = dept_id
            user.login_ip = login_ip
        else:
            user = UserModel(username, dept_id, login_ip)

        try:
            user.save()
        except:
            message = "Unable to save/update user"

        flash(message)
    return render_template('add_user.html', form=form, email=email)
예제 #4
0
def list_all():
    if not LoginController.athenticate_user():
        return redirect(url_for('logout'))

    resp = google.get("/oauth2/v2/userinfo")
    email = resp.json()["email"]

    # all_agents = UserModel.find_all()
    user = UserController()
    all_agents = user.get_all()
    return render_template('list_all.html', all_agents=all_agents, email=email)
예제 #5
0
    def __init__(self, websocket, address):
        """
        Connection object that is created when a new client connects.

        :param websocket: Websocket bound to the connection
        :param address: Address of the connection
        :return:
        """
        self.account = None
        self.websocket = websocket
        self.address = address
        self.controller = LoginController(self, runtime)
        logging.info("Connection established to address [{}]".format(str(address)))
예제 #6
0
 def show_form_login(self):
     self.form_login = LoginController(Login())
     self.form_login.show_view()
     self.form_login.loginUser.connect(self.show_main_window)