Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/usr/bin/python
"""Verify the date because Apple can't."""
import datetime
import shell_tools
import sys_tools
current_year = int(datetime.datetime.now().year)
sys_tools.log('CPE-date_verification', 'Year is: %s' % current_year)
if current_year > 2017:
# If the date is > 2017, then Apple has fucked up again
sys_tools.log('CPE-date_verification', 'Year is > 2017: %s' % current_year)
# Manually set the current date to something reasonable, because if it's
# too far in advance, ntpdate can't fix itself
system_results = shell_tools.run_subp([
'/usr/bin/systemsetup',
'-setdate',
'04/20/17'
])
if not system_results['success']:
sys_tools.log('CPE-date_verification', "Fixing the date didn't work!")
results = shell_tools.run_subp([
'ntpdate',
'ntp.vip.facebook.com',
])
if not results['success']:
sys_tools.log('CPE-date_verification', "ntpdate didn't work!")
sys_tools.log(
'CPE-date_verification',
'Adjusted time. Current year is: %s ' % int(datetime.datetime.now().year)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.