-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on packer and improving human readable report output.
- Loading branch information
Showing
7 changed files
with
232 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
""" | ||
Bastion.Humane | ||
Utilities mostly for creating "humane" (i.e. human scale) messages. | ||
""" | ||
import datetime | ||
|
||
from Bastion.Common import Alchemist | ||
|
||
humanize = Alchemist('Humane', "humanize") | ||
|
||
def _humanize_timedelta(elapsed, **kwargs): | ||
dt = elapsed.total_seconds( ) | ||
|
||
if dt > (86400*2): | ||
days = round(dt/86400.0, 1) | ||
return "{:.1f} days".format(days) | ||
|
||
if dt > 7200.0: | ||
hrs = round(dt/3600.0, 1) | ||
return "{:.1f} hours".format(hrs) | ||
|
||
if dt > 600.0: | ||
mins = round(dt/60.0, 1) | ||
return "{:.1f} minutes".format(dt / mins) | ||
|
||
return "{:.1f} seconds".format(dt) | ||
|
||
|
||
humanize.spells.append( (datetime.timedelta, _humanize_timedelta) ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.