From 9b41ba33482698fc20c521cb182a5207c3ec44b6 Mon Sep 17 00:00:00 2001 From: gregor herrmann Date: Thu, 14 Jul 2016 05:40:58 +0200 Subject: [PATCH] use the new shiny BlockipError somehow this works better with call than with Popen --- bin/tdyndns_update | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/tdyndns_update b/bin/tdyndns_update index ea15832..8f943f8 100755 --- a/bin/tdyndns_update +++ b/bin/tdyndns_update @@ -2,7 +2,7 @@ import sys import re import argparse -from subprocess import Popen, PIPE +from subprocess import Popen, PIPE, call import ipaddr @@ -52,9 +52,9 @@ def blockip_whitelist_add(ip): :param ip: ipv4 address :raises a BlockipError in case of errors.""" command = "iptables -I blockip -s {ip} -j ACCEPT".format(ip=ip) - p = Popen(command, shell=True) - if p.returncode != 0: - raise NsupdateError(p.returncode) + p = call(command, shell=True) + if p != 0: + raise BlockipError(p) def blockip_whitelist_delete(ip): @@ -62,9 +62,9 @@ def blockip_whitelist_delete(ip): :param ip: ipv4 address :raises a BlockipError in case of errors.""" command = "iptables -D blockip -s {ip} -j ACCEPT".format(ip=ip) - p = Popen(command, shell=True) - if p.returncode != 0: - raise NsupdateError(p.returncode) + p = call(command, shell=True) + if p != 0: + raise BlockipError(p) def main(args): -- 2.39.5