Add Sermon Upload and README

This commit is contained in:
Josh Mudge 2018-09-29 19:06:38 -06:00
parent 74275e823f
commit be8736587f
6 changed files with 84 additions and 1 deletions

7
README.md Normal file
View File

@ -0,0 +1,7 @@
# Python Scripts
These are an assortment of my Python scripts, most of them while following "Python The Hard Way", some while not.
The most interesting (in my opinion) are [The Python Caeser Cipher Helper](src/branch/master/Caeser-Cipher), [The Dots of Death (Use with caution)](src/branch/master/ex7-dots.py) and the latest is a work in progress: [Sermon-Upload](src/branch/master/Sermon-Upload)
You can also find out if you're a giant here (Read the comments): [Short and Tall](src/branch/master/ex11_Fun.py)

3
Sermon-Upload/README.md Normal file
View File

@ -0,0 +1,3 @@
# Sermon Upload
Finds latest sermon, uploads it, notifies the user. Sounds simple, it isn't.

View File

@ -0,0 +1,51 @@
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/

View File

@ -0,0 +1,16 @@
cd /home/berean/sermons/2018
sermons=$(ls /mnt/52265C99265C8041/Users/Berean-Sound/sermons)
IFS=$'\n'
lastsermon=$(echo "${sermons[*]}" | sort -nr | head -n1)
cp /mnt/52265C99265C8041/Users/Berean-Sound/sermons/$lastsermon .
rsync --update --progress -e "ssh -i /home/berean/sermons/.tempssh/temp" *.mp3 sermons@bereanbibleutah.org:/home/josh/sermons/2018/
sermons=$(ssh -i /home/berean/sermons/.tempssh/temp sermons@bereanbibleutah.org 'ls /home/josh/sermons/2018')
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/

View File

@ -1,4 +1,4 @@
# I had some fun with this one. # I had some fun with this one. If someone enters ' instead of '' for inches it will proclaim their immense height.
shortInches = False # set shortInches to False shortInches = False # set shortInches to False

6
install-dbus-python.sh Normal file
View File

@ -0,0 +1,6 @@
#!/bin/bash
# Enable posibility of notificaions in Python, assumes you have pip
pip install notify2
sudo apt-get install libgtk2.0-dev libdbus-1-dev
pip install dbus-python