[calc] Add timeouts and better formatting to calc.

- Added default timeout of 5s to expression evaluator, that will throw
  an error before evaluating the next statement if the timeout has passed.
  This should stop an expression consisting of several long running
  statements from taking too long.

- Calc now uses general number formatting from str.format to print the
  number according to it's magnitude.

- Fixes bug in Python 2 from #538, where long ints are let through by using
  abstract base class numbers.Integral.