From: gregor herrmann Date: Thu, 14 Jul 2016 03:40:58 +0000 (+0200) Subject: use the new shiny BlockipError X-Git-Url: https://git.toastfreeware.priv.at/toast/tdyndns.git/commitdiff_plain/9b41ba33482698fc20c521cb182a5207c3ec44b6 use the new shiny BlockipError somehow this works better with call than with Popen --- 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):