diff --git a/README.md b/README.md new file mode 100644 index 0000000..006f62c --- /dev/null +++ b/README.md @@ -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) diff --git a/Sermon-Upload/README.md b/Sermon-Upload/README.md new file mode 100644 index 0000000..8de8836 --- /dev/null +++ b/Sermon-Upload/README.md @@ -0,0 +1,3 @@ +# Sermon Upload + +Finds latest sermon, uploads it, notifies the user. Sounds simple, it isn't. diff --git a/Sermon-Upload/sermon-upload.py b/Sermon-Upload/sermon-upload.py new file mode 100644 index 0000000..e215f83 --- /dev/null +++ b/Sermon-Upload/sermon-upload.py @@ -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/ diff --git a/Sermon-Upload/sermon-upload.sh b/Sermon-Upload/sermon-upload.sh new file mode 100644 index 0000000..4ec2406 --- /dev/null +++ b/Sermon-Upload/sermon-upload.sh @@ -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/ diff --git a/ex11_Fun.py b/ex11_Fun.py index f750697..48572ab 100644 --- a/ex11_Fun.py +++ b/ex11_Fun.py @@ -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 diff --git a/install-dbus-python.sh b/install-dbus-python.sh new file mode 100644 index 0000000..f927d29 --- /dev/null +++ b/install-dbus-python.sh @@ -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