Check for most recent upload and warn user if the sermon did not upload.

This commit is contained in:
Josh Mudge 2018-10-06 11:48:39 -06:00
parent 697a5c5f0f
commit cef16b6ffa
1 changed files with 29 additions and 29 deletions

View File

@ -1,4 +1,4 @@
# Sermon Upload v1.0 # Sermon Upload v1.1 Alpha
from subprocess import call # We can do BASH in Python if needed. from subprocess import call # We can do BASH in Python if needed.
import os # Lots of system stuff import os # Lots of system stuff
@ -8,37 +8,37 @@ import notify2 # Notification utility.
import time # Import time into the galaxy import time # Import time into the galaxy
time.sleep(10) # Wait 10 seconds. time.sleep(10) # Wait 10 seconds.
os.chdir("/mnt/52265C99265C8041/Users/Berean-Sound/sermons") # os.chdir("/mnt/52265C99265C8041/Users/Berean-Sound/sermons") # Go to sermon directory.
list = sorted(glob.glob('*.mp3')) list = sorted(glob.glob('*.mp3')) # Sort files alphabetically.
mostrecent = list[-1] mostrecent = list[-1] # Find most recent sermon
secondrecent = list[-2] secondrecent = list[-2] # Find second most recent sermon
sermonsrc = "/mnt/52265C99265C8041/Users/Berean-Sound/sermons/" + mostrecent sermonsrc = "/mnt/52265C99265C8041/Users/Berean-Sound/sermons/" + mostrecent # Grab the most recent sermon to copy.
sermondst = "/home/berean/sermons/2018/" + mostrecent # /home/berean/sermons/2018/ sermondst = "/home/berean/sermons/2018/" + mostrecent # Destination for most recent sermon.
copyfile(sermonsrc, sermondst) copyfile(sermonsrc, sermondst) # Copy the sermon
os.chdir("/home/berean/sermons/2018/") os.chdir("/home/berean/sermons/2018/") # Go to the directory where the sermon has been copied to
os.system("rsync --update --progress -e 'ssh -i /home/berean/sermons/.tempssh/temp' *.mp3 sermons@bereanbibleutah.org:/home/josh/sermons/2018/") os.system("rsync --update --progress -e 'ssh -i /home/berean/sermons/.tempssh/temp' *.mp3 sermons@bereanbibleutah.org:/home/josh/sermons/2018/") # Upload the sermon.
#call(sermons=$("ssh -i /home/berean/sermons/.tempssh/temp sermons@bereanbibleutah.org 'ls /home/josh/sermons/2018'") call(sermons=$("ssh -i /home/berean/sermons/.tempssh/temp sermons@bereanbibleutah.org 'ls /home/josh/sermons/2018'") # Grab a list of uploaded sermons.
#recentsermon = call("$(echo hi)") call("export sermons") # Export the list to Python
#recentsermon = call("echo $sermons") recentsermon = os.environ["sermons"] # Set it to a variable
#print(recentsermon) recentsermon = recentsermon[-1] # Try to grab most recent sermon.
print(recentsermon) # Print most recent sermon.
# if mostrecent == recentsermon: if mostrecent == recentsermon: # If the most recent sermon uploaded matches the most recent sermon locally, we're good.
#
notify2.init('Sermon Script') notify2.init('Sermon Script')
n = notify2.Notification("Sermon Uploaded", # NOTE TO SELF: Add validation. n = notify2.Notification("Sermon Uploaded",
mostrecent #(var + " and " + secondrecent) #, mostrecent
# "notification-message-im" # Icon name
) )
n.show() n.show()
# else: else: # Otherwise, something went wrong.
# notify2.init('Sermon Script')
# n = notify2.Notification("Sermon Upload Failed", notify2.init('Sermon Script')
# mostrecent #(var + " and " + secondrecent) #, n = notify2.Notification("Sermon Upload Failed",
# # "notification-message-im" # Icon name mostrecent
# ) )
# n.show() n.show()