forked from Eve-PySpy/PySpy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchkversion.py
44 lines (38 loc) · 1.65 KB
/
chkversion.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# !/usr/local/bin/python3.6
# MIT licensed
# Copyright (c) 2018 White Russsian
# Github: <https://github.com/Eve-PySpy/PySpy>**********************
''' Checks if there is a later version of PySpy available on GitHub.'''
# **********************************************************************
import logging.config
import logging
import os
import sys
import datetime
import requests
import wx
import __main__
import config
# cSpell Checker - Correct Words****************************************
# // cSpell:words russsian
# **********************************************************************
Logger = logging.getLogger(__name__)
# Example call: Logger.info("Something badhappened", exc_info=True) ****
CURRENT_VER = config.CURRENT_VER
def chk_github_update():
last_check = config.OPTIONS_OBJECT.Get("last_update_check", 0)
if last_check == 0 or last_check < datetime.date.today():
# Get latest version available on GitHub
GIT_URL = "https://api.github.com/repos/Eve-PySpy/PySpy/releases/latest"
try:
# verify=False to avoid certificate errors. This is not critical.
latest_ver = requests.get(GIT_URL, verify=False).json()["tag_name"]
Logger.info(
"You are running " + CURRENT_VER + " and " +
latest_ver + " is the latest version available on GitHub."
)
config.OPTIONS_OBJECT.Set("last_update_check", datetime.date.today())
if latest_ver != CURRENT_VER:
wx.CallAfter(__main__.app.PySpy.updateAlert, latest_ver, CURRENT_VER)
except:
Logger.info("Could not check GitHub for potential available updates.")