mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-14 16:27:13 +03:00
Check system time against NTP on startup
This commit is contained in:
parent
2cc44f0bf8
commit
ea0c3d3e9a
@ -57,6 +57,7 @@ import coriolis
|
||||
import eddb
|
||||
import edshipyard
|
||||
import loadout
|
||||
from ntp import NTPCheck
|
||||
import stats
|
||||
import prefs
|
||||
import plug
|
||||
@ -309,6 +310,10 @@ class AppWindow:
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
|
||||
if not NTPCheck(self.w): # Check system time
|
||||
self.w.destroy()
|
||||
return
|
||||
|
||||
self.postprefs(False) # Companion login happens in callback from monitor
|
||||
|
||||
if keyring.get_keyring().priority < 1:
|
||||
|
@ -52,6 +52,12 @@
|
||||
/* Menu item. [EDMarketConnector.py] */
|
||||
"Check for Updates..." = "Check for Updates...";
|
||||
|
||||
/* Error message shown if system time is wrong. [ntp.py] */
|
||||
"Check your system's Date and Time settings." = "Check your system's Date and Time settings.";
|
||||
|
||||
/* Error message shown if system time is wrong. [ntp.py] */
|
||||
"Check your system's Time Zone setting." = "Check your system's Time Zone setting.";
|
||||
|
||||
/* Federation rank. [stats.py] */
|
||||
"Chief Petty Officer" = "Chief Petty Officer";
|
||||
|
||||
@ -475,6 +481,9 @@
|
||||
/* Appearance setting. [prefs.py] */
|
||||
"Theme" = "Theme";
|
||||
|
||||
/* Error message shown if system time is wrong. [ntp.py] */
|
||||
"This app requires accurate timestamps." = "This app requires accurate timestamps.";
|
||||
|
||||
/* Help text in settings. [prefs.py] */
|
||||
"Tip: You can disable a plugin by{CR}adding '{EXT}' to it's folder name" = "Tip: You can disable a plugin by{CR}adding '{EXT}' to it's folder name";
|
||||
|
||||
|
@ -178,17 +178,17 @@ Download and extract the source code of the [latest release](https://github.com/
|
||||
|
||||
Mac:
|
||||
|
||||
* Requires the Python “keyring”, “requests” and “watchdog” modules, plus an up-to-date “py2app” module if you also want to package the app - install these with `easy_install -U keyring requests watchdog py2app` .
|
||||
* Requires the Python “keyring”, “ntplib”, “requests” and “watchdog” modules, plus an up-to-date “py2app” module if you also want to package the app - install these with `easy_install -U keyring ntplib requests watchdog py2app` .
|
||||
* Run with `./EDMarketConnector.py` .
|
||||
|
||||
Windows:
|
||||
|
||||
* Requires Python2.7 and the Python “keyring”, “requests” and “watchdog” modules, plus “py2exe” 0.6 if you also want to package the app.
|
||||
* Requires Python2.7 and the Python “keyring”, “ntplib”, “requests” and “watchdog” modules, plus “py2exe” 0.6 if you also want to package the app.
|
||||
* Run with `EDMarketConnector.py` .
|
||||
|
||||
Linux:
|
||||
|
||||
* Requires the Python “imaging-tk”, “iniparse”, “keyring” and “requests” modules. On Debian-based systems install these with `sudo apt-get install python-imaging-tk python-iniparse python-keyring python-requests` .
|
||||
* Requires the Python “imaging-tk”, “iniparse”, “keyring”, “ntplib” and “requests” modules. On Debian-based systems install these with `sudo apt-get install python-imaging-tk python-iniparse python-ntplib python-keyring python-requests` .
|
||||
* Run with `./EDMarketConnector.py` .
|
||||
|
||||
Command-line
|
||||
|
28
ntp.py
Normal file
28
ntp.py
Normal file
@ -0,0 +1,28 @@
|
||||
from ntplib import NTPClient
|
||||
from tkMessageBox import showerror
|
||||
|
||||
from config import applongname
|
||||
|
||||
if __debug__:
|
||||
from traceback import print_exc
|
||||
|
||||
def NTPCheck(parent):
|
||||
|
||||
DRIFT_THRESHOLD = 3 * 60
|
||||
TZ_THRESHOLD = 30 * 60
|
||||
CLOCK_THRESHOLD = 12 * 60 * 60 + DRIFT_THRESHOLD
|
||||
|
||||
try:
|
||||
response = NTPClient().request('pool.ntp.org')
|
||||
if abs(response.offset) > DRIFT_THRESHOLD:
|
||||
showerror(applongname,
|
||||
_('This app requires accurate timestamps.') + '\n' + # Error message shown if system time is wrong
|
||||
(TZ_THRESHOLD < abs(response.offset) < CLOCK_THRESHOLD and
|
||||
_("Check your system's Time Zone setting.") or # Error message shown if system time is wrong
|
||||
_("Check your system's Date and Time settings.")), # Error message shown if system time is wrong
|
||||
parent = parent)
|
||||
return False
|
||||
except:
|
||||
if __debug__: print_exc()
|
||||
|
||||
return True
|
Loading…
x
Reference in New Issue
Block a user