Add config file

This commit is contained in:
AxelC
2019-06-12 21:32:31 +02:00
parent c4ac0ef30c
commit 3811e6ef90
5 changed files with 61 additions and 13 deletions

2
.gitignore vendored Normal file
View File

@@ -0,0 +1,2 @@
config.py
.idea/

View File

@@ -1,7 +1,14 @@
#
# MUSIC CARD
# Card management
#
import csv
import os.path
import sys
class CardList:
def __init__(self):
self.path = os.path.dirname(os.path.realpath(__file__))

View File

@@ -1,3 +1,9 @@
#
# MUSIC CARD
# Card Reader
#
import string
import csv
import os.path

43
box.py
View File

@@ -1,32 +1,49 @@
#!/usr/bin/env python
#from readtest import *
#
# MUSIC CARD
# Application
#
import re
from CardList import CardList
from Reader import Reader
import sys
import subprocess
import os
import time
from CardList import CardList
from Reader import Reader
import config as cfg # Get config from file
reader = Reader()
cardList = CardList()
#TODO Get from config file
addr = 'http://192.168.1.80:5005'
# Create address path
address = cfg.ip + ':' + cfg.port
# Create command line
if cfg.location == '':
# Command for global playing
commandLine = address + ' '
else:
# Command for local playing
commandLine = address + ' ' + cfg.location + '/'
print 'Ready: place a card on top of the reader'
while True:
card = reader.readCard()
try:
print 'Read card : ', card
plist = cardList.getPlaylist(card)
print 'Command : ', plist
if plist != '':
subprocess.check_call( ["./sonosplay.sh %s" % addr+' '+plist], shell=True)
# subprocess.check_call( ["./haplaylist.sh %s" % plist], shell=True)
range(10000) # some payload code
time.sleep(0.2) # sane sleep time of 0.1 seconds
print 'Read card : ', card
plist = cardList.getPlaylist(card)
print 'Command : ', plist
if plist != '':
subprocess.check_call(["./sonosplay.sh %s" % commandLine + plist], shell=True)
# subprocess.check_call( ["./haplaylist.sh %s" % plist], shell=True)
range(10000) # some payload code
time.sleep(0.2) # sane sleep time of 0.1 seconds
except OSError as e:
print "Execution failed:"
range(10000) # some payload code

16
config.sample Normal file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env python
#
# MUSIC CARD CONFIG
#
# Rename this file to config.py
#
ip = "192.168.1.80"
port = "5005"
# Room name designation
# If you want to play on all your speakers, set roomName = ""
roomName = "Hugo"
# roomName = "Salon"