Execute command
(command)
| 192 | |
| 193 | |
| 194 | def execute(command): |
| 195 | """ Execute command """ |
| 196 | returncode = -1 |
| 197 | try: |
| 198 | logging.info("Executing: %s" % command) |
| 199 | result = subprocess.check_output(command, shell=True) |
| 200 | returncode = 0 |
| 201 | |
| 202 | logging.debug("Command [%s] has the result [%s]" % (command, result)) |
| 203 | return result.decode().splitlines() |
| 204 | except subprocess.CalledProcessError as e: |
| 205 | logging.error(e) |
| 206 | returncode = e.returncode |
| 207 | finally: |
| 208 | logging.debug("Executed: %s - exitstatus=%s " % (command, returncode)) |
| 209 | |
| 210 | return list() |
| 211 | |
| 212 | |
| 213 | def save_iptables(command, iptables_file): |
no test coverage detected