Last active
May 13, 2019 15:23
-
-
Save anaselli/a860793ff750ae842fdd2d2c509a9950 to your computer and use it in GitHub Desktop.
firewalld client connection and connection-changed event
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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