def get(self, *args, **kwargs): try: session = Session() token, created = register_token(session) if not token: return if is_token_activated(session): response = Response( {'message': 'Project token is already activated'}) self.write_response(response) return if settings.WEB_BASE_URL.startswith( 'https' ) and not self.request.full_url().startswith('https'): web_base_url = 'http{}'.format(settings.WEB_BASE_URL[5:]) else: web_base_url = settings.WEB_BASE_URL url = '{}/projects/register/{}'.format(web_base_url, token.token) query_string = 'referrer={}'.format( quote(self.request.full_url().encode('utf8'))) self.redirect('%s?%s' % (url, query_string)) finally: session.close()
def main(): app = make_app() app.listen(settings.PORT, settings.ADDRESS) address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) logging.info(datetime.now().strftime('%B %d, %Y - %H:%M:%S %Z')) logging.info('Jet Bridge version {}'.format(VERSION)) logging.info('Starting server at {}'.format(url)) if settings.DEBUG: logging.warning('Server is running in DEBUG mode') logging.info('Quit the server with CONTROL-C') try: if not is_token_activated(): register_url = '{}register/'.format(url) logging.warning('[!] Your server token is not activated') if webbrowser.open(register_url): logging.warning('[!] Activation page was opened in your browser - {}'.format(register_url)) else: logging.warning('[!] Go to {} to activate'.format(register_url)) except RequestException: logging.error('[!] Can\'t connect to Jet Admin API') logging.error('[!] Token verification failed') tornado.ioloop.IOLoop.current().start()
def run_command(): logging.info(datetime.now().strftime('%B %d, %Y - %H:%M:%S %Z')) logging.info('Jet Bridge version {}'.format(VERSION)) if missing_options == settings.required_options_without_default: create_config() return elif len(missing_options) and len(missing_options) < len( settings.required_options_without_default): logging.info('Required options are not specified: {}'.format( ', '.join(missing_options))) return from jet_bridge.app import make_app app = make_app() app.listen(settings.PORT, settings.ADDRESS) address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) logging.info('Starting server at {}'.format(url)) if settings.DEBUG: logging.warning('Server is running in DEBUG mode') logging.info('Quit the server with CONTROL-C') try: session = Session() token, created = register_token(session) if not token: return if not is_token_activated(session): token = get_token(session) register_url = '{}api/register/?token={}'.format(url, token) logging.warning('[!] Your server token is not activated') logging.warning('[!] Token: {}'.format(token)) if settings.AUTO_OPEN_REGISTER and webbrowser.open(register_url): logging.warning( '[!] Activation page was opened in your browser - {}'. format(register_url)) except RequestException: logging.error('[!] Can\'t connect to Jet Admin API') logging.error('[!] Token verification failed') finally: session.close() tornado.ioloop.IOLoop.current().start()
def run_command(): from jet_bridge.app import make_app app = make_app() app.listen(settings.PORT, settings.ADDRESS) address = 'localhost' if settings.ADDRESS == '0.0.0.0' else settings.ADDRESS url = 'http://{}:{}/'.format(address, settings.PORT) logging.info('Starting server at {}'.format(url)) if settings.DEBUG: logging.warning('Server is running in DEBUG mode') logging.info('Quit the server with CONTROL-C') try: session = Session() token, created = register_token(session) if not token: return if not is_token_activated(session): token = get_token(session) register_url = '{}api/register/?token={}'.format(url, token) logging.warning('[!] Your server token is not activated') logging.warning('[!] Token: {}'.format(token)) if settings.AUTO_OPEN_REGISTER and webbrowser.open(register_url): logging.warning('[!] Activation page was opened in your browser - {}'.format(register_url)) except RequestException: logging.error('[!] Can\'t connect to Jet Admin API') logging.error('[!] Token verification failed') finally: session.close() tornado.ioloop.IOLoop.current().start()