コード例 #1
0
def scan_tickets(binary='zbarcam', signer=None):
    import subprocess, sys
    process = subprocess.Popen(binary, bufsize=1, stdout=subprocess.PIPE)
    if signer is None:
        signer = ticket_security.TicketSigner()
    while True:
        stdout = process.stdout.readline().strip()
        if stdout.startswith('QR-Code:'):
            data = stdout[8:]
            # Ticket of doom
            if sha256(data).hexdigest(
            ) == '6640cc0c536901fbc7c9f0fbe508a09c80be74656cb3ab915ec668503d54f91d':
                import webbrowser
                webbrowser.open('http://nyan.cat')
                continue
            try:
                user = signer.verify(data)
                un = User.get(user)
                if un is None:
                    yield False, "user not found in DB"
                    continue
                if not un.media_consent:
                    yield False, "user has not signed media consent"
                    continue
                if un.checked_in:
                    yield False, "user already granted entry"
                    continue
                un.mark_checked_in()
                yield True, "{0} - {1} ({2})".format(un.organisation,
                                                     un.fullname, un.username)
            except ValueError:
                yield False, "ticket is not valid"
コード例 #2
0
 def _get_user_fields(self):
     user_details = User.get(self.username)
     if not user_details:
         raise KeyError("username is unknown")
     elif not user_details.media_consent:
         raise ValueError("user has not signed a media consent form")
     self.name = user_details.fullname
     self.school = user_details.organisation
コード例 #3
0
    def _check_user(self, username, id_confirm):
        """Checks user details, moving into the wristbanding state on success"""
        try:
            user = User.get(username)
            self.current_username = username
            self.current_user = user

            if user is None:
                self._error_state("User '{}' not found".format(username))

            elif not user.media_consent:
                self._error_state("User '{}' ({}) has no media consent "
                                  "{}".format(
                                      user.fullname, username,
                                      "or doesn't exist"
                                      if user.fullname == username else ""))

            elif user.checked_in:
                self._error_state("User '{}' ({}) already checked-in".format(
                    user.fullname, username))

            else:
                if id_confirm:
                    self._set_message("Waiting for identity confirmation...",
                                      GOOD)
                    self._can_scan = False
                    if not self._confirm_identity_dialog():
                        self._ready_state()
                        return

                self._wristband_state(
                    "\nUser '{}' ({}) can be wristbanded".format(
                        user.fullname, username))

        except ValueError as e:
            self._error_state(str(e))