Exemplo n.º 1
0
    def POST(self):
        input = web.input()

        if input.Submit == "stop_pairing":
            set_bt_discoverable(False)
            if bluetooth.stop_pairing() is True:
                # show info and then go back to Index screen
                return render.info("Pairing stopped", "/bluetooth")
            return render.error(
                "Pairing process could not be stopped. Wait for timeout to happen."
            )

        # Set the bluetooth device as discoverable so that we can find
        # it while pairing
        error = set_bt_discoverable(True)
        bluetooth_set_pairable(True)
        if error is None:
            # if input.pin != "":
            #     use_pin = True
            # else:
            #     use_pin = False
            input.pin = ""
            use_pin = False
            status = bluetooth.start_pairing(use_pin, input.pin)
            set_bt_discoverable(False)
            bluetooth_set_pairable(False)
        else:
            return render.error("%s: %s" %
                                (error._dbus_error_name, error.message))
        if status is False:
            return render.error("Pairing failed")
        return view.main_screen()
Exemplo n.º 2
0
    def POST(self):
        if not logged():
            raise web.seeother("/login")
        input = web.input()

        if input.Submit == "stop_pairing":
            set_bt_discoverable(False)
            if bluetooth.stop_pairing() == True:
                return render.error("Pairing stopped")
            return render.error("Pairing process could not be stopped. Wait for timeout to happen.")

	# Set the bluetooth device as discoverable so that we can find
	# it while pairing
        error = set_bt_discoverable(True)
        if error == None:
            if input.pin != "":
                use_pin = True
            else:
                use_pin = False

            status = bluetooth.start_pairing(use_pin, input.pin)
            set_bt_discoverable(False)
        else:
            return render.error("%s: %s" % (error._dbus_error_name, error.message))
        if status == False:
            return render.error("Pairing failed")
        return view.main_screen()
Exemplo n.º 3
0
    def POST(self):
        if not logged():
            raise web.seeother("/login")
        input = web.input()
        if input.Submit == "tethering":
            if input["wifi"] == "ON":
                # Only validating the form if Wlan tethering is turned ON
                input.valid = True

                try:
                    len_passphrase = len(input["passphrase"])
                except:
                    len_passphrase = 0;

                try:
                    len_ssid = len(input["ssid"])
                except:
                    len_ssid = 0;

                if len_ssid == 0:
                    tethering.form.note = "Wlan SSID missing"
                    input.valid = False
                elif len_passphrase < 8 or len_passphrase > 64:
                    tethering.form.note = "Passphrase must be between 8 and 64 characters"
                    input.valid = False

                if not input.valid:
                    return render.base(view.listing(),
                                       title, logout, help)
                else:
                    tethering.form.note = ""
                    tethering.update(input)
            else:
                tethering.form.note = ""
                tethering.update(input)

        elif input.Submit == "technology":
            if not technology.form.validates():
                return render.base(view.listing(),
                                   title, logout, help)
            else:
                technology.update(input)

        elif input.Submit == "rescan":
            rescan.update(input)
            # allow some time for the scan to return some results
            time.sleep(6)

        return view.main_screen()
Exemplo n.º 4
0
    def POST(self):
        input = web.input()
        if input.Submit == "tethering":
            if input["wifi"] == "ON":
                # Only validating the form if Wlan tethering is turned ON
                input.valid = True

                try:
                    len_passphrase = len(input["passphrase"])
                except:
                    len_passphrase = 0

                try:
                    len_ssid = len(input["ssid"])
                except:
                    len_ssid = 0

                if len_ssid == 0:
                    tethering.form.note = "Wlan SSID missing"
                    input.valid = False
                elif len_passphrase < 8 or len_passphrase > 64:
                    tethering.form.note = "Passphrase must be between 8 and 64 characters"
                    input.valid = False

                if not input.valid:
                    return render.base(view.listing(), title, help)
                else:
                    tethering.form.note = ""
                    tethering.update(input)
            else:
                tethering.form.note = ""
                tethering.update(input)

        elif input.Submit == "technology":
            if not technology.form.validates():
                return render.base(view.listing(), title, help)
            else:
                technology.update(input)

        elif input.Submit == "rescan":
            rescan.update(input)
            # allow some time for the scan to return some results
            time.sleep(6)

        return view.main_screen()
Exemplo n.º 5
0
    def POST(self):
        if not cellular.form.validates():
            return cellular.view()

        input = web.input()

        (error, modem) = set_cellular_pin(input.pin)
        if error != None:
            return render.error("Setting PIN failed.<br>%s: %s" %
                                (error._dbus_error_name, error.message))

        (error, text) = activate_cellular()
        if error != None:
            return render.error("Activating cellular context failed. %s: %s" %
                                (error._dbus_error_name, error.message))
        if text != None:
            return render.error(text)
        return view.main_screen()
Exemplo n.º 6
0
    def POST(self):
        if not logged():
            raise web.seeother("/login")
        if not cellular.form.validates():
            return cellular.view()

        input = web.input()

        (error, modem) = set_cellular_pin(input.pin)
        if error != None:
            return render.error("Setting PIN failed.<br>%s: %s" % (error._dbus_error_name, error.message))

        (error, text) = activate_cellular()
        if error != None:
            return render.error("Activating cellular context failed. %s: %s" % (error._dbus_error_name, error.message))
        if text != None:
            return render.error(text)
        return view.main_screen()
Exemplo n.º 7
0
    def POST(self):
        if is_allowed() and logged():
            raise web.seeother("/")
        if not self.login_form.validates():
            return render.login(self.login_form,
                                "Login failed. Please authenticate yourself")

        username, password = web.input().user, web.input().passwd
        salt = ""
        password_without_hash = ""
        for userpwd in allowed:
            (allowed_username, hashed_password) = userpwd
            if username == allowed_username:
                split_password = hashed_password.rsplit("$", 1)
                salt = split_password[0] + "$"
                password_without_hash = split_password[1]
                break
        hashed_password = crypt.crypt(password, salt)
        if (username, hashed_password) in allowed:
            session.logged_in = True
            return view.main_screen()
        else:
            session.logged_in = False
            return render.login_error()
Exemplo n.º 8
0
 def GET(self):
     return view.main_screen()
Exemplo n.º 9
0
    def GET(self):
        if not logged():
            raise web.seeother('/login')

        return view.main_screen()