mirror of
https://github.com/acatoire/bipbipzizik.git
synced 2026-03-10 08:01:18 +00:00
Implement windows/linux import, now the app run on windows using keyboard, that's easier for debug!
This commit is contained in:
12
box.py
12
box.py
@@ -10,8 +10,16 @@ from time import time, sleep
|
||||
|
||||
# Bipbipzizic import
|
||||
from card_launcher import CardLauncher
|
||||
from modules.rfid_reader.linux_reader import Reader
|
||||
from modules.tools import get_serial
|
||||
from sys import platform
|
||||
|
||||
if platform == "linux" or platform == "linux2" or platform == "darwin":
|
||||
# linux or OS X
|
||||
from modules.tools import get_linux_serial as get_serial
|
||||
from modules.rfid_reader.linux_reader import Reader
|
||||
elif platform == "win32":
|
||||
# Windows
|
||||
from modules.tools import get_win_serial as get_serial
|
||||
from modules.rfid_reader.windows_reader import Reader
|
||||
|
||||
# Constants
|
||||
UPDATE_PERIOD = 60
|
||||
|
||||
@@ -23,7 +23,7 @@ DATABASE.write_card(user="user",
|
||||
DATABASE.write_card(user="axel",
|
||||
name="Play/Pause",
|
||||
comment="",
|
||||
ids="0013397903",
|
||||
ids="0013397903,1",
|
||||
mode="none",
|
||||
action="command",
|
||||
data="playpause")
|
||||
|
||||
@@ -23,18 +23,18 @@ DATABASE.write_config(
|
||||
|
||||
|
||||
DATABASE.write_config(
|
||||
app_name="Main house sonos",
|
||||
app_name="Main house sonos (black72)",
|
||||
app_owner="axel",
|
||||
app_id="000000008e3c2b91",
|
||||
sonos_server_ip="192.168.1.80",
|
||||
sonos_server_port="5005",
|
||||
room_name="Salon 3",
|
||||
room_name="Salon",
|
||||
multi_read_mode="cancel",
|
||||
card_timeout="30")
|
||||
|
||||
|
||||
DATABASE.write_config(
|
||||
app_name="Hugo's sonos",
|
||||
app_name="Hugo's (orange71)",
|
||||
app_owner="axel",
|
||||
app_id="00000000deec2469",
|
||||
sonos_server_ip="192.168.1.80",
|
||||
@@ -43,8 +43,19 @@ DATABASE.write_config(
|
||||
multi_read_mode="cancel",
|
||||
card_timeout="30")
|
||||
|
||||
|
||||
DATABASE.write_config(
|
||||
app_name="Bertrand",
|
||||
app_name="Debug (naked74)",
|
||||
app_owner="axel",
|
||||
app_id="00000000bad90242",
|
||||
sonos_server_ip="192.168.1.80",
|
||||
sonos_server_port="5005",
|
||||
room_name="Billard",
|
||||
multi_read_mode="cancel",
|
||||
card_timeout="5")
|
||||
|
||||
DATABASE.write_config(
|
||||
app_name="Bertrand (nano)",
|
||||
app_owner="bertrand",
|
||||
app_id="0000000036c8d22e",
|
||||
sonos_server_ip="192.168.1.80",
|
||||
|
||||
@@ -67,7 +67,7 @@ class DbReader:
|
||||
"""
|
||||
|
||||
for _, card in self.cards_db_python.items():
|
||||
if card_id in card.get("ids"):
|
||||
if card_id in card.get("ids").split(","):
|
||||
return Card(card)
|
||||
|
||||
# Card not found, return None
|
||||
|
||||
@@ -22,6 +22,10 @@ for dev in DEVICES_LIST:
|
||||
|
||||
DEVICE_ID = int(input('Device Number: '))
|
||||
|
||||
with open(FILE_PATH, 'w') as f:
|
||||
f.write(DEVICES_LIST[DEVICE_ID].name)
|
||||
f.close()
|
||||
with open(FILE_PATH, 'w') as file_handler:
|
||||
file_handler.write(DEVICES_LIST[DEVICE_ID].name)
|
||||
# FIXME, doesn't save the file
|
||||
file_handler.close()
|
||||
|
||||
print("Device name saved in: " + FILE_PATH)
|
||||
|
||||
|
||||
33
modules/rfid_reader/windows_reader.py
Normal file
33
modules/rfid_reader/windows_reader.py
Normal file
@@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
"""
|
||||
MUSIC CARD
|
||||
Card Reader
|
||||
"""
|
||||
|
||||
import os.path
|
||||
import sys
|
||||
|
||||
from select import select
|
||||
|
||||
|
||||
class Reader:
|
||||
"""
|
||||
Reader class to handle card read on linux
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def read_card():
|
||||
"""
|
||||
Function to read the cards.
|
||||
It concatenate all characters until finding 'KEY_ENTER'
|
||||
The final word is returned
|
||||
:return: card key as string
|
||||
"""
|
||||
|
||||
keys_input = input('Card id: ')
|
||||
|
||||
if not keys_input:
|
||||
keys_input = "error"
|
||||
|
||||
return keys_input
|
||||
@@ -4,6 +4,7 @@ Module containing useful tools
|
||||
|
||||
# pylint: disable=import-outside-toplevel
|
||||
|
||||
|
||||
def print_my_path():
|
||||
"""
|
||||
For debug purpose, print path
|
||||
@@ -15,7 +16,7 @@ def print_my_path():
|
||||
print('DEBUG: abspath: {}'.format(path.abspath(__file__)))
|
||||
|
||||
|
||||
def get_serial() -> str:
|
||||
def get_linux_serial() -> str:
|
||||
"""
|
||||
Extract serial from raspberry pi cpuinfo file
|
||||
:return: serial as string
|
||||
@@ -30,3 +31,15 @@ def get_serial() -> str:
|
||||
serial = "ERROR00000000000"
|
||||
|
||||
return serial
|
||||
|
||||
|
||||
def get_win_serial() -> str:
|
||||
"""
|
||||
Extract serial from windows pc
|
||||
TODO not doing anything for now, for test purpose allowing to run on personal computer.
|
||||
:return: serial as string
|
||||
"""
|
||||
# serial = "000000TEST000000"
|
||||
serial = "000000008e3c2b91"
|
||||
|
||||
return serial
|
||||
|
||||
Reference in New Issue
Block a user