import constants
import utils

# planet update sanity checking

print("= sanity checking the planet file =")
sane = True
planet_size_bytes = 0
try:
    planet_size_bytes = os.path.getsize(constants.PLANET_PATH)
except OSError:
    planet_size_bytes = 0

# size
print("* planet size check *")
print("planet size: %s" % utils.bytes2PrettyUnitString(planet_size_bytes))
print("planet size sanity threshold: %s" % utils.bytes2PrettyUnitString(constants.PLANET_SANITY_THRESHOLD))
if planet_size_bytes >= constants.PLANET_SANITY_THRESHOLD:
    print("* planet size: OK")
else:
    print("* planet size: NOK")
    sane = False

# md5
print("* md5 check *")
remote_checksum = None
local_checksum = None
if constants.PLANET_MD5_URL:
    remote_checksum = None
    try:
        print("retrieving remote planet file checksum from:\n%s" % constants.PLANET_MD5_URL)