-
-
Notifications
You must be signed in to change notification settings - Fork 850
feat: add progress indicator to repository check loop #9476
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 5 commits
6b640dd
52453a7
b9c31f5
81e11b0
1b98058
9df300c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
|
|
||
| class ProgressIndicatorBase: | ||
| LOGGER = "borg.output.progress" | ||
| JSON_TYPE: str = None | ||
| JSON_TYPE: str = None # type: ignore[assignment] | ||
|
|
||
| operation_id_counter = 0 | ||
|
|
||
|
|
@@ -41,6 +41,38 @@ def output(self, msg): | |
| self.logger.info(j) | ||
|
|
||
|
|
||
| class ProgressIndicatorCounter(ProgressIndicatorBase): | ||
| JSON_TYPE = "progress_counter" | ||
|
|
||
| def __init__(self, step=1000, msg="%d objects", msgid=None): | ||
|
ThomasWaldmann marked this conversation as resolved.
Outdated
|
||
| """ | ||
| Activity-based progress indicator, simply tracking a changing count. | ||
|
|
||
| :param step: step size | ||
| :param msg: output message; must contain one %d placeholder for the count. | ||
| """ | ||
| self.step = step | ||
| self.msg = msg | ||
| self.trigger_at = step | ||
| super().__init__(msgid=msgid) | ||
|
|
||
| def show(self, current=None): | ||
|
ThomasWaldmann marked this conversation as resolved.
Outdated
|
||
| """ | ||
| Show and output the progress message if the step condition is met. | ||
|
|
||
| :param current: Set the current counter value. | ||
| """ | ||
| if current is not None and current >= self.trigger_at: | ||
|
Comment on lines
+66
to
71
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initialize self.counter = 0 in init method, so you don't need that hasattr. also, move the code that is not related to producing output to a
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sagar-h007 seen this? ^ |
||
| # adjust trigger_at to the next step threshold | ||
| while self.trigger_at <= current: | ||
| self.trigger_at += self.step | ||
| return self.output(self.msg % current) | ||
|
|
||
| def output(self, message): | ||
| j = self.make_json(message=message) | ||
| self.logger.info(j) | ||
|
|
||
|
|
||
| class ProgressIndicatorPercent(ProgressIndicatorBase): | ||
| JSON_TYPE = "progress_percent" | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.