diff options
author | mkaay <mkaay@mkaay.de> | 2011-01-31 15:39:03 +0100 |
---|---|---|
committer | mkaay <mkaay@mkaay.de> | 2011-01-31 15:39:03 +0100 |
commit | ffb4c1124d52e19128881c6d78a3009b191c8bbe (patch) | |
tree | 6dae99495d1a96c56f33caaf622c09dd0639db98 | |
parent | closed #223 (diff) | |
download | pyload-ffb4c1124d52e19128881c6d78a3009b191c8bbe.tar.xz |
fixed gui notification
-rw-r--r-- | module/PullEvents.py | 3 | ||||
-rw-r--r-- | module/Utils.py | 18 |
2 files changed, 19 insertions, 2 deletions
diff --git a/module/PullEvents.py b/module/PullEvents.py index 16566cfae..4f250d2f7 100644 --- a/module/PullEvents.py +++ b/module/PullEvents.py @@ -18,6 +18,7 @@ """ from time import time +from module.utils import uniqify class PullManager(): def __init__(self, core): @@ -45,7 +46,7 @@ class PullManager(): if not validUuid: self.newClient(uuid) events = [ReloadAllEvent("queue").toList(), ReloadAllEvent("collector").toList()] - return events + return uniqify(events, repr) def addEvent(self, event): for client in self.clients: diff --git a/module/Utils.py b/module/Utils.py index b85f48210..de07a9450 100644 --- a/module/Utils.py +++ b/module/Utils.py @@ -42,5 +42,21 @@ def freeSpace(folder): s = statvfs(folder) return s.f_bsize * s.f_bavail / 1024 / 1024 #megabyte +def uniqify(seq, idfun=None): + # order preserving + if idfun is None: + def idfun(x): return x + seen = {} + result = [] + for item in seq: + marker = idfun(item) + # in old Python versions: + # if seen.has_key(marker) + # but in new ones: + if marker in seen: continue + seen[marker] = 1 + result.append(item) + return result + if __name__ == "__main__": - print freeSpace(".")
\ No newline at end of file + print freeSpace(".") |