Check for most recent upload and warn user if the sermon did not upload.
This commit is contained in:
parent
697a5c5f0f
commit
cef16b6ffa
|
@ -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()
|
||||||
|
|
||||||
|
else: # Otherwise, something went wrong.
|
||||||
|
|
||||||
|
notify2.init('Sermon Script')
|
||||||
|
n = notify2.Notification("Sermon Upload Failed",
|
||||||
|
mostrecent
|
||||||
)
|
)
|
||||||
n.show()
|
n.show()
|
||||||
|
|
||||||
# else:
|
|
||||||
# notify2.init('Sermon Script')
|
|
||||||
# n = notify2.Notification("Sermon Upload Failed",
|
|
||||||
# mostrecent #(var + " and " + secondrecent) #,
|
|
||||||
# # "notification-message-im" # Icon name
|
|
||||||
# )
|
|
||||||
# n.show()
|
|
||||||
|
|
Loading…
Reference in New Issue