Replies: 2 comments
-
Short answer: Yes! |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thank you, this is basically the use case text version code below to get an understanding if I can do this with Kivy. See the comments.
ip_add1 = "192.168.1.210" #MOCK CORE SWITCH 1
ip_add2 = "192.168.1.211" #MOCK CORE SWITCH 2
creds = {"username": "admin", "password": "xxxxx"}
session = requests.Session()
### initial login to device – this will be replaced with a rest cookie
def login():
login = session.post(fhttps://{ip_add1}/rest/v10.11/login <https://%7bip_add1%7d/rest/v10.11/login> , data=creds, verify=False)
print(f"This is the login code for SW1: {login.status_code}")
login = session.post(fhttps://{ip_add2}/rest/v10.11/login <https://%7bip_add2%7d/rest/v10.11/login> , data=creds, verify=False)
print(f"This is the login code for SW2: {login.status_code}")
print('─' * 80)
def logout():
logout = session.post(fhttps://{ip_add1}/rest/v10.11/logout <https://%7bip_add1%7d/rest/v10.11/logout> )
print(f"This is the logout code: {logout.status_code}")
logout = session.post(fhttps://{ip_add2}/rest/v10.11/logout <https://%7bip_add2%7d/rest/v10.11/logout> )
print(f"This is the logout code: {logout.status_code}")
print('─' * 80)
####rest api polling call####### This is what I am pulling from the device and based on the If statement match just change the button or box element representing that devie to the color and status. See below.
#that is basically it.
def bgpstatus_sw1():
bgp = session.get(fhttps://{ip_add1}/rest/v10.11/system/vrfs/default/bgp_routers/65001/bgp_neighbors?attributes=status <https://%7bip_add1%7d/rest/v10.11/system/vrfs/default/bgp_routers/65001/bgp_neighbors?attributes=status&depth=2&selector=status> &depth=2&selector=status, verify=False)
pprint.pprint(bgp.json())
sw_resp = (bgp.json())
b_format = json.dumps(sw_resp)
####based on json response into dictionary the if statements are what I am looking for. Based one of the six returned keywords I would set the box or button to the following color.
### below is just simple test code that works for an early text version. NOTE the colors I assigned based on status.
### the REST api polling call to pull the status is occurring every 10 seconds.
### I just need to get the returned status into a kivy element based on the if statement and change the text and color of the element for the device.
if "Idle" in b_format:
print("BGP PEER Idle - RED")
if "Connect" in b_format:
print("BGP PEER Connect - PURPLE")
if "Active" in b_format:
print("BGP PEER IS Active - BLUE")
if "OpenSent" in b_format:
print("BGP PEER IS OPEN SENT STATE - YELLOW")
if "Open-confirm" in b_format:
print("BGP PEER IS OPEN CONFIRM STATE - ORANGE")
if "Established" in b_format:
print("BGP PEER IS ESTABLISHED STATE - GREEN")
#else:
#print("something else")
#### second device polled via REST API
def bgpstatus_sw2():
bgp = session.get(fhttps://{ip_add2}/rest/v10.11/system/vrfs/default/bgp_routers/65002/bgp_neighbors?attributes=status <https://%7bip_add2%7d/rest/v10.11/system/vrfs/default/bgp_routers/65002/bgp_neighbors?attributes=status&depth=2&selector=status> &depth=2&selector=status, verify=False)
print(bgp.json())
sw_resp = (bgp.json())
b_format = json.dumps(sw_resp)
if "Idle" in b_format:
print("BGP PEER Idle - RED")
if "Connect" in b_format:
print("BGP PEER Connect - PURPLE")
if "Active" in b_format:
print("BGP PEER IS Active - BLUE")
if "OpenSent" in b_format:
print("BGP PEER IS OPEN SENT STATE - YELLOW")
if "Open-confirm" in b_format:
print("BGP PEER IS OPEN CONFIRM STATE - ORANGE")
if "Established" in b_format:
print("BGP PEER IS ESTABLISHED STATE - GREEN")
login()
while True:
bgpstatus_sw1()
bgpstatus_sw2()
time.sleep(10)
that is basically it. I have a working text version using colorama library that changes the router or switch’s bgp peer status dynamically based on the polling. However, would love to achieve the same with kivy if possible.
The only “clickable” events would be an initial login and exit of the application otherwise it would sit there, poll, and based on returned values update box/button color . Just a simple dashboard for a network operating center to view.
Any ideas/suggestions would be greatly appreciated. .
From: Julian ***@***.***>
Sent: Tuesday, February 27, 2024 9:11 AM
To: kivy/kivy-github-discussions ***@***.***>
Cc: AMILABS ***@***.***>; Author ***@***.***>
Subject: Re: [kivy/kivy-github-discussions] Can Kivy framwork accomodate as simple non interactive layout for a dashboard status application.? (Discussion #30)
Short answer: Yes!
—
Reply to this email directly, view it on GitHub <#30 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABOBAN7YAHZWWOFFJGEGABDYVXSQVAVCNFSM6AAAAABD3JXF46VHI2DSMVQWIX3LMV43SRDJONRXK43TNFXW4Q3PNVWWK3TUHM4DMMBVG44DI> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/ABOBANY5ZLEL6TUGBW25QGTYVXSQVA5CNFSM6AAAAABD3JXF46WGG33NNVSW45C7OR4XAZNRIRUXGY3VONZWS33OINXW23LFNZ2KUY3PNVWWK3TUL5UWJTQAQNIFQ.gif> Message ID: ***@***.*** ***@***.***> >
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
My use case is very simple and I want to know if the Kivy GUI framework can accommodate the use of dynamically updating a box’s(or using a button element as a box) text and color based on a changing status. No input(clicking a button) etc. is involved.
Basically a simple NON-Interactive dashboard consisting of a couple of boxes(or using button element) with text inside of them. When the status is changed for a variable the box's color should change as well as the status text.
My application is simple. It will make a REST API call periodically to a network device and pull its BGP peer’s current status(Established, connect, idle, etc). Upon receiving the data from the device it just updates that device’s gui box(or button) to reflect the data returned per device.
For example, a box’s color changes to red and text reads “idle” when the “idle” status is returned from the device, then the box’s color changes to green and text reads “established” when “established” status is returned from the device. A simple dashboard of BGP peer status.
I get this to work without the GUI via traditional looping through the rest call to the devices and std print output and that works fine but would love to use a simple Gui for this as well.
Can Kivy accommodate a passive layout(no user intervention) yet receive and update its layout elements(buttons etc) dynamically from received data OR is there a better python GUI framework that can accommodate this use case.
I just need the status and color of the box to change based on the status received. I don't need a complicated GUI framework with all kinds of refresh or timing machinations to update the framework’s layout. That is basically it.
I have tried another GUI framework but it was very rigid in its ability.
Any assistance or direction is greatly appreciated before I select the use of Kivy.
Beta Was this translation helpful? Give feedback.
All reactions