1
0
Fork 0
mirror of https://github.com/dbarzin/pandora-box.git synced 2025-07-18 21:09:41 +02:00

code quality

This commit is contained in:
dbarzin 2023-02-25 18:59:41 +01:00
parent ccf1a9b31c
commit ed789fb9e8
8 changed files with 37 additions and 44 deletions

View file

@ -17,7 +17,6 @@ jobs:
uses: py-actions/flake8@v2 uses: py-actions/flake8@v2
with: with:
ignore: "BLK100" ignore: "BLK100"
exclude: "tests/*"
max-line-length: "128" max-line-length: "128"
path: "." path: "."
plugins: "flake8-bugbear==22.1.11 flake8-black" plugins: "flake8-bugbear==22.1.11 flake8-black"

View file

@ -1,5 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/python3
import pyudev import pyudev
import psutil import psutil
import time import time
@ -51,9 +50,9 @@ for device in iter(monitor.poll, None):
for partition in psutil.disk_partitions(): for partition in psutil.disk_partitions():
if partition.device == device.device_node: if partition.device == device.device_node:
print("Mounted at {}".format(partition.mountpoint)) print("Mounted at {}".format(partition.mountpoint))
statvfs=os.statvfs(partition.mountpoint) statvfs = os.statvfs(partition.mountpoint)
print("size %4.1fGB"% (statvfs.f_frsize * statvfs.f_blocks // 1024 // 1024 / 1024)) print("size %4.1fGB" % (statvfs.f_frsize * statvfs.f_blocks // 1024 // 1024 / 1024))
print("used %4.1fGB"% (statvfs.f_frsize * (statvfs.f_blocks - statvfs.f_bfree) // 1024 // 1024 / 1024)) print("used %4.1fGB" % (statvfs.f_frsize * (statvfs.f_blocks - statvfs.f_bfree) // 1024 // 1024 / 1024))
found = True found = True
loop += 1 loop += 1
else: else:

View file

@ -1,5 +1,4 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
import time import time
@ -11,4 +10,3 @@ os.system("convert -resize 1024x600 -background black -gravity center -extent 10
time.sleep(1) time.sleep(1)
os.system("convert -resize 1024x600 -background black -gravity center -extent 1024x600 image2.png bgra:/dev/fb0") os.system("convert -resize 1024x600 -background black -gravity center -extent 1024x600 image2.png bgra:/dev/fb0")
time.sleep(1) time.sleep(1)

View file

@ -1,17 +1,19 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os; import os
def waitMouseClick(): def waitMouseClick():
mouse = open( "/dev/input/mice", "rb" ) mouse = open("/dev/input/mice", "rb")
down = False; down = False
while True: while True:
buf = mouse.read(3) buf = mouse.read(3)
if ((buf[0] & 0x1)==1): if ((buf[0] & 0x1) == 1):
down = True down = True
if (((buf[0] & 0x1)==0) and down): if (((buf[0] & 0x1) == 0) and down):
break; break
mouse.close() mouse.close()
while True: while True:
os.system("killall fim") os.system("killall fim")
os.system("fim -qa image1.png 2>/dev/null &") os.system("fim -qa image1.png 2>/dev/null &")
@ -19,4 +21,3 @@ while True:
os.system("killall fim") os.system("killall fim")
os.system("fim -qa image2.png 2>/dev/null &") os.system("fim -qa image2.png 2>/dev/null &")
waitMouseClick() waitMouseClick()

View file

@ -1,15 +1,15 @@
#!/usr/bin/python3 #!/usr/bin/python3
def waitMouseClick(): def waitMouseClick():
mouse = open( "/dev/input/mice", "rb" ) mouse = open("/dev/input/mice", "rb")
down = False; down = False
while True: while True:
buf = mouse.read(3) buf = mouse.read(3)
if ((buf[0] & 0x1)==1): if ((buf[0] & 0x1) == 1):
down = True down = True
if (((buf[0] & 0x1)==0) and down): if (((buf[0] & 0x1) == 0) and down):
break; break
mouse.close() mouse.close()
waitMouseClick()
waitMouseClick()

View file

@ -14,8 +14,8 @@ def initBar():
def updateBar(progress): def updateBar(progress):
global progress_win global progress_win
pos = (60 * progress) // 100 pos = (60 * progress) // 100
if pos != 0 : if pos != 0:
progress_win.addstr(1, 1, "#" * pos) progress_win.addstr(1, 1, "#" * pos)
progress_win.refresh() progress_win.refresh()
@ -26,8 +26,5 @@ while loading <= 100:
time.sleep(0.03) time.sleep(0.03)
updateBar(loading) updateBar(loading)
loading += 3 loading += 3
time.sleep(1) time.sleep(1)
#curses.endwin()
curses.flushinp() curses.flushinp()

View file

@ -1,17 +1,19 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os; import os
def waitMouseClick(): def waitMouseClick():
mouse = open( "/dev/input/mice", "rb" ) mouse = open("/dev/input/mice", "rb")
down = False; down = False
while True: while True:
buf = mouse.read(3) buf = mouse.read(3)
if ((buf[0] & 0x1)==1): if ((buf[0] & 0x1) == 1):
down = True down = True
if (((buf[0] & 0x1)==0) and down): if (((buf[0] & 0x1) == 0) and down):
break; break
mouse.close() mouse.close()
os.system("fim *.png -qa -c 'while(1){display;sleep 1;next;}' </dev/null 2>/dev/null &") os.system("fim *.png -qa -c 'while(1){display;sleep 1;next;}' </dev/null 2>/dev/null &")
waitMouseClick() waitMouseClick()
os.system("killall -s 9 fim") os.system("killall -s 9 fim")

View file

@ -1,20 +1,20 @@
#!/usr/bin/python3 #!/usr/bin/python3
#
def waitMouseClick(): def waitMouseClick():
print("wait mouse click") print("wait mouse click")
mouse = open( "/dev/input/mice", "rb" ) mouse = open("/dev/input/mice", "rb")
down = False; down = False
while True: while True:
buf = mouse.read(3) buf = mouse.read(3)
if ((buf[0] & 0x1)==1): if ((buf[0] & 0x1) == 1):
down = True down = True
if (((buf[0] & 0x1)==0) and down): if (((buf[0] & 0x1) == 0) and down):
break; break
mouse.close() mouse.close()
def loop(state): def loop(state):
print('loop ' +state) print('loop ' + state)
match state: match state:
case "START": case "START":
waitMouseClick() waitMouseClick()
@ -26,16 +26,13 @@ def loop(state):
waitMouseClick() waitMouseClick()
return "STOP" return "STOP"
case _: case _:
print("Unknwn state "+state) print("Unknwn state " + state)
return "STOP" return "STOP"
print("end loop") print("end loop")
if __name__ == "__main__": if __name__ == "__main__":
# The client code. # The client code.
state = "START"
state="START" while (state != "STOP"):
while (state!="STOP"):
state = loop(state) state = loop(state)