def BandwidthToString(bandwidth):
  """Converts a bandwidth to string.

  Args:
    bandwidth: The bandwidth to convert in byte/s. Must be a multiple of 1024/8.

  Returns:
    A string compatible with wpr --{up,down} command line flags.
  """
  assert bandwidth % (1024/8) == 0
  bandwidth_kbps = (int(bandwidth) * 8) / 1024
  if bandwidth_kbps % 1024:
    return '{}Kbit/s'.format(bandwidth_kbps)
  return '{}Mbit/s'.format(bandwidth_kbps / 1024)