def create_or_link_account(self, context, host, force, cb): if host != "floobits.com": self.link_account(context, host, cb) return disable_account_creation = utils.get_persistent_data().get( 'disable_account_creation') if disable_account_creation and not force: print( 'We could not automatically create or link your floobits account. Please go to floobits.com and sign up to use this plugin.' ) return if not G.EXPERT_MODE: editor.message_dialog( 'Thank you for installing the Floobits plugin!\n\nLet\'s set up your editor to work with Floobits.' ) choices = [ 'Sign in to Floobits', 'Automatically create a Floobits account', 'Cancel (see https://floobits.com/help/floorc)' ] ( choice, index ) = yield self.user_select, context, 'You need an account to use Floobits! Do you want to:', choices, None if index == -1 or index == 2: d = utils.get_persistent_data() if not d.get('disable_account_creation'): d['disable_account_creation'] = True utils.update_persistent_data(d) # TODO: this instruction is only useful for Sublime Text editor.message_dialog( '''You can set up a Floobits account at any time under:\n\nTools -> Floobits -> Set up''' ) cb(None) return agent = None if index == 0: agent = credentials.RequestCredentialsHandler() else: agent = account.CreateAccountHandler() agent.once('end', cb) try: reactor.reactor.connect(agent, host, G.DEFAULT_PORT, True) except Exception as e: print(str_e(e))
def link_account(self, context, host, cb): prompt = 'No credentials found in ~/.floorc.json for %s. Would you like to sign in? (opens a browser)' % host yes = yield self.user_y_or_n, context, prompt, 'Sign in' if not yes: return agent = credentials.RequestCredentialsHandler() if not agent: self.error_message('''A configuration error occured earlier. Please go to %s and sign up to use this plugin. We're really sorry. This should never happen.''' % host) return agent.once('end', cb) try: reactor.reactor.connect(agent, host, G.DEFAULT_PORT, True) except Exception as e: print(str_e(e))