You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: daily_checks.py
+17-17
Original file line number
Diff line number
Diff line change
@@ -20,10 +20,10 @@
20
20
fromtimeimportstrftime# Load just the strftime Module from Time
21
21
22
22
defclear_screen(): # Function to clear the screen
23
-
ifos.name=="posix": # Unix/Linux/MacOS/BSD/etc
24
-
os.system('clear') # Clear the Screen
25
-
elifos.namein ("nt", "dos", "ce"): # DOS/Windows
26
-
os.system('CLS') # Clear the Screen
23
+
ifos.name=="posix": # Unix/Linux/MacOS/BSD/etc
24
+
os.system('clear') # Clear the Screen
25
+
elifos.namein ("nt", "dos", "ce"): # DOS/Windows
26
+
os.system('CLS') # Clear the Screen
27
27
28
28
defprint_docs(): # Function to print the daily checks automatically
29
29
print"Printing Daily Check Sheets:"
@@ -33,7 +33,7 @@ def print_docs(): # Function to print the daily checks automatically
33
33
defputty_sessions(): # Function to load the putty sessions I need
34
34
forserverinopen(conffilename): # Open the file server_list.txt, loop through reading each line - 1.1 -Changed - 1.3 Changed name to use variable conffilename
35
35
subprocess.Popen(('putty -load '+server)) # Open the PuTTY sessions - 1.1
36
-
36
+
37
37
defrdp_sessions():
38
38
print"Loading RDP Sessions:"
39
39
subprocess.Popen("mstsc eclr.rdp") # Open up a terminal session connection and load the euroclear session
@@ -46,19 +46,19 @@ def euroclear_docs():
46
46
47
47
# Start of the Main Program
48
48
defmain():
49
-
filename=sys.argv[0] # Create the variable filename
50
-
confdir=os.getenv("my_config") # Set the variable confdir from the OS environment variable - 1.3
51
-
conffile= ('daily_checks_servers.conf') # Set the variable conffile - 1.3
52
-
conffilename=os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together - 1.3
53
-
clear_screen() # Call the clear screen function
49
+
filename=sys.argv[0] # Create the variable filename
50
+
confdir=os.getenv("my_config") # Set the variable confdir from the OS environment variable - 1.3
51
+
conffile= ('daily_checks_servers.conf') # Set the variable conffile - 1.3
52
+
conffilename=os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together - 1.3
53
+
clear_screen() # Call the clear screen function
54
54
55
-
# The command below prints a little welcome message, as well as the script name, the date and time and where it was run from.
Copy file name to clipboardexpand all lines: move_files_over_x_days.py
+1-1
Original file line number
Diff line number
Diff line change
@@ -1 +1 @@
1
-
# Script Name : move_files_over_x_days.py# Author : Craig Richards# Created : 8th December 2011# Last Modified : # Version : 1.0# Modifications : # Description : This will move all the files from the src directory that are over 240 days old to the destination directory.import shutil, sys, time, os# Import the header filessrc = 'u:\\test'# Set the source directorydst = 'c:\\test'# Set the destination directorynow = time.time()# Get the current timefor f in os.listdir(src):# Loop through all the files in the source directory if os.stat(f).st_mtime < now - 240 * 86400:# Work out how old they are, if they are older than 240 days old if os.path.isfile(f):# Check it's a file shutil.move(f, dst)# Move the files
1
+
# Script Name : move_files_over_x_days.py# Author : Craig Richards# Created : 8th December 2011# Last Modified : # Version : 1.0# Modifications : # Description : This will move all the files from the src directory that are over 240 days old to the destination directory.import shutil, sys, time, os# Import the header filessrc = 'u:\\test'# Set the source directorydst = 'c:\\test'# Set the destination directorynow = time.time()# Get the current timefor f in os.listdir(src):# Loop through all the files in the source directory if os.stat(f).st_mtime < now - 240 * 86400:# Work out how old they are, if they are older than 240 days old if os.path.isfile(f):# Check it's a file shutil.move(f, dst)# Move the files
Copy file name to clipboardexpand all lines: ping_servers.py
+30-30
Original file line number
Diff line number
Diff line change
@@ -15,35 +15,35 @@
15
15
if'-h'insys.argvor'--h'insys.argvor'-help'insys.argvor'--help'insys.argv: # Help Menu if called
16
16
print'''
17
17
You need to supply the application group for the servers you want to ping, i.e.
18
-
dms
19
-
swaps
20
-
18
+
dms
19
+
swaps
20
+
21
21
Followed by the site i.e.
22
-
155
23
-
bromley'''
22
+
155
23
+
bromley'''
24
24
sys.exit(0)
25
25
else:
26
26
27
-
if (len(sys.argv) <3): # If no arguments are passed,display the help/instructions on how to run the script
28
-
sys.exit ('\nYou need to supply the app group. Usage : '+filename+' followed by the application group i.e. \n\t dms or \n\t swaps \n then the site i.e. \n\t 155 or \n\t bromley')
27
+
if (len(sys.argv) <3): # If no arguments are passed,display the help/instructions on how to run the script
28
+
sys.exit ('\nYou need to supply the app group. Usage : '+filename+' followed by the application group i.e. \n\t dms or \n\t swaps \n then the site i.e. \n\t 155 or \n\t bromley')
29
+
30
+
appgroup=sys.argv[1] # Set the variable appgroup as the first argument you supply
31
+
site=sys.argv[2] # Set the variable site as the second argument you supply
32
+
33
+
ifos.name=="posix": # Check the os, if it's linux then
34
+
myping="ping -c 2 "# This is the ping command
35
+
elifos.namein ("nt", "dos", "ce"): # Check the os, if it's windows then
36
+
myping="ping -n 2 "# This is the ping command
29
37
30
-
appgroup=sys.argv[1] # Set the variable appgroup as the first argument you supply
31
-
site=sys.argv[2] # Set the variable site as the second argument you supply
32
-
33
-
ifos.name=="posix": # Check the os, if it's linux then
34
-
myping="ping -c 2 "# This is the ping command
35
-
elifos.namein ("nt", "dos", "ce"): # Check the os, if it's windows then
36
-
myping="ping -n 2 "# This is the ping command
37
-
38
-
if'dms'insys.argv: # If the argument passed is dms then
39
-
appgroup='dms'# Set the variable appgroup to dms
40
-
elif'swaps'insys.argv: # Else if the argment passed is swaps then
41
-
appgroup='swaps'# Set the variable appgroup to swaps
42
-
43
-
if'155'insys.argv: # If the argument passed is 155 then
44
-
site='155'# Set the variable site to 155
45
-
elif'bromley'insys.argv: # Else if the argument passed is bromley
46
-
site='bromley'# Set the variable site to bromley
38
+
if'dms'insys.argv: # If the argument passed is dms then
39
+
appgroup='dms'# Set the variable appgroup to dms
40
+
elif'swaps'insys.argv: # Else if the argment passed is swaps then
41
+
appgroup='swaps'# Set the variable appgroup to swaps
42
+
43
+
if'155'insys.argv: # If the argument passed is 155 then
44
+
site='155'# Set the variable site to 155
45
+
elif'bromley'insys.argv: # Else if the argument passed is bromley
46
+
site='bromley'# Set the variable site to bromley
47
47
48
48
filename=sys.argv[0] # Sets a variable for the script name
49
49
logdir=os.getenv("logs") # Set the variable logdir by getting the OS environment logs
@@ -55,10 +55,10 @@
55
55
56
56
f=open(logfilename, "w") # Open a logfile to write out the output
57
57
forserverinopen(conffilename): # Open the config file and read each line - 1.2
58
-
ret=subprocess.call(myping+server, shell=True,stdout=f,stderr=subprocess.STDOUT) # Run the ping command for each server in the list.
59
-
ifret==0: # Depending on the response
60
-
f.write (server.strip() +" is alive"+"\n") # Write out that you can receive a reponse
61
-
else:
62
-
f.write (server.strip() +" did not respond"+"\n") # Write out you can't reach the box
63
-
58
+
ret=subprocess.call(myping+server, shell=True,stdout=f,stderr=subprocess.STDOUT) # Run the ping command for each server in the list.
59
+
ifret==0: # Depending on the response
60
+
f.write (server.strip() +" is alive"+"\n") # Write out that you can receive a reponse
61
+
else:
62
+
f.write (server.strip() +" did not respond"+"\n") # Write out you can't reach the box
63
+
64
64
print ("\n\tYou can see the results in the logfile : "+logfilename); # Show the location of the logfile
0 commit comments