Browse Source

Added option to add a quote to the quotes file by using command quote -a

pull/11/head
jrtechs 6 years ago
parent
commit
81a048dc7e
2 changed files with 51 additions and 10 deletions
  1. +2
    -2
      src/mount_ssh_drive.py
  2. +49
    -8
      src/quote.py

+ 2
- 2
src/mount_ssh_drive.py View File

@ -4,7 +4,6 @@ Jeffery Russell
""" """
import subprocess import subprocess
import collections
import sys import sys
import module import module
@ -94,7 +93,8 @@ def remove_drive():
f.close() f.close()
def add_drive_to_config(remote_connection, remote_mount_point, local_mount_point):
def add_drive_to_config(remote_connection, remote_mount_point,
local_mount_point):
""" """
Adds a new network drive to the default mount config file Adds a new network drive to the default mount config file
""" """

+ 49
- 8
src/quote.py View File

@ -6,8 +6,8 @@ This will print a welcome message and then a random quote from a text file
Jeffery Russell Jeffery Russell
""" """
import subprocess
import random import random
import sys
import module import module
import roosay import roosay
@ -27,21 +27,62 @@ def print_roosay_message(message):
roosay.roo_say(message) roosay.roo_say(message)
def main():
def print_usage():
""" """
This function calls the welcome function, then it calls the cowsay function with a random quote.
Prints the usage message to the terminal
:return: None :return: None
""" """
quotes = module.input_file(INPUT_FILE)
print("Usage:")
print("\t-a quote \t: Adds a quote to the quotes list")
print("\t-h \t\t: Prints usage message")
def add_quote():
"""
Adds the quote in the command line arguments
to the quotes text file
:return: None
"""
quote = ""
for i in range(2, len(sys.argv)):
quote = quote + sys.argv[i]
quote = quote + " "
if len(quotes) == 0:
print("Quotes file : " + INPUT_FILE + " is empty.")
print("added " + quote + "to " + INPUT_FILE)
module.append_file(INPUT_FILE, quote)
def main():
"""
This function calls the welcome function, then it calls the cowsay
function with a random quote.
:return: None
"""
if len(sys.argv) > 1:
if sys.argv[1].lower() == "-h" or sys.argv[1].lower() == "-help":
print_usage()
elif sys.argv[1].lower() == "-a":
if len(sys.argv) > 2:
add_quote()
else:
print("You forgot to enter a quote.")
else:
print_usage()
else: else:
print_roosay_message(quotes[random.randint(0,(len(quotes) -1))])
quotes = module.input_file(INPUT_FILE)
if len(quotes) == 0:
print("Quotes file : " + INPUT_FILE + " is empty.")
else:
print_roosay_message(quotes[random.randint(0,(len(quotes) -1))])
""" """
Makes sure that other programs don't execute the main Makes sure that other programs don't execute the main
""" """
if __name__ == '__main__': if __name__ == '__main__':
main()
try:
main()
except KeyboardInterrupt:
exit()

Loading…
Cancel
Save