Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d6413eb

Browse files
committed
My daily checks script
When having to complete early morning checks this script loads everything I need and prints my sheets, saves my having to do everything manually
1 parent 765952e commit d6413eb

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

daily_checks.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Script Name : daily_checks.py
2+
# Author : Craig Richards
3+
# Created : 07th December 2011
4+
# Last Modified : 01st May 2013
5+
# Version : 1.4
6+
7+
# Modifications : 1.1 Removed the static lines for the putty sessions, it now reads a file, loops through and makes the connections.
8+
# : 1.2 Added a variable filename=sys.argv[0] , as when you use __file__ it errors when creating an exe with py2exe.
9+
# : 1.3 Changed the server_list.txt file name and moved the file to the config directory.
10+
# : 1.4 Changed some settings due to getting a new pc
11+
12+
# Description : This simple script loads everything I need to carry out the daily checks for our systems.
13+
14+
import platform # Load the Library Module
15+
import os # Load the Library Module
16+
import subprocess # Load the Library Module
17+
import sys # Load the Library Module
18+
19+
from time import strftime # Load just the strftime Module from Time
20+
21+
def clear_screen(): # Function to clear the screen
22+
if os.name == "posix": # Unix/Linux/MacOS/BSD/etc
23+
os.system('clear') # Clear the Screen
24+
elif os.name in ("nt", "dos", "ce"): # DOS/Windows
25+
os.system('CLS') # Clear the Screen
26+
27+
def print_docs(): # Function to print the daily checks automatically
28+
print "Printing Daily Check Sheets:"
29+
# The command below passes the command line string to open word, open the document, print it then close word down
30+
subprocess.Popen(["C:\\Program Files (x86)\Microsoft Office\Office14\winword.exe", "P:\\\\Documentation\\Daily Docs\\Back office Daily Checks.doc", "/mFilePrintDefault", "/mFileExit"]).communicate()
31+
32+
def putty_sessions(): # Function to load the putty sessions I need
33+
for server in open(conffilename): # Open the file server_list.txt, loop through reading each line - 1.1 -Changed - 1.3 Changed name to use variable conffilename
34+
subprocess.Popen(('putty -load '+server)) # Open the PuTTY sessions - 1.1
35+
36+
def rdp_sessions():
37+
print "Loading RDP Sessions:"
38+
subprocess.Popen("mstsc eclr.rdp") # Open up a terminal session connection and load the euroclear session
39+
40+
def euroclear_docs():
41+
# The command below opens IE and loads the Euroclear password document
42+
subprocess.Popen('"C:\\Program Files\\Internet Explorer\\iexplore.exe"' '"file://fs1\pub_b\Pub_Admin\Documentation\Settlements_Files\PWD\Eclr.doc"')
43+
44+
# End of the functions
45+
46+
# Start of the Main Program
47+
48+
filename=sys.argv[0] # Create the variable filename
49+
confdir = os.getenv("my_config") # Set the variable confdir from the OS environment variable - 1.3
50+
conffile = ('daily_checks_servers.conf') # Set the variable conffile - 1.3
51+
conffilename=os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together - 1.3
52+
clear_screen() # Call the clear screen function
53+
# The command below prints a little welcome message, as well as the script name, the date and time and where it was run from.
54+
print "Good Morning " + os.getenv('USERNAME') + ", " + filename, "ran at", strftime("%Y-%m-%d %H:%M:%S"), "on",platform.node(), "run from",os.getcwd()
55+
print_docs() # Call the print_docs function
56+
putty_sessions() # Call the putty_session function
57+
rdp_sessions() # Call the rdp_sessions function
58+
euroclear_docs() # Call the euroclear_docs function

0 commit comments

Comments
 (0)