34 lines
1.2 KiB
Python
34 lines
1.2 KiB
Python
"""Optional browser workflow; all existing finalisation commands stay available."""
|
|
from pathlib import Path
|
|
import time
|
|
import webbrowser
|
|
|
|
from copienator import evaluation_parser
|
|
|
|
|
|
def main(argv=None):
|
|
parser = evaluation_parser('Open the local finalisation workspace')
|
|
parser.add_argument('--annotation-dir', choices=('BGnot', 'Bnot'), default='BGnot')
|
|
parser.add_argument('--no-browser', action='store_true')
|
|
args = parser.parse_args(argv)
|
|
from copienator.finalisation_server import WebSession
|
|
session = None
|
|
try:
|
|
session = WebSession(Path(args.evaluation).resolve(), args.annotation_dir)
|
|
print(session.url, flush=True)
|
|
if not args.no_browser:
|
|
webbrowser.open(session.url)
|
|
while session.alive:
|
|
time.sleep(.2)
|
|
except KeyboardInterrupt:
|
|
if session:
|
|
print('Fermeture après la fin du traitement en cours…', flush=True)
|
|
while session.service.job['running']:
|
|
time.sleep(.2)
|
|
session.request_stop()
|
|
session.thread.join()
|
|
except Exception as exc:
|
|
print(f'Erreur : {exc}', flush=True)
|
|
return 1
|
|
return 0
|