Fixed bug where modulo functions returned float instead of int
This commit is contained in:
39
clocky.py
39
clocky.py
@@ -81,7 +81,6 @@ brightness=0
|
|||||||
snooze=0
|
snooze=0
|
||||||
count=0
|
count=0
|
||||||
|
|
||||||
print("")
|
|
||||||
print('My PID is %d' %os.getpid())
|
print('My PID is %d' %os.getpid())
|
||||||
signal.signal(signal.SIGHUP, receive_signal)
|
signal.signal(signal.SIGHUP, receive_signal)
|
||||||
signal.signal(signal.SIGINT, receive_signal)
|
signal.signal(signal.SIGINT, receive_signal)
|
||||||
@@ -94,10 +93,9 @@ but3=button.Button(26)
|
|||||||
#------------------------------------------------------------------
|
#------------------------------------------------------------------
|
||||||
|
|
||||||
while not stopprogram:
|
while not stopprogram:
|
||||||
print("reload config...")
|
print("Load config...")
|
||||||
reload=False
|
reload=False
|
||||||
|
|
||||||
|
|
||||||
# display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
|
# display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
|
||||||
display=max7219.MAX7219(brightness=1)
|
display=max7219.MAX7219(brightness=1)
|
||||||
|
|
||||||
@@ -107,18 +105,12 @@ while not stopprogram:
|
|||||||
print("reading mp3s from directory:")
|
print("reading mp3s from directory:")
|
||||||
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=True)
|
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=True)
|
||||||
allmp3s=tracks.tracklist
|
allmp3s=tracks.tracklist
|
||||||
if allmp3s==0:
|
|
||||||
print("ERROR: No mp3's found!")
|
|
||||||
display.showclock(" E rr")
|
|
||||||
sleep(30)
|
|
||||||
sys.exit()
|
|
||||||
|
|
||||||
c=0
|
c=0
|
||||||
for m in allmp3s:
|
for m in allmp3s:
|
||||||
print(" %2d : %s"%(c+1,m))
|
print(" %2d : %s"%(c+1,m))
|
||||||
c+=1
|
c+=1
|
||||||
|
|
||||||
|
|
||||||
stamp()
|
stamp()
|
||||||
print("Started")
|
print("Started")
|
||||||
sys.stdout.flush()
|
sys.stdout.flush()
|
||||||
@@ -143,8 +135,8 @@ while not stopprogram:
|
|||||||
settings = pickle.load(handle)
|
settings = pickle.load(handle)
|
||||||
handle.close()
|
handle.close()
|
||||||
|
|
||||||
a_mins=settings['alarmtime']%60
|
a_mins=int(settings['alarmtime']%60)
|
||||||
a_hour=(settings['alarmtime']-a_mins)/60
|
a_hour=int((settings['alarmtime']-a_mins)/60)
|
||||||
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
|
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
|
||||||
print("Alarmdisable: %d"%(settings['alarmdisabled']))
|
print("Alarmdisable: %d"%(settings['alarmdisabled']))
|
||||||
print("Starttrack : %d"%(settings['starttrack']))
|
print("Starttrack : %d"%(settings['starttrack']))
|
||||||
@@ -236,8 +228,8 @@ while not stopprogram:
|
|||||||
|
|
||||||
if looptype==1: # show alarmtime
|
if looptype==1: # show alarmtime
|
||||||
if not settings["alarmdisabled"]==1:
|
if not settings["alarmdisabled"]==1:
|
||||||
a_mins=settings['alarmtime']%60
|
a_mins=int(settings['alarmtime']%60)
|
||||||
a_hour=(settings['alarmtime']-a_mins)/60
|
a_hour=int((settings['alarmtime']-a_mins)/60)
|
||||||
|
|
||||||
if colon:
|
if colon:
|
||||||
tim="%02d:%02d" % (a_hour, a_mins)
|
tim="%02d:%02d" % (a_hour, a_mins)
|
||||||
@@ -264,11 +256,12 @@ while not stopprogram:
|
|||||||
|
|
||||||
if looptype==2: # edit alarmtime
|
if looptype==2: # edit alarmtime
|
||||||
|
|
||||||
|
|
||||||
delta=0
|
delta=0
|
||||||
sm=settings['alarmtime']%10
|
sm=int(settings['alarmtime']%10)
|
||||||
dm=((settings['alarmtime']-sm)/10)%6
|
dm=int(((settings['alarmtime']-sm)/10)%6)
|
||||||
sh=(settings['alarmtime']-dm)/60%10
|
sh=int((settings['alarmtime']-dm)/60%10)
|
||||||
dh=(settings['alarmtime']-sh)/600
|
dh=int((settings['alarmtime']-sh)/600)
|
||||||
|
|
||||||
if colon:
|
if colon:
|
||||||
tim="%0d%0d:%0d%0d" % (dh,sh,dm,sm)
|
tim="%0d%0d:%0d%0d" % (dh,sh,dm,sm)
|
||||||
@@ -376,8 +369,8 @@ while not stopprogram:
|
|||||||
soundpreview=1
|
soundpreview=1
|
||||||
|
|
||||||
tr=track
|
tr=track
|
||||||
tl=settings["track%d"%tr]%10
|
tl=int(settings["track%d"%tr]%10)
|
||||||
th=(settings["track%d"%tr]-tl)/10
|
th=int((settings["track%d"%tr]-tl)/10)
|
||||||
|
|
||||||
if colon:
|
if colon:
|
||||||
tim="%d=:%d%d" % (tr,th,tl)
|
tim="%d=:%d%d" % (tr,th,tl)
|
||||||
@@ -418,8 +411,8 @@ while not stopprogram:
|
|||||||
|
|
||||||
delta=0
|
delta=0
|
||||||
tr=track
|
tr=track
|
||||||
tl=settings["track%d"%tr]%10
|
tl=int(settings["track%d"%tr]%10)
|
||||||
th=(settings["track%d"%tr]-tl)/10
|
th=int((settings["track%d"%tr]-tl)/10)
|
||||||
|
|
||||||
if colon:
|
if colon:
|
||||||
tim="%d=:%d%d" % (tr,th,tl)
|
tim="%d=:%d%d" % (tr,th,tl)
|
||||||
|
|||||||
@@ -13,13 +13,22 @@ class ClockyTracklist:
|
|||||||
self.__verbose=verbose
|
self.__verbose=verbose
|
||||||
self.__sort=sort
|
self.__sort=sort
|
||||||
self.__reloaded=False
|
self.__reloaded=False
|
||||||
|
self.supportedformats=EXTENSIONS
|
||||||
|
|
||||||
p=Path(self.path)
|
p=Path(self.path)
|
||||||
if(not p.is_dir()):
|
if not p.exists():
|
||||||
|
print("ERROR: directory \""+path+"\" does not exist")
|
||||||
|
exit();
|
||||||
|
if not p.is_dir():
|
||||||
print("ERROR: \""+path+"\" is not an directory")
|
print("ERROR: \""+path+"\" is not an directory")
|
||||||
exit();
|
exit();
|
||||||
|
|
||||||
self.__ReadTrackList()
|
self.__ReadTrackList()
|
||||||
|
|
||||||
|
if self.count==0:
|
||||||
|
print("ERROR: no (supported) files found in directory \""+path+"\"")
|
||||||
|
exit();
|
||||||
|
|
||||||
if(self.__verbose):
|
if(self.__verbose):
|
||||||
self.ShowTrackList()
|
self.ShowTrackList()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user