Fixed bug where modulo functions returned float instead of int

This commit is contained in:
Jan
2019-09-26 20:44:02 +02:00
parent ce9a4837e1
commit eaaeadf642
2 changed files with 26 additions and 24 deletions

View File

@@ -81,7 +81,6 @@ brightness=0
snooze=0
count=0
print("")
print('My PID is %d' %os.getpid())
signal.signal(signal.SIGHUP, receive_signal)
signal.signal(signal.SIGINT, receive_signal)
@@ -94,10 +93,9 @@ but3=button.Button(26)
#------------------------------------------------------------------
while not stopprogram:
print("reload config...")
print("Load config...")
reload=False
# display=tm1637.TM1637(CLK=14, DIO=4, brightness=1)
display=max7219.MAX7219(brightness=1)
@@ -107,18 +105,12 @@ while not stopprogram:
print("reading mp3s from directory:")
tracks=clockytracklist.ClockyTracklist("mp3",recursive=True,verbose=True)
allmp3s=tracks.tracklist
if allmp3s==0:
print("ERROR: No mp3's found!")
display.showclock(" E rr")
sleep(30)
sys.exit()
c=0
for m in allmp3s:
print(" %2d : %s"%(c+1,m))
c+=1
stamp()
print("Started")
sys.stdout.flush()
@@ -143,8 +135,8 @@ while not stopprogram:
settings = pickle.load(handle)
handle.close()
a_mins=settings['alarmtime']%60
a_hour=(settings['alarmtime']-a_mins)/60
a_mins=int(settings['alarmtime']%60)
a_hour=int((settings['alarmtime']-a_mins)/60)
print("Alarmtime : %02d:%02d"%(a_hour,a_mins))
print("Alarmdisable: %d"%(settings['alarmdisabled']))
print("Starttrack : %d"%(settings['starttrack']))
@@ -236,8 +228,8 @@ while not stopprogram:
if looptype==1: # show alarmtime
if not settings["alarmdisabled"]==1:
a_mins=settings['alarmtime']%60
a_hour=(settings['alarmtime']-a_mins)/60
a_mins=int(settings['alarmtime']%60)
a_hour=int((settings['alarmtime']-a_mins)/60)
if colon:
tim="%02d:%02d" % (a_hour, a_mins)
@@ -264,11 +256,12 @@ while not stopprogram:
if looptype==2: # edit alarmtime
delta=0
sm=settings['alarmtime']%10
dm=((settings['alarmtime']-sm)/10)%6
sh=(settings['alarmtime']-dm)/60%10
dh=(settings['alarmtime']-sh)/600
sm=int(settings['alarmtime']%10)
dm=int(((settings['alarmtime']-sm)/10)%6)
sh=int((settings['alarmtime']-dm)/60%10)
dh=int((settings['alarmtime']-sh)/600)
if colon:
tim="%0d%0d:%0d%0d" % (dh,sh,dm,sm)
@@ -376,8 +369,8 @@ while not stopprogram:
soundpreview=1
tr=track
tl=settings["track%d"%tr]%10
th=(settings["track%d"%tr]-tl)/10
tl=int(settings["track%d"%tr]%10)
th=int((settings["track%d"%tr]-tl)/10)
if colon:
tim="%d=:%d%d" % (tr,th,tl)
@@ -418,8 +411,8 @@ while not stopprogram:
delta=0
tr=track
tl=settings["track%d"%tr]%10
th=(settings["track%d"%tr]-tl)/10
tl=int(settings["track%d"%tr]%10)
th=int((settings["track%d"%tr]-tl)/10)
if colon:
tim="%d=:%d%d" % (tr,th,tl)

View File

@@ -13,13 +13,22 @@ class ClockyTracklist:
self.__verbose=verbose
self.__sort=sort
self.__reloaded=False
self.supportedformats=EXTENSIONS
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")
exit();
self.__ReadTrackList()
if self.count==0:
print("ERROR: no (supported) files found in directory \""+path+"\"")
exit();
if(self.__verbose):
self.ShowTrackList()