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():
|
def checkPhone():
|
||||||
|
|
||||||
response = os.system("ping -c 1 -w5 " + os.environ['PHONEIP'] + " > /dev/null 2>&1")
|
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:
|
if response == 0:
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
network = networkclass.network(userclass.User())
|
|
||||||
|
|
||||||
found = False
|
try:
|
||||||
|
|
||||||
for i in range(0, 36):
|
network = networkclass.network(userclass.User())
|
||||||
if checkPhone():
|
|
||||||
found = True
|
|
||||||
break
|
|
||||||
|
|
||||||
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)
|
playlisturi = next((i.uri for i in playlists if i.name == date.strftime("%B %-y").lower()), os.environ['SPOTALARMURI'])
|
||||||
network.setVolume(os.environ['SPOTALARMVOLUME'])
|
|
||||||
network.next()
|
|
||||||
|
|
||||||
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()
|
||||||
|
35
backup.py
35
backup.py
@ -9,22 +9,27 @@ import os
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
network = networkclass.network(userclass.User())
|
try:
|
||||||
playlists = network.getUserPlaylists()
|
|
||||||
|
|
||||||
for playlist in playlists:
|
network = networkclass.network(userclass.User())
|
||||||
playlist.tracks = network.getPlaylistTracks(playlist.playlistid)
|
playlists = network.getUserPlaylists()
|
||||||
|
|
||||||
path = sys.argv[1]
|
|
||||||
|
|
||||||
datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/')
|
|
||||||
|
|
||||||
totalpath = os.path.join(path, datepath)
|
for playlist in playlists:
|
||||||
pathdir = os.path.dirname(totalpath)
|
playlist.tracks = network.getPlaylistTracks(playlist.playlistid)
|
||||||
if not os.path.exists(totalpath):
|
|
||||||
os.makedirs(totalpath)
|
|
||||||
|
|
||||||
for play in playlists:
|
path = sys.argv[1]
|
||||||
csvwrite.exportPlaylist(play, totalpath)
|
|
||||||
|
|
||||||
log.dumpLog()
|
datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/')
|
||||||
|
|
||||||
|
totalpath = os.path.join(path, datepath)
|
||||||
|
pathdir = os.path.dirname(totalpath)
|
||||||
|
if not os.path.exists(totalpath):
|
||||||
|
os.makedirs(totalpath)
|
||||||
|
|
||||||
|
for play in playlists:
|
||||||
|
csvwrite.exportPlaylist(play, totalpath)
|
||||||
|
|
||||||
|
log.dumpLog()
|
||||||
|
|
||||||
|
except:
|
||||||
|
log.dumpLog()
|
||||||
|
Loading…
Reference in New Issue
Block a user