Skip to content
This repository has been archived by the owner on May 15, 2020. It is now read-only.

Commit

Permalink
small enhancements
Browse files Browse the repository at this point in the history
  • Loading branch information
Philippe Faist committed Dec 23, 2013
1 parent e4048a9 commit a90ab23
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 15 deletions.
3 changes: 2 additions & 1 deletion upd_iface.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def restart_app(exe=None):
def _bash_quote(x):
return "'" + x.replace("'", "'\\''") + "'"
def _batch_quote(x):
return '"' + x + '"'
raise NotImplementedError
#return '"' + x.replace(...) + '"'



Expand Down
15 changes: 12 additions & 3 deletions upd_iface_pyqt4.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ def __init__(self, init_check_delay=DEFAULT_INIT_CHECK_DELAY, check_interval=DEF
self.init_check_delay = init_check_delay
self.check_interval = check_interval

self.update_installed = False

self.timer = None
self.is_initial_delay = None
super(UpdatePyQt4Interface, self).__init__(parent=parent)
Expand All @@ -75,6 +77,10 @@ def start(self):
@pyqtSlot()
def slotTimeout(self):
logger.debug("pyqt4 interface: slotTimeout()")

if (self.update_installed):
logger.warning("We have already installed an update and pending restart.")
return

try:
# check for updates
Expand All @@ -94,6 +100,7 @@ def slotTimeout(self):
# yes, install update
#
upd_core.install_update(rel_info)
self.update_installed = True
#
# update installed.
#
Expand All @@ -111,9 +118,11 @@ def slotTimeout(self):
finally:
# configure the timer to tick in check_interval milliseconds from now.
self.is_initial_delay = False # also, we're no longer in the first initial delay.
self.timer.setSingleShot(True)
self.timer.setInterval(self.check_interval)
self.timer.start()
# only if we didn't just install an update and postponed restart
if not self.update_installed:
self.timer.setSingleShot(True)
self.timer.setInterval(self.check_interval)
self.timer.start()



Expand Down
32 changes: 21 additions & 11 deletions upd_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
import logging
import copy
import json
import inspect

import upd_core

Expand Down Expand Up @@ -127,19 +128,28 @@ def get_releases(self, newer_than_version=None, **kwargs):
class IgnoreArgument:
pass

def _make_bin_release_info(m, lst):
def _make_bin_release_info(m, lst, innerkwargs):

logger.debug("make_bin_release_info: lst=%r", lst)

args = {}
for k,v in lst:
for k,v in lst+innerkwargs.items():
val = None
try:
val = v(m=m)
except TypeError:
if (type(v).__name__ == 'function'):
argspec = inspect.getargspec(v)
valargs = {}
if ('m' in argspec.args or argspec.keywords is not None):
valargs['m'] = m;
if ('d' in argspec.args or argspec.keywords is not None):
valargs['d'] = innerkwargs;

val = v(**valargs)
else:
val = v

if (isinstance(val, IgnoreArgument)):
continue

args[k] = val

logger.debug("make_bin_release_info: final args=%r", args)
Expand All @@ -153,13 +163,13 @@ def relpattern(re_pattern, reltype=RELTYPE_UNKNOWN, platform=None, **kwargs):
(lambda m, filename, url, version=None,
_fix_plat=platform, _fix_rtyp=reltype, _fix_kwargs=copy.deepcopy(kwargs), **innerkwargs:
_make_bin_release_info(m,
[('version',version)] +
[ ('version',version) ] +
_fix_kwargs.items() +
[('filename', filename),
('url', url),
('platform',_fix_plat),
('reltype',_fix_rtyp)] +
innerkwargs.items()
[ ('filename', filename),
('url', url),
('platform',_fix_plat),
('reltype',_fix_rtyp) ],
innerkwargs
)
)
)
Expand Down

0 comments on commit a90ab23

Please sign in to comment.