Skip to content

Conversation

@jcharaoui
Copy link

Makes it easier to use the output of this script in other places (eg. cron).

Copy link
Owner

@eepp eepp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too bad, but since the two functions (human and machine) do almost the same thing, some sort of template method with callbacks would be interesting.

True: colored('yes', 'green', attrs=['bold']),
False: colored('no', 'red', attrs=['bold']),
}[v]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two newlines here.

True: 1,
False: 0,
}[v]

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two newlines here.

eboxbw/cli.py Outdated
print_table_border()

def _print_machine(usage_info, conv_func, punit, details):

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.

for du in cur_month_usage.days_usage:
print_row(du.date, du.dl_usage, du.ul_usage, du.combined_usage,
lambda d: d.strftime('%Y-%m-%d'))

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two newlines here.

eboxbw/cli.py Outdated
date_txt = date_cb(date)
fmt_row1 = '{}::{}::{}::{}'

print(fmt_row1.format(date_txt, dl.real_gb, ul.real_gb, cb.real_gb))
Copy link
Owner

@eepp eepp Sep 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use conv_func here to print either GiBs or MiBs.

print(fmt_row1.format(date_txt, dl.real_gb, ul.real_gb, cb.real_gb))

if dl.effective_gb is not None:
dl_txt = dl.effective_gb
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use conv_func.

eboxbw/cli.py Outdated
dl_txt = dl.effective_gb
ul_txt = ul.effective_gb
cb_txt = cb.effective_gb

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty line.

eboxbw/cli.py Outdated
print('{}::{}'.format('capacity',
usage_info.plan_cap.real_gb))
print('{}::{}'.format('available_usage',
usage_info.available_usage.real_gb))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all the print() above:

  • Use CSV format.
  • Use hyphens instead of underscores, e.g. super-off-peak.
  • Follow PEP 8 to align parameters.
  • Use conv_func.

return {
True: 1,
False: 0,
}[v]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer non-colored yes and no.

cur_month_usage = usage_info.cur_month_usage
date = cur_month_usage.date

if date is None:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duplicate code: create a function for this warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants