示例#1
0
 def _show_verification_success(self, username):
     text = "Congrats {}!\nYou are paired with this device.".format(
         username)
     console.big_image('images/pair_success.png')
     console.big_status(text)
     print_all(text + "\n")
     time.sleep(5)  # <-- TODO Remove this hack. Do something that's async.
     console.big_clear()
示例#2
0
 def _show_verification_failed(self, reason):
     reason = re.sub(r'\<.*?\>', '', reason)
     text = "Error:\n{}".format(reason)
     console.big_image('images/pair_error.png')
     console.big_status("Error:\nTry again.")
     print_all(text + "\n")
     time.sleep(5)  # <-- TODO Remove this hack. Do something that's async.
     console.big_clear()
示例#3
0
def ensure_token():
    token = STORE.get('DEVICE_TOKEN', None)

    if token is not None:
        # We have a token. All is well.
        return

    console.big_image('images/token_error.png')
    console.big_status('Ready to receive login token.')

    camera = CameraRGB()

    system_password = None

    for i, frame in enumerate(camera.stream()):
        frame = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
        stream_frame(frame)
        qrcodes = myzbarlight.qr_scan(frame)

        if len(qrcodes) > 0:
            qr_data = qrcodes[0]
            try:
                qr_data = json.loads(qr_data.decode('utf-8'))
                token = qr_data['t']
                if 'p' in qr_data:
                    # This allows us to override the default system_password for special-purpose devices.
                    # The default is just... a default. No matter what is set here, it can be changed later.
                    system_password = qr_data['p']
                break
            except:
                pass

    console.big_image('images/token_success.png')
    console.big_status('Success. Token: {}...'.format(token[:5]))

    camera.close()

    STORE.put('DEVICE_TOKEN', token)
    print_all("Stored Device token: {}...".format(token[:5]))

    jupyter_password = util.token_to_jupyter_password(token)
    STORE.put('DEVICE_JUPYTER_PASSWORD', jupyter_password)
    print_all("Stored Jupyter password: {}...".format(jupyter_password[:2]))

    if system_password is None:
        # If a particular default system_password was not specified, we will generate a good
        # default system_password from the token. This is a good thing, since it ensures that
        # each device is given a strong, unique default system_password.
        system_password = util.token_to_system_password(token)

    util.change_system_password(system_priv_user, system_password)
    print_all("Successfully changed {}'s password!".format(system_priv_user))

    time.sleep(5)

    console.big_clear()
    console.clear_image()
示例#4
0
                        else:
                            wireless.delete_connection(ssid)
                            msg = 'Disconnected.\nPlease use another WiFi network.'
                            log.info(msg)
                            console.big_image('images/wifi_error.png')
                            console.big_status(msg)
                            time.sleep(2)
                    else:
                        msg = 'WiFi credentials did not work.\nDid you type them correctly?\nPlease try again.'
                        log.info(msg)
                        console.big_image('images/wifi_error.png')
                        console.big_status(msg)
                else:
                    log.info("Success! Connected to SSID: {}".format(ssid))
                    console.big_image('images/wifi_success.png')
                    console.big_status('WiFi connection success!')
                    time.sleep(5)
                    print_connection_info()
                    break
            console.big_clear()
            console.clear_image()

            update_and_reboot_if_no_token()

    else:
        # We have WiFi.
        # After WiFi, we care that we have a Token so that we can authenticate with the CDP.
        ensure_token()

    time.sleep(5)
示例#5
0
# Use of this library, in source or binary form, is prohibited without written
# approval from AutoAuto, LLC.
#
###############################################################################

from auto import console as c
import time


# Put up a big full-screen image by passing an image-path.
c.big_image('images/wifi_success.png')
time.sleep(2)


# Put up some big text!
for i in range(1, 5):
    text = "All is good... {}".format(i)
    c.big_status(text)
    time.sleep(1)


# Clear the big text.
c.big_status('')
time.sleep(2)


# Clear the screen of the big image and text.
c.big_clear()
time.sleep(2)