Notify that Python needs upgrading when requests can't be imported

This commit is contained in:
Alan Hamlett 2017-04-22 19:40:25 -07:00
parent 149ab8d00e
commit df7bf5cddb

View file

@ -34,8 +34,19 @@ from .constants import (
MALFORMED_HEARTBEAT_ERROR, MALFORMED_HEARTBEAT_ERROR,
) )
from .logger import setup_logging from .logger import setup_logging
from .offlinequeue import Queue
log = logging.getLogger('WakaTime')
try:
from .packages import requests from .packages import requests
except ImportError:
log.traceback(logging.ERROR)
print(traceback.format_exc())
log.error('Please upgrade Python to the latest version.')
print('Please upgrade Python to the latest version.')
sys.exit(UNKNOWN_ERROR)
from .offlinequeue import Queue
from .packages.requests.exceptions import RequestException from .packages.requests.exceptions import RequestException
from .project import get_project_info from .project import get_project_info
from .session_cache import SessionCache from .session_cache import SessionCache
@ -48,9 +59,6 @@ except (ImportError, SyntaxError): # pragma: nocover
from .packages import tzlocal from .packages import tzlocal
log = logging.getLogger('WakaTime')
def send_heartbeat(project=None, branch=None, hostname=None, stats={}, key=None, def send_heartbeat(project=None, branch=None, hostname=None, stats={}, key=None,
entity=None, timestamp=None, is_write=None, plugin=None, entity=None, timestamp=None, is_write=None, plugin=None,
offline=None, entity_type='file', hidefilenames=None, offline=None, entity_type='file', hidefilenames=None,