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. | ||||
| import os # Lots of system stuff | ||||
| @ -8,37 +8,37 @@ import notify2 # Notification utility. | ||||
| import time # Import time into the galaxy | ||||
| 
 | ||||
| time.sleep(10) # Wait 10 seconds. | ||||
| os.chdir("/mnt/52265C99265C8041/Users/Berean-Sound/sermons") # | ||||
| list = sorted(glob.glob('*.mp3')) | ||||
| mostrecent = list[-1] | ||||
| secondrecent = list[-2] | ||||
| os.chdir("/mnt/52265C99265C8041/Users/Berean-Sound/sermons") # Go to sermon directory. | ||||
| list = sorted(glob.glob('*.mp3')) # Sort files alphabetically. | ||||
| mostrecent = list[-1] # Find most recent sermon | ||||
| secondrecent = list[-2] # Find second most recent sermon | ||||
| 
 | ||||
| sermonsrc = "/mnt/52265C99265C8041/Users/Berean-Sound/sermons/" + mostrecent | ||||
| sermondst = "/home/berean/sermons/2018/" + mostrecent # /home/berean/sermons/2018/ | ||||
| sermonsrc = "/mnt/52265C99265C8041/Users/Berean-Sound/sermons/" + mostrecent # Grab the most recent sermon to copy. | ||||
| 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.system("rsync --update --progress -e 'ssh -i /home/berean/sermons/.tempssh/temp' *.mp3 sermons@bereanbibleutah.org:/home/josh/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/") # Upload the sermon. | ||||
| 
 | ||||
| #call(sermons=$("ssh -i /home/berean/sermons/.tempssh/temp sermons@bereanbibleutah.org 'ls /home/josh/sermons/2018'") | ||||
| #recentsermon = call("$(echo hi)") | ||||
| #recentsermon = call("echo $sermons") | ||||
| #print(recentsermon) | ||||
| call(sermons=$("ssh -i /home/berean/sermons/.tempssh/temp sermons@bereanbibleutah.org 'ls /home/josh/sermons/2018'") # Grab a list of uploaded sermons. | ||||
| call("export sermons") # Export the list to Python | ||||
| recentsermon = os.environ["sermons"] # Set it to a variable | ||||
| recentsermon = recentsermon[-1] # Try to grab most recent sermon. | ||||
| print(recentsermon) # Print most recent sermon. | ||||
| 
 | ||||
| if mostrecent == recentsermon: # If the most recent sermon uploaded matches the most recent sermon locally, we're good. | ||||
| 
 | ||||
| # if mostrecent == recentsermon: | ||||
| # | ||||
|     notify2.init('Sermon Script') | ||||
| n = notify2.Notification("Sermon Uploaded", # NOTE TO SELF: Add validation. | ||||
|      mostrecent #(var + " and " + secondrecent) #, | ||||
|          # "notification-message-im"   # Icon name | ||||
|     n = notify2.Notification("Sermon Uploaded", | ||||
|          mostrecent | ||||
|              ) | ||||
|     n.show() | ||||
| 
 | ||||
| # else: | ||||
| #     notify2.init('Sermon Script') | ||||
| #     n = notify2.Notification("Sermon Upload Failed", | ||||
| #          mostrecent #(var + " and " + secondrecent) #, | ||||
| #         # "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() | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user