Skip to content

Commit

Permalink
updated client with new last successful sync check implemented in wpk…
Browse files Browse the repository at this point in the history
…g-gp mod 17.17.
  • Loading branch information
sonicnkt committed Jul 21, 2017
1 parent 21a84c2 commit 1198f1c
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 35 deletions.
21 changes: 11 additions & 10 deletions WPKG-GP-Client.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# set path to wpkg.xml and get system architecture
xml_file, arch = arch_check()

req_wpkggp_ver = '0.17.15'
req_wpkggp_ver = '0.17.17'
app_name = 'WPKG-GP Client'

#Change working directory to get relative paths working for the images in the help files:
Expand Down Expand Up @@ -110,7 +110,7 @@ def __init__(self, trayicon, tooltip):
if update_startup:
self.on_timer(None)
if check_bootup_log:
last_check = check_file_date(xml_file)
last_check = ReadLastSyncTime()
now = datetime.datetime.now()
if (self.bootup_time + datetime.timedelta(hours=1) > now) and \
(self.bootup_time + datetime.timedelta(minutes=30) > last_check):
Expand All @@ -123,15 +123,16 @@ def __init__(self, trayicon, tooltip):
dlg = ViewLogDialog(title=title,log=errorlog)
dlg.ShowModal()
if check_last_upgrade:
# Check if the last changes to the local wpkg.xml are older than a specific time
# Check when WPKG-GP sucessfully synced the last time
# Inform USER that he should upgrade the System
last_check = check_file_date(xml_file)
if last_check < (datetime.datetime.now() - datetime.timedelta(days=last_upgrade_interval)):
dlg_str = _(u"System should be updated!\n\n"
u"System wasn't updated in over {} days.").format(str(last_upgrade_interval))
dlg = wx.MessageDialog(None, dlg_str, _(u"Attention!"), wx.OK | wx.ICON_EXCLAMATION)
dlg.ShowModal()
self.on_upgrade(None)
last_sync = ReadLastSyncTime()
if last_sync:
if last_sync < (datetime.datetime.now() - datetime.timedelta(days=last_upgrade_interval)):
dlg_str = _(u"System should be updated!\n\n"
u"System wasn't updated in over {} days.").format(str(last_upgrade_interval))
dlg = wx.MessageDialog(None, dlg_str, _(u"Attention!"), wx.OK | wx.ICON_EXCLAMATION)
dlg.ShowModal()
self.on_upgrade(None)

def CreatePopupMenu(self):
menu = wx.Menu()
Expand Down
44 changes: 23 additions & 21 deletions build_script.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- encoding: utf-8 -*-
# WPKG-GP Client BUILD SCRIPT

VERSION = "0.9.7.2" # max 4 number values separated by a "."
NAME = "WPKG-GP Client" # Application Name
VERSION = "0.9.7.4" # max 4 number values separated by a "."
NAME = "WPKG-GP Client" # Application Name
AUTHOR = "Nils Thiele"
INNOSETUPCMD = r'%PROGRAMFILES(X86)%\Inno Setup 5\iscc.exe' # InnoSetup with PreProcessor Support!
PYTHONSHELL = False # True or False
PYTHONSHELL = False # True or False, If True the compiled exe includes console window
INSTALLER = True # True or False, If True innosetup installer will be created
INNOSETUPCMD = r'%PROGRAMFILES(X86)%\Inno Setup 5\iscc.exe' # InnoSetup with PreProcessor Support!

# DO NOT MODIFY AFTER THIS POINT IF YOU DON'T KNOW WHAT YOU ARE DOING!!!

Expand Down Expand Up @@ -118,21 +119,22 @@ def v_convert(ver_str):
print 'Error Occured during pyinstaller process'
sys.exit(1)

print 'Building Inno Setup installer...'
print '--------------------------------'
# running inno setup to create installer package
INNOSETUPPATH = os.path.expandvars(INNOSETUPCMD)
if not PYTHONSHELL:
installer_name = 'wpkg-gp-client_v' + VERSION
else:
installer_name = 'wpkg-gp-client_v' + VERSION + '_debug'
innosetup_cmd = '""' + INNOSETUPPATH + '"' + ' /DMyOutput="{0}" /DMyAppVersion={1} /DMyAppName="{2}" ' \
'/DMyAppPublisher="{3}" /DMySourceDir="{4}" "{5}""'.format(
installer_name,
VERSION,
NAME,
AUTHOR,
os.path.join(path, 'dist'),
os.path.join(path, 'dist', "setup_script.iss"))
os.system(innosetup_cmd)
if INSTALLER:
print 'Building Inno Setup installer...'
print '--------------------------------'
# running inno setup to create installer package
INNOSETUPPATH = os.path.expandvars(INNOSETUPCMD)
if PYTHONSHELL:
installer_name = 'wpkg-gp-client_v' + VERSION + '_debug'
else:
installer_name = 'wpkg-gp-client_v' + VERSION
innosetup_cmd = '""' + INNOSETUPPATH + '"' + ' /DMyOutput="{0}" /DMyAppVersion={1} /DMyAppName="{2}" ' \
'/DMyAppPublisher="{3}" /DMySourceDir="{4}" "{5}""'.format(
installer_name,
VERSION,
NAME,
AUTHOR,
os.path.join(path, 'dist'),
os.path.join(path, 'dist', "setup_script.iss"))
os.system(innosetup_cmd)

17 changes: 13 additions & 4 deletions utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,19 @@ def ReadRebootPendingTime():
return None
return reboot_pending_time

def ReadLastSyncTime():
with _winreg.CreateKeyEx(_winreg.HKEY_LOCAL_MACHINE, R"SOFTWARE\WPKG", 0,
_winreg.KEY_READ | _winreg.KEY_WOW64_64KEY) as key:
try:
last_sync_value = _winreg.QueryValueEx(key, "lastsync")[0]
except WindowsError:
return None
try:
last_sync_time = datetime.datetime.strptime(last_sync_value, '%Y-%m-%d %H:%M:%S')
except (ValueError, TypeError):
return None
return last_sync_time

def vpn_connected(arch="x64"):
if arch == "x64":
vpn_path = "C:\Program Files (x86)\Cisco\Cisco AnyConnect Secure Mobility Client\\vpncli.exe"
Expand All @@ -183,10 +196,6 @@ def vpn_connected(arch="x64"):
else:
return False

def check_file_date(file):
time = datetime.datetime.fromtimestamp(os.path.getmtime(file))
return time

def getPercentage(str):
pat = re.compile('\(([0-9]{1,3})\/([0-9]{1,3})\)')
try:
Expand Down

0 comments on commit 1198f1c

Please sign in to comment.