From 84f2faa818a7815bbb4c7ab5e2902ca09576a363 Mon Sep 17 00:00:00 2001 From: Oleksii Shevchuk Date: Sun, 12 Mar 2017 08:12:23 +0200 Subject: [PATCH] Don't try to execute IGD commands if ctrlURL is empty --- pupy/modules/igd.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pupy/modules/igd.py b/pupy/modules/igd.py index 7816dda6..21fbb0fa 100644 --- a/pupy/modules/igd.py +++ b/pupy/modules/igd.py @@ -37,7 +37,7 @@ class IGDCMDClient(object): columnlen = len(column) - 3 else: columnlen = len(column) - + columns.append(column) column_sizes[column] = max(len(str(cvalue)), columnlen) else: @@ -52,13 +52,13 @@ class IGDCMDClient(object): header += colorize(fmt.format(column), 'yellow') lines.append(header) - for value in values: + for value in values: row = '' for column in columns: fmt = ' {{:<{}}} '.format(column_sizes[column]) row += fmt.format(value[column]) lines.append(row) - + self.log('\n'.join(lines)) def addPM(self, args): @@ -195,7 +195,7 @@ class IGDClient(PupyModule): def init_argparse(self): cli = IGDCMDClient() - + parser = PupyArgumentParser( prog='igdc', description=self.__doc__ @@ -409,6 +409,10 @@ class IGDClient(PupyModule): igdc = self.client.conn.modules['network.lib.igd'].IGDClient UPNPError = self.client.conn.modules['network.lib.igd'].UPNPError self.cli.init(igdc, args, self.log) + if not self.cli.igdc.available: + self.error('IGD: Not found in LAN') + return + self.cli.igdc.enableDebug(args.DEBUG) self.cli.igdc.enablePPrint(args.pretty_print) try: