Skip to content

Instantly share code, notes, and snippets.

@anaselli
Last active May 13, 2019 15:23
Show Gist options
  • Save anaselli/a860793ff750ae842fdd2d2c509a9950 to your computer and use it in GitHub Desktop.
Save anaselli/a860793ff750ae842fdd2d2c509a9950 to your computer and use it in GitHub Desktop.
firewalld client connection and connection-changed event
from firewall.client import FirewallClient
import threading
from gi.repository import GLib
def fwConnectionChanged():
print ("event connection changed")
def glib_mainloop(loop):
loop.run()
loop = GLib.MainLoop()
fw = FirewallClient(wait=2)
fw.connect("connection-changed", fwConnectionChanged)
t = threading.Thread(target=glib_mainloop, args=(loop,))
t.start()
val = input("Press a key")
if fw.connected:
print("fw is connected")
print(fw.getZones())
loop.quit()
t.join()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment