Browse Source

Created the quote.py file which displays a random quote and greetings.

pull/1/head
Jeffery Russell 6 years ago
parent
commit
dd549a8989
2 changed files with 60 additions and 2 deletions
  1. +59
    -0
      src/quote.py
  2. +1
    -2
      src/ssh_manager.py

+ 59
- 0
src/quote.py View File

@ -0,0 +1,59 @@
"""
Simple python script to run on bash start up.
This will print a welcome message and then a random quote from a text file
9-27-17
Jeffery Russell
"""
import subprocess
import random
INPUT_FILE = "/home/jeff/scripts/quotes.txt"
WELCOME_MESSAGE = "***************Jeff-Laptop*************"
def print_cowsay_message(message):
"""
Runs the cowsay command and passes it message to print
:param message: The message to print
:return: None
"""
subprocess.call(["cowsay", message])
def print_welcome_message():
"""
Prints defined greeting message to terminal
:return: None
"""
print(WELCOME_MESSAGE)
def input_file():
"""
This file inputs the file defined by INPUT_FILE into a string line and returns it
:return: a string array containing the lines of INPUT_FILE
"""
quotes = []
with open(INPUT_FILE) as file:
for line in file:
quotes.append(line.host.strip(' \t\n\r'))
def main():
"""
This function calls the welcome function, then it calls the cowsay function with a random quote.
:return: None
"""
print_welcome_message()
quotes = input_file()
print_cowsay_message(quotes[random.randint(0,(len(quotes) -1))])
"""
Makes sure that other programs don't execute the main
"""
if __name__ == '__main__':
main()

+ 1
- 2
src/ssh_manager.py View File

@ -28,10 +28,9 @@ def main():
for c in cmp:
if i != '' and int(i) == c.menue_id:
subprocess.call(["ssh", c.host.strip(' \t\n\r')])
#subprocess.Popen("ssh " + c.host.strip(' \t\n\r'))
"""
Makes sure that this other programs don't run the program
Makes sure that other programs don't execute the main
"""
if __name__ == '__main__':
main()

Loading…
Cancel
Save