From 4f9001cea466e8a9bf0066764f4d0de4e1f9373a Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Tue, 3 Sep 2013 13:38:03 +0800 Subject: [PATCH 1/4] do not limit very much on package names --- archrepo2/__init__.py | 2 +- archrepo2/repomon.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/archrepo2/__init__.py b/archrepo2/__init__.py index a35d00e..623554d 100644 --- a/archrepo2/__init__.py +++ b/archrepo2/__init__.py @@ -1,3 +1,3 @@ #!/usr/bin/env python3 -__version__ = '0.3.2' +__version__ = '0.3.3dev' diff --git a/archrepo2/repomon.py b/archrepo2/repomon.py index 410f424..c9a3078 100755 --- a/archrepo2/repomon.py +++ b/archrepo2/repomon.py @@ -26,7 +26,7 @@ from . import dbutil logger = logging.getLogger(__name__) # handles only x86_64, i686 and any arch packages -_pkgfile_pat = re.compile(r'(?:^|/)[a-z0-9_+-]+-[^-]+-\d+-(?:x86_64|i686|any)\.pkg\.tar\.xz(?:\.sig)?$') +_pkgfile_pat = re.compile(r'(?:^|/).+-[^-]+-\d+-(?:x86_64|i686|any)\.pkg\.tar\.xz(?:\.sig)?$') class ActionInfo(archpkg.PkgNameInfo): def __new__(cls, path, action, four=None, five=None, pkgpath=None): From cca8a27ef91c1c8c02b67b7ba3621f2c283101d8 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 5 Sep 2013 11:38:39 +0800 Subject: [PATCH 2/4] handle exceptions in callbacks --- archrepo2/repomon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/archrepo2/repomon.py b/archrepo2/repomon.py index c9a3078..2390d08 100755 --- a/archrepo2/repomon.py +++ b/archrepo2/repomon.py @@ -194,7 +194,10 @@ class RepoMan: del actiondict[act.name] else: # take the later action, but record the former - actiondict[act.name].callback(state=0) + try: + actiondict[act.name].callback(state=0) + except: + logger.exception('failed to run action %r.', actiondict[act.name]) actiondict[act.name] = act toadd = [(x.path, x.callback) for x in actiondict.values() if x.action == 'add'] toremove = [(x.name, x.callback) for x in actiondict.values() if x.action == 'remove'] From edc547632a9a936508eba662d869cca721ed1295 Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 5 Sep 2013 11:45:14 +0800 Subject: [PATCH 3/4] more logging --- archrepo2/repomon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/archrepo2/repomon.py b/archrepo2/repomon.py index 2390d08..d14ed2b 100755 --- a/archrepo2/repomon.py +++ b/archrepo2/repomon.py @@ -375,6 +375,7 @@ class EventHandler(pyinotify.ProcessEvent): (filename, pkgrepo, pkgname, pkgarch, pkgver, forarch, state, owner, mtime, info) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)''', (act.path, self.name, act.name, act.arch, act.fullversion, arch, state, owner, mtime, info)) + logger.info('Action %r done.', act) else: res = self._db.execute( From e0f3aa19f0a3fc0017bf546169fc78fcfa01c2dd Mon Sep 17 00:00:00 2001 From: lilydjwg Date: Thu, 5 Sep 2013 11:59:41 +0800 Subject: [PATCH 4/4] filter out broken symlinks --- archrepo2/repomon.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/archrepo2/repomon.py b/archrepo2/repomon.py index d14ed2b..c887adb 100755 --- a/archrepo2/repomon.py +++ b/archrepo2/repomon.py @@ -237,7 +237,10 @@ class EventHandler(pyinotify.ProcessEvent): dirs = [os.path.join(base, x) for x in ('any', 'i686', 'x86_64')] self.files = files = set() for d in dirs: - files.update(os.path.join(d, f) for f in os.listdir(d)) + for f in os.listdir(d): + p = os.path.join(d, f) + if os.path.exists(p): # filter broken symlinks + files.add(p) wm.add_watch(d, pyinotify.ALL_EVENTS) self.repomans[d] = RepoMan(config, d, self._ioloop) self.name = self.repomans[d].name