summaryrefslogtreecommitdiffstats
path: root/tv/2configs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-02-18 14:14:30 +0100
committertv <tv@krebsco.de>2016-02-18 16:48:32 +0100
commit482180639dcf6064f0b249aeb350347f6e8e461f (patch)
tree0b22dc7ebb0b054a49278c74b8ff28d012bef8a6 /tv/2configs
parent4dfd89de1781c699a8c8b04abf109cafb18105ae (diff)
tv urlwatch: filter pypi/vncdotool/json through jq
Diffstat (limited to 'tv/2configs')
-rw-r--r--tv/2configs/urlwatch.nix41
1 files changed, 38 insertions, 3 deletions
diff --git a/tv/2configs/urlwatch.nix b/tv/2configs/urlwatch.nix
index 0106cdd..51b5323 100644
--- a/tv/2configs/urlwatch.nix
+++ b/tv/2configs/urlwatch.nix
@@ -1,5 +1,5 @@
-{ config, ... }:
-
+{ config, pkgs, ... }:
+with config.krebs.lib;
{
krebs.urlwatch = {
enable = true;
@@ -52,8 +52,43 @@
# is derived from `configFile` in:
https://raw.githubusercontent.com/NixOS/nixpkgs/master/nixos/modules/services/x11/xserver.nix
- https://pypi.python.org/pypi/vncdotool
+ {
+ url = https://pypi.python.org/pypi/vncdotool/json;
+ filter = "system:${pkgs.jq}/bin/jq -r '.releases|keys[]'";
+ }
https://api.github.com/repos/kanaka/noVNC/tags
];
+ hooksFile = toFile "hooks.py" ''
+ import subprocess
+ import urlwatch
+
+ class CaseFilter(urlwatch.filters.FilterBase):
+ """Filter for piping data through an external process"""
+
+ __kind__ = 'system'
+
+ def filter(self, data, subfilter=None):
+ if subfilter is None:
+ raise ValueError('The system filter needs a command')
+
+ proc = subprocess.Popen(
+ subfilter,
+ shell=True,
+ stdin=subprocess.PIPE,
+ stdout=subprocess.PIPE,
+ stderr=subprocess.PIPE,
+ )
+
+ (stdout, stderr) = proc.communicate(data.encode())
+
+ if proc.returncode != 0:
+ raise RuntimeError(
+ "system filter returned non-zero exit status %d; stderr:\n"
+ % proc.returncode
+ + stderr.decode()
+ )
+
+ return stdout.decode()
+ '';
};
}