52 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
			
		
		
	
	
			52 lines
		
	
	
		
			1.7 KiB
		
	
	
	
		
			Python
		
	
	
	
	
	
| from subprocess import call # We can do BASH in Python if needed.
 | |
| import os # Lots of system stuff
 | |
| from shutil import copyfile # Allow copying of files
 | |
| import glob # Import glob tools for file listings.
 | |
| import notify2 # Notification utility.
 | |
| import time # Import time into the galaxy
 | |
| 
 | |
| #time.sleep(10) # Wait 10 seconds.
 | |
| os.chdir("/home/josh/Downloads/Downloads") #/home/berean/sermons/2018
 | |
| list = sorted(glob.glob('*.mp3'))
 | |
| mostrecent = list[-1]
 | |
| secondrecent = list[-2]
 | |
| 
 | |
| #sermoncopy = "/mnt/52265C99265C8041/Users/Berean-Sound/sermons/" + mostrecent
 | |
| 
 | |
| sermonsrc = "/home/josh/Downloads/Downloads/" + mostrecent
 | |
| sermondst = "/home/josh/Downloads/" + mostrecent # /home/berean/sermons/2018/
 | |
| 
 | |
| copyfile(sermonsrc, sermondst)
 | |
| 
 | |
| #call('rsync --update --progress -e "ssh -i /home/berean/sermons/.tempssh/temp" *.mp3 sermons@bereanbibleutah.org:/home/josh/sermons/2018/')
 | |
| 
 | |
| #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)
 | |
| 
 | |
| # if mostrecent == recentsermon:
 | |
| #
 | |
| #     notify2.init('Sermon Script')
 | |
| #     n = notify2.Notification("Sermon Uploaded",
 | |
| #          mostrecent #(var + " and " + secondrecent) #,
 | |
| #         # "notification-message-im"   # Icon name
 | |
| #         )
 | |
| #     n.show()
 | |
| 
 | |
| # else:
 | |
| #     notify2.init('Sermon Script')
 | |
| #     n = notify2.Notification("Sermon Upload Failed",
 | |
| #          mostrecent #(var + " and " + secondrecent) #,
 | |
| #         # "notification-message-im"   # Icon name
 | |
| #         )
 | |
| #     n.show()
 | |
| 
 | |
| # IFS=$'\n'
 | |
| # recentsermon=$(echo "${sermons[*]}" | sort -nr) #| head -n2)
 | |
| # echo $recentsermon
 | |
| 
 | |
| #cd ..
 | |
| #cd 2016
 | |
| #rsync --progress -e "ssh -i ../.tempssh/temp" *.mp3 sermons@bereanbibleutah.org:/home/josh/sermons/2016/
 |