added dumping logs on error
This commit is contained in:
parent
2046dda356
commit
fa7748b0ae
38
alarm.py
38
alarm.py
@ -8,34 +8,40 @@ import datetime
|
||||
def checkPhone():
|
||||
|
||||
response = os.system("ping -c 1 -w5 " + os.environ['PHONEIP'] + " > /dev/null 2>&1")
|
||||
print('checking for phone')
|
||||
log.log('checking for phone')
|
||||
if response == 0:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
network = networkclass.network(userclass.User())
|
||||
|
||||
found = False
|
||||
try:
|
||||
|
||||
for i in range(0, 36):
|
||||
if checkPhone():
|
||||
found = True
|
||||
break
|
||||
network = networkclass.network(userclass.User())
|
||||
|
||||
if found:
|
||||
found = False
|
||||
|
||||
date = datetime.datetime.now()
|
||||
for i in range(0, 36):
|
||||
if checkPhone():
|
||||
found = True
|
||||
break
|
||||
|
||||
playlists = network.getUserPlaylists()
|
||||
if found:
|
||||
|
||||
playlisturi = next((i.uri for i in playlists if i.name == date.strftime("%B %-y").lower()), os.environ['SPOTALARMURI'])
|
||||
date = datetime.datetime.now()
|
||||
|
||||
network.play(playlisturi, network.getDeviceID(os.environ['SPOTALARMDEVICENAME']))
|
||||
playlists = network.getUserPlaylists()
|
||||
|
||||
network.setShuffle(True)
|
||||
network.setVolume(os.environ['SPOTALARMVOLUME'])
|
||||
network.next()
|
||||
playlisturi = next((i.uri for i in playlists if i.name == date.strftime("%B %-y").lower()), os.environ['SPOTALARMURI'])
|
||||
|
||||
log.dumpLog()
|
||||
network.play(playlisturi, network.getDeviceID(os.environ['SPOTALARMDEVICENAME']))
|
||||
|
||||
network.setShuffle(True)
|
||||
network.setVolume(os.environ['SPOTALARMVOLUME'])
|
||||
network.next()
|
||||
|
||||
log.dumpLog()
|
||||
|
||||
except:
|
||||
log.dumpLog()
|
||||
|
31
backup.py
31
backup.py
@ -9,22 +9,27 @@ import os
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
network = networkclass.network(userclass.User())
|
||||
playlists = network.getUserPlaylists()
|
||||
try:
|
||||
|
||||
for playlist in playlists:
|
||||
playlist.tracks = network.getPlaylistTracks(playlist.playlistid)
|
||||
network = networkclass.network(userclass.User())
|
||||
playlists = network.getUserPlaylists()
|
||||
|
||||
path = sys.argv[1]
|
||||
for playlist in playlists:
|
||||
playlist.tracks = network.getPlaylistTracks(playlist.playlistid)
|
||||
|
||||
datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/')
|
||||
path = sys.argv[1]
|
||||
|
||||
totalpath = os.path.join(path, datepath)
|
||||
pathdir = os.path.dirname(totalpath)
|
||||
if not os.path.exists(totalpath):
|
||||
os.makedirs(totalpath)
|
||||
datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/')
|
||||
|
||||
for play in playlists:
|
||||
csvwrite.exportPlaylist(play, totalpath)
|
||||
totalpath = os.path.join(path, datepath)
|
||||
pathdir = os.path.dirname(totalpath)
|
||||
if not os.path.exists(totalpath):
|
||||
os.makedirs(totalpath)
|
||||
|
||||
log.dumpLog()
|
||||
for play in playlists:
|
||||
csvwrite.exportPlaylist(play, totalpath)
|
||||
|
||||
log.dumpLog()
|
||||
|
||||
except:
|
||||
log.dumpLog()
|
||||
|
Loading…
Reference in New Issue
Block a user