Skip to content

Commit 6b70f4c

Browse files
Merge pull request #234 from RGauthamRam/patch-3
Fixed some alignment of comments
2 parents 00c291f + 9024f6e commit 6b70f4c

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

powerdown_startup.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
# Script Name : powerdown_startup.py
2-
# Author : Craig Richards
3-
# Created : 05th January 2012
4-
# Last Modified :
5-
# Version : 1.0
2+
# Author : Craig Richards
3+
# Created : 05th January 2012
4+
# Last Modified : 21th September 2017
5+
# Version : 1.0
66

77
# Modifications :
88

9-
# Description : This goes through the server list and pings the machine, if it's up it will load the putty session, if its not it will notify you.
9+
# Description : This goes through the server list and pings the machine, if it's up it will load the putty session, if its not it will notify you.
1010

11-
import os # Load the Library Module
12-
import subprocess # Load the Library Module
11+
import os # Load the Library Module
12+
import subprocess # Load the Library Module
1313
from time import strftime # Load just the strftime Module from Time
1414

1515
def windows(): # This is the function to run if it detects the OS is windows.
16-
f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile
16+
f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile
1717
for server in open('startup_list.txt','r'): # Read the list of servers from the list
1818
ret = subprocess.call("ping -n 3 %s" % server, shell=True,stdout=open('NUL', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
1919
if ret == 0: # If you get a response.
20-
f.write ("%s: is alive, loading PuTTY session" % server.strip() + "\n") # Write out to the logfile
20+
f.write ("%s: is alive, loading PuTTY session" % server.strip() + "\n") # Write out to the logfile
2121
subprocess.Popen(('putty -load '+server)) # Load the putty session
2222
else:
23-
f.write ("%s : did not respond" % server.strip() + "\n") # Write to the logfile if the server is down
23+
f.write ("%s : did not respond" % server.strip() + "\n") # Write to the logfile if the server is down
2424

2525
def linux():
26-
f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile
26+
f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile
2727
for server in open('startup_list.txt'): # Read the list of servers from the list
2828
ret = subprocess.call("ping -c 3 %s" % server, shell=True,stdout=open('/dev/null', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
2929
if ret == 0: # If you get a response.
@@ -36,7 +36,9 @@ def linux():
3636

3737
# Start of the Main Program
3838

39-
if os.name == "posix": # If the OS is linux...
40-
linux() # Call the linux function
39+
if os.name == "posix": # If the OS is linux...
40+
linux() # Call the linux function
4141
elif os.name in ("nt", "dos", "ce"): # If the OS is Windows...
42-
windows() # Call the windows function
42+
windows() # Call the windows function
43+
else:
44+
print("Not supported")

0 commit comments

Comments
 (0)