Fix open browser on servers

This commit is contained in:
Gabriel Augendre 2021-06-19 18:10:00 +02:00
parent af66b9728b
commit 8f529ea0fa
2 changed files with 9 additions and 4 deletions

View file

@ -1,6 +1,7 @@
import configparser import configparser
import os import os
import sys import sys
import webbrowser
import click import click
@ -19,18 +20,22 @@ def _config_has_sections(config):
def _open_url(url, echo): def _open_url(url, echo):
opened = False
if _is_tty(): if _is_tty():
if echo: if echo:
click.echo( click.echo(
"We will now open a browser for each account set in the config file." "We will now try to open a browser for each account set in the config file."
) )
click.echo( click.echo(
"You'll need to authenticate and then copy the code provided in the web " "You'll need to authenticate and then copy the code provided in the web "
"page back into this terminal, upon prompt." "page back into this terminal, upon prompt."
) )
click.pause() click.pause()
click.launch(url) result = webbrowser.open(url)
else: opened = result
if not opened:
click.echo("Go to {}, authenticate and enter the code below.".format(url)) click.echo("Go to {}, authenticate and enter the code below.".format(url))

View file

@ -1,6 +1,6 @@
[tool.poetry] [tool.poetry]
name = "cleantoots" name = "cleantoots"
version = "0.4.1" version = "0.4.2"
description = "Cleanup your toot history." description = "Cleanup your toot history."
license = "GPL-3.0-or-later" license = "GPL-3.0-or-later"
authors = ["Gabriel Augendre <gabriel@augendre.info>"] authors = ["Gabriel Augendre <gabriel@augendre.info>"]