(self)
Run the registration procedure

        The procedure is divided in two steps:

        1) Interaction with the user;
        2) Interaction with the API.

        This method implements step 1, where it sets up a GPG keyring, collects
        the user address, and prepares the request parameters for registering
        with the monitoring API. In the end, it dispatches step 2 on a thread.

        Note step 2 has to run on a thread because it needs the receiver lock
        first. By running on a thread, the main (parent) thread can proceed to
        initializing the receiver.
Run the registration procedure
Run the registration procedure
def _register(self):
        """Run the registration procedure

        The procedure is divided in two steps:

        1) Interaction with the user;
        2) Interaction with the API.

        This method implements step 1, where it sets up a GPG keyring, collects
        the user address, and prepares the request parameters for registering
        with the monitoring API. In the end, it dispatches step 2 on a thread.

        Note step 2 has to run on a thread because it needs the receiver lock
        first. By running on a thread, the main (parent) thread can proceed to
        initializing the receiver.

        """
        self.registration_running = True
        self.registration_failure = False

        # Save some state on the local cache
        cache = Cache(self.cfg_dir)

        # Show the explainer when running the registration for the first time
        # for this configuration
        if (cache.get(self.cfg + '.monitoring.explainer') is None):
            _register_explainer()

        # Cache flag indicating that the explainer has been shown already
        cache.set(self.cfg + '.monitoring.explainer', True)
        cache.save()

        # Create a GPG keyring and a keypair if necessary
        api.config_keyring(self.gpg)

        # Make sure the GPG passphrase is available. The passphrase can be
        # collected on key creation for a new keyring. On the other hand, it
        # wouldn't be available yet at this point for a pre-existing keyring.
        if (self.gpg.passphrase is None):
            util.fill_print("Please inform your GPG passphrase to decode the "
                            "encrypted verification code sent over satellite")
            self.gpg.prompt_passphrase("GPG passphrase: ")

        os.system('clear')

        # Get the user's location
        util.fill_print(
            "Please inform you city, state (if applicable), and country:")
        confirmed = False
        while (not confirmed):
            # City (required)
            city = util.string_input("City")

            # State (optional)
            state = input("State: ")
            if (len(state) > 0):
                address = "{}, {}".format(city, state)
            else:
                address = city

            # Country (required)
            country = util.string_input("Country")

            # Wait until the user confirms the full address
            address += ", {}".format(country)
            confirmed = util.ask_yes_or_no("\"{}\"?".format(address))

        os.system('clear')

        # Registration parameters
        fingerprint = self.gpg.get_default_priv_key()['fingerprint']
        pubkey = self.gpg.gpg.export_keys(fingerprint)
        satellite = self.user_info['sat']['alias']
        rx_type = config.get_rx_model(self.user_info)
        antenna = config.get_antenna_model(self.user_info)
        lnb = config.get_lnb_model(self.user_info)

        # Run step 2 on a thread
        t1 = threading.Thread(target=self._register_thread,
                              daemon=True,
                              args=(fingerprint, pubkey, address, satellite,
                                    rx_type, antenna, lnb))
        t1.start()
def _register ( self ) : self . registration_running = True self . registration_failure = False # Save some state on the local cache cache = Cache ( self . cfg_dir ) # Show the explainer when running the registration for the first time # for this configuration if ( cache . get ( self . cfg + '.monitoring.explainer' ) is None ) : _register_explainer ( ) # Cache flag indicating that the explainer has been shown already cache . set ( self . cfg + '.monitoring.explainer' , True ) cache . save ( ) # Create a GPG keyring and a keypair if necessary api . config_keyring ( self . gpg ) # Make sure the GPG passphrase is available. The passphrase can be # collected on key creation for a new keyring. On the other hand, it # wouldn't be available yet at this point for a pre-existing keyring. if ( self . gpg . passphrase is None ) : util . fill_print ( "Please inform your GPG passphrase to decode the " "encrypted verification code sent over satellite" ) self . gpg . prompt_passphrase ( "GPG passphrase: " ) os . system ( 'clear' ) # Get the user's location util . fill_print ( "Please inform you city, state (if applicable), and country:" ) confirmed = False while ( not confirmed ) : # City (required) city = util . string_input ( "City" ) # State (optional) state = input ( "State: " ) if ( len ( state ) > 0 ) : address = "{}, {}" . format ( city , state ) else : address = city # Country (required) country = util . string_input ( "Country" ) # Wait until the user confirms the full address address += ", {}" . format ( country ) confirmed = util . ask_yes_or_no ( "\"{}\"?" . format ( address ) ) os . system ( 'clear' ) # Registration parameters fingerprint = self . gpg . get_default_priv_key ( ) [ 'fingerprint' ] pubkey = self . gpg . gpg . export_keys ( fingerprint ) satellite = self . user_info [ 'sat' ] [ 'alias' ] rx_type = config . get_rx_model ( self . user_info ) antenna = config . get_antenna_model ( self . user_info ) lnb = config . get_lnb_model ( self . user_info ) # Run step 2 on a thread t1 = threading . Thread ( target = self . _register_thread , daemon = True , args = ( fingerprint , pubkey , address , satellite , rx_type , antenna , lnb ) ) t1 . start ( )