mirror of
https://github.com/Garmelon/PFERD.git
synced 2023-12-21 10:23:01 +01:00
Use transient progessbar
This will ensure no pesky newline ends up in the output, even on windows.
This commit is contained in:
parent
23bfa42a0d
commit
7024db1f13
@ -7,8 +7,7 @@ from types import TracebackType
|
||||
from typing import Optional, Type
|
||||
|
||||
import requests
|
||||
from rich.console import Console, ConsoleOptions, Control, RenderResult
|
||||
from rich.live_render import LiveRender
|
||||
from rich.console import Console
|
||||
from rich.progress import (BarColumn, DownloadColumn, Progress, TaskID,
|
||||
TextColumn, TimeRemainingColumn,
|
||||
TransferSpeedColumn)
|
||||
@ -23,7 +22,8 @@ _progress: Progress = Progress(
|
||||
TransferSpeedColumn(),
|
||||
"•",
|
||||
TimeRemainingColumn(),
|
||||
console=Console(file=sys.stdout)
|
||||
console=Console(file=sys.stdout),
|
||||
transient=True
|
||||
)
|
||||
|
||||
|
||||
@ -61,18 +61,6 @@ def progress_for(settings: Optional[ProgressSettings]) -> 'ProgressContextManage
|
||||
return ProgressContextManager(settings)
|
||||
|
||||
|
||||
class _OneLineUp(LiveRender):
|
||||
"""
|
||||
Render a control code for moving one line upwards.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
super().__init__("not rendered")
|
||||
|
||||
def __console__(self, console: Console, options: ConsoleOptions) -> RenderResult:
|
||||
yield Control(f"\r\x1b[1A")
|
||||
|
||||
|
||||
class ProgressContextManager:
|
||||
"""
|
||||
A context manager used for displaying progress.
|
||||
@ -113,9 +101,6 @@ class ProgressContextManager:
|
||||
_progress.stop()
|
||||
_progress.refresh()
|
||||
|
||||
# And we existed, so remove the line above (remove_task leaves one behind)
|
||||
Console().print(_OneLineUp())
|
||||
|
||||
return None
|
||||
|
||||
def advance(self, amount: float) -> None:
|
||||
|
14
README.md
14
README.md
@ -9,11 +9,19 @@ Ensure that you have at least Python 3.8 installed.
|
||||
To install PFERD or update your installation to the latest version, run this
|
||||
wherever you want to install/have installed PFERD:
|
||||
```
|
||||
$ pip install git+https://github.com/Garmelon/PFERD@v2.0.0
|
||||
$ pip install git+https://github.com/Garmelon/PFERD@v2.1.1
|
||||
```
|
||||
|
||||
The use of [venv](https://docs.python.org/3/library/venv.html) is recommended.
|
||||
|
||||
### Upgrading from 2.0.0 to 2.1.0+
|
||||
|
||||
The `IliasDirectoryType` type was renamed to `IliasElementType` and is now far
|
||||
more detailed.
|
||||
The new values are: REGULAR_FOLDER, VIDEO_FOLDER,
|
||||
EXERCISE_FOLDER, REGULAR_FILE, VIDEO_FILE, FORUM, EXTERNAL_LINK.
|
||||
Forums and external links are skipped automatically if you use the `kit_ilias` helper.
|
||||
|
||||
## Example setup
|
||||
|
||||
In this example, `python3` refers to at least Python 3.8.
|
||||
@ -29,8 +37,8 @@ $ mkdir Vorlesungen
|
||||
$ cd Vorlesungen
|
||||
$ python3 -m venv .venv
|
||||
$ .venv/bin/activate
|
||||
$ pip install git+https://github.com/Garmelon/PFERD@v2.0.0
|
||||
$ curl -O https://raw.githubusercontent.com/Garmelon/PFERD/v2.0.0/example_config.py
|
||||
$ pip install git+https://github.com/Garmelon/PFERD@v2.1.1
|
||||
$ curl -O https://raw.githubusercontent.com/Garmelon/PFERD/v2.1.1/example_config.py
|
||||
$ python3 example_config.py
|
||||
$ deactivate
|
||||
```
|
||||
|
Loading…
Reference in New Issue
Block a user