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()
|
||||
|
35
backup.py
35
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)
|
||||
|
||||
path = sys.argv[1]
|
||||
|
||||
datepath = str(datetime.datetime.now()).split(' ')[0].replace('-', '/')
|
||||
network = networkclass.network(userclass.User())
|
||||
playlists = network.getUserPlaylists()
|
||||
|
||||
totalpath = os.path.join(path, datepath)
|
||||
pathdir = os.path.dirname(totalpath)
|
||||
if not os.path.exists(totalpath):
|
||||
os.makedirs(totalpath)
|
||||
for playlist in playlists:
|
||||
playlist.tracks = network.getPlaylistTracks(playlist.playlistid)
|
||||
|
||||
for play in playlists:
|
||||
csvwrite.exportPlaylist(play, totalpath)
|
||||
path = sys.argv[1]
|
||||
|
||||
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