Skip to content

Commit 17d6a11

Browse files
committed
convert indent to space / reformat files based on PEP8
1 parent 38ca7d9 commit 17d6a11

10 files changed

+111
-110
lines changed

check_for_sqlite_files.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ def isSQLite3(filename):
3030
for r,d,f in os.walk(r'.'):
3131
for files in f:
3232
if isSQLite3(files):
33-
print files
34-
print "[+] '%s' **** is a SQLITE database file **** " % os.path.join(r,files)
35-
log.write("[+] '%s' **** is a SQLITE database file **** " % files+'\n')
33+
print files
34+
print "[+] '%s' **** is a SQLITE database file **** " % os.path.join(r,files)
35+
log.write("[+] '%s' **** is a SQLITE database file **** " % files+'\n')
3636
else:
37-
log.write("[-] '%s' is NOT a sqlite database file" % os.path.join(r,files)+'\n')
38-
log.write("[-] '%s' is NOT a sqlite database file" % files+'\n')
37+
log.write("[-] '%s' is NOT a sqlite database file" % os.path.join(r,files)+'\n')
38+
log.write("[-] '%s' is NOT a sqlite database file" % files+'\n')

daily_checks.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
from time import strftime # Load just the strftime Module from Time
2121

2222
def clear_screen(): # Function to clear the screen
23-
if os.name == "posix": # Unix/Linux/MacOS/BSD/etc
24-
os.system('clear') # Clear the Screen
25-
elif os.name in ("nt", "dos", "ce"): # DOS/Windows
26-
os.system('CLS') # Clear the Screen
23+
if os.name == "posix": # Unix/Linux/MacOS/BSD/etc
24+
os.system('clear') # Clear the Screen
25+
elif os.name in ("nt", "dos", "ce"): # DOS/Windows
26+
os.system('CLS') # Clear the Screen
2727

2828
def print_docs(): # Function to print the daily checks automatically
2929
print "Printing Daily Check Sheets:"
@@ -33,7 +33,7 @@ def print_docs(): # Function to print the daily checks automatically
3333
def putty_sessions(): # Function to load the putty sessions I need
3434
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
3535
subprocess.Popen(('putty -load '+server)) # Open the PuTTY sessions - 1.1
36-
36+
3737
def rdp_sessions():
3838
print "Loading RDP Sessions:"
3939
subprocess.Popen("mstsc eclr.rdp") # Open up a terminal session connection and load the euroclear session
@@ -46,19 +46,19 @@ def euroclear_docs():
4646

4747
# Start of the Main Program
4848
def main():
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
5454

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.
56-
print "Good Morning " + os.getenv('USERNAME') + ", " + filename, "ran at", strftime("%Y-%m-%d %H:%M:%S"), "on",platform.node(), "run from",os.getcwd()
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.
56+
print "Good Morning " + os.getenv('USERNAME') + ", " + filename, "ran at", strftime("%Y-%m-%d %H:%M:%S"), "on",platform.node(), "run from",os.getcwd()
5757

58-
print_docs() # Call the print_docs function
59-
putty_sessions() # Call the putty_session function
60-
rdp_sessions() # Call the rdp_sessions function
61-
euroclear_docs() # Call the euroclear_docs function
58+
print_docs() # Call the print_docs function
59+
putty_sessions() # Call the putty_session function
60+
rdp_sessions() # Call the rdp_sessions function
61+
euroclear_docs() # Call the euroclear_docs function
6262

6363
if __name__ == '__main__':
64-
main()
64+
main()

dir_test.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
# Description : Tests to see if the directory testdir exists, if not it will create the directory for you
99

10-
import os # Import the OS module
11-
if not os.path.exists('testdir'): # Check to see if it exists
12-
os.makedirs('testdir') # Create the directory
10+
import os # Import the OS module
11+
12+
if not os.path.exists('testdir'): # Check to see if it exists
13+
os.makedirs('testdir') # Create the directory

move_files_over_x_days.py

+1-1
Original file line numberDiff line numberDiff 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

ping_servers.py

+30-30
Original file line numberDiff line numberDiff line change
@@ -15,35 +15,35 @@
1515
if '-h' in sys.argv or '--h' in sys.argv or '-help' in sys.argv or '--help' in sys.argv: # Help Menu if called
1616
print '''
1717
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+
2121
Followed by the site i.e.
22-
155
23-
bromley'''
22+
155
23+
bromley'''
2424
sys.exit(0)
2525
else:
2626

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+
if os.name == "posix": # Check the os, if it's linux then
34+
myping = "ping -c 2 " # This is the ping command
35+
elif os.name in ("nt", "dos", "ce"): # Check the os, if it's windows then
36+
myping = "ping -n 2 " # This is the ping command
2937

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-
if os.name == "posix": # Check the os, if it's linux then
34-
myping = "ping -c 2 " # This is the ping command
35-
elif os.name in ("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' in sys.argv: # If the argument passed is dms then
39-
appgroup = 'dms' # Set the variable appgroup to dms
40-
elif 'swaps' in sys.argv: # Else if the argment passed is swaps then
41-
appgroup = 'swaps' # Set the variable appgroup to swaps
42-
43-
if '155' in sys.argv: # If the argument passed is 155 then
44-
site = '155' # Set the variable site to 155
45-
elif 'bromley' in sys.argv: # Else if the argument passed is bromley
46-
site = 'bromley' # Set the variable site to bromley
38+
if 'dms' in sys.argv: # If the argument passed is dms then
39+
appgroup = 'dms' # Set the variable appgroup to dms
40+
elif 'swaps' in sys.argv: # Else if the argment passed is swaps then
41+
appgroup = 'swaps' # Set the variable appgroup to swaps
42+
43+
if '155' in sys.argv: # If the argument passed is 155 then
44+
site = '155' # Set the variable site to 155
45+
elif 'bromley' in sys.argv: # Else if the argument passed is bromley
46+
site = 'bromley' # Set the variable site to bromley
4747

4848
filename = sys.argv[0] # Sets a variable for the script name
4949
logdir = os.getenv("logs") # Set the variable logdir by getting the OS environment logs
@@ -55,10 +55,10 @@
5555

5656
f = open(logfilename, "w") # Open a logfile to write out the output
5757
for server in open(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-
if ret == 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+
if ret == 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+
6464
print ("\n\tYou can see the results in the logfile : "+ logfilename); # Show the location of the logfile

ping_subnet.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,20 @@
2020
sys.exit(0)
2121
else:
2222

23-
if (len(sys.argv) < 2): # If no arguments are passed then display the help and instructions on how to run the script
24-
sys.exit (' You need to supply the first octets of the address Usage : ' + filename + ' 111.111.111')
25-
26-
subnet = sys.argv[1] # Set the variable subnet as the three octets you pass it
27-
28-
if os.name == "posix": # Check the os, if it's linux then
29-
myping = "ping -c 2 " # This is the ping command
30-
elif os.name in ("nt", "dos", "ce"): # Check the os, if it's windows then
31-
myping = "ping -n 2 " # This is the ping command
32-
33-
f = open('ping_'+subnet+'.log', 'w') # Open a logfile
34-
for ip in range(2,255): # Set the ip variable for the range of numbers
35-
ret = subprocess.call(myping + str(subnet)+"."+str(ip) , shell=True,stdout=f,stderr=subprocess.STDOUT) # Run the command pinging the servers
36-
if ret == 0: # Depending on the response
37-
f.write (subnet+"."+str(ip) + " is alive" + "\n") # Write out that you can receive a reponse
38-
else:
39-
f.write (subnet+"."+str(ip) + " did not respond" + "\n") # Write out you can't reach the box
23+
if (len(sys.argv) < 2): # If no arguments are passed then display the help and instructions on how to run the script
24+
sys.exit (' You need to supply the first octets of the address Usage : ' + filename + ' 111.111.111')
25+
26+
subnet = sys.argv[1] # Set the variable subnet as the three octets you pass it
27+
28+
if os.name == "posix": # Check the os, if it's linux then
29+
myping = "ping -c 2 " # This is the ping command
30+
elif os.name in ("nt", "dos", "ce"): # Check the os, if it's windows then
31+
myping = "ping -n 2 " # This is the ping command
32+
33+
f = open('ping_'+subnet+'.log', 'w') # Open a logfile
34+
for ip in range(2,255): # Set the ip variable for the range of numbers
35+
ret = subprocess.call(myping + str(subnet)+"."+str(ip) , shell=True,stdout=f,stderr=subprocess.STDOUT) # Run the command pinging the servers
36+
if ret == 0: # Depending on the response
37+
f.write (subnet+"."+str(ip) + " is alive" + "\n") # Write out that you can receive a reponse
38+
else:
39+
f.write (subnet+"."+str(ip) + " did not respond" + "\n") # Write out you can't reach the box

powerup_checks.py

+24-24
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,28 @@
2929
3030
You need to pass an argument, the options the script expects is
3131
32-
-site1 For the Servers relating to site1
33-
-site2 For the Servers located in site2'''
34-
32+
-site1 For the Servers relating to site1
33+
-site2 For the Servers located in site2'''
34+
3535
def windows(): # This is the function to run if it detects the OS is windows.
36-
f = open(outputfile, 'a') # Open the logfile
37-
for server in open(serverfile,'r'): # Read the list of servers from the list
38-
#ret = subprocess.call("ping -n 3 %s" % server.strip(), shell=True,stdout=open('NUL', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
39-
ret = subprocess.call("ping -n 3 %s" % server.strip(),stdout=open('NUL', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
40-
if ret == 0: # Depending on the response
41-
f.write ("%s: is alive" % server.strip().ljust(15) + "\n") # Write out to the logfile is the server is up
42-
else:
43-
f.write ("%s: did not respond" % server.strip().ljust(15) + "\n") # Write to the logfile if the server is down
44-
45-
36+
f = open(outputfile, 'a') # Open the logfile
37+
for server in open(serverfile,'r'): # Read the list of servers from the list
38+
#ret = subprocess.call("ping -n 3 %s" % server.strip(), shell=True,stdout=open('NUL', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
39+
ret = subprocess.call("ping -n 3 %s" % server.strip(),stdout=open('NUL', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
40+
if ret == 0: # Depending on the response
41+
f.write ("%s: is alive" % server.strip().ljust(15) + "\n") # Write out to the logfile is the server is up
42+
else:
43+
f.write ("%s: did not respond" % server.strip().ljust(15) + "\n") # Write to the logfile if the server is down
44+
45+
4646
def linux(): # This is the function to run if it detects the OS is nix.
47-
f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile
48-
for server in open(serverfile,'r'): # Read the list of servers from the list
49-
ret = subprocess.call("ping -c 3 %s" % server, shell=True,stdout=open('/dev/null', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
50-
if ret == 0: # Depending on the response
51-
f.write ("%s: is alive" % server.strip().ljust(15) + "\n") # Write out to the logfile is the server is up
52-
else:
53-
f.write ("%s: did not respond" % server.strip().ljust(15) + "\n") # Write to the logfile if the server is down
47+
f = open('server_startup_'+strftime("%Y-%m-%d")+'.log', 'a') # Open the logfile
48+
for server in open(serverfile,'r'): # Read the list of servers from the list
49+
ret = subprocess.call("ping -c 3 %s" % server, shell=True,stdout=open('/dev/null', 'w'),stderr=subprocess.STDOUT) # Ping the servers in turn
50+
if ret == 0: # Depending on the response
51+
f.write ("%s: is alive" % server.strip().ljust(15) + "\n") # Write out to the logfile is the server is up
52+
else:
53+
f.write ("%s: did not respond" % server.strip().ljust(15) + "\n") # Write to the logfile if the server is down
5454

5555
def get_servers(query): # Function to get the servers from the database
5656
conn = sqlite3.connect(master_db) # Connect to the database
@@ -69,7 +69,7 @@ def get_servers(query): # Function to get the ser
6969
def main(): # Main Function
7070
if os.path.exists(serverfile): # Checks to see if there is an existing server file
7171
os.remove(serverfile) # If so remove it
72-
72+
7373
if len(sys.argv) < 2: # Check there is an argument being passed
7474
print text # Display the help text if there isn't one passed
7575
sys.exit() # Exit the script
@@ -81,16 +81,16 @@ def main(): # Main Function
8181
if sys.argv[1].lower().startswith('-site1'): # If the argument is site1
8282
query = 'site1' # Set the variable to have the value site
8383
elif sys.argv[1].lower().startswith('-site2'): # Else if the variable is bromley
84-
query = 'site2' # Set the variable to have the value bromley
84+
query = 'site2' # Set the variable to have the value bromley
8585
else:
8686
print '\n[-] Unknown option [-] ' + text # If an unknown option is passed, let the user know
8787
sys.exit(0)
8888
get_servers(query) # Call the get servers funtion, with the value from the argument
8989

9090
if os.name == "posix": # If the OS is linux.
91-
linux() # Call the linux function
91+
linux() # Call the linux function
9292
elif os.name in ("nt", "dos", "ce"): # If the OS is Windows...
93-
windows() # Call the windows function
93+
windows() # Call the windows function
9494

9595
print ('\n[+] Check the log file ' + outputfile + ' [+]\n') # Display the name of the log
9696

recyclebin.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ def sid2user(sid): # Start of the function to gather the user
2020
return user
2121
except:
2222
return sid
23-
23+
2424

2525
def returnDir(): # Start of the function to search through the recyclebin
2626
dirs=['c:\\Recycler\\','C:\\Recycled\\','C:\\$RECYCLE.BIN\\']
2727
#dirs=['c:\\$RECYCLE.BIN\\']
2828
for recycleDir in dirs:
2929
if os.path.isdir(recycleDir):
30-
return recycleDir
30+
return recycleDir
3131
return None
3232

3333
def findRecycled(recycleDir): # Start of the function, list the contents of the recyclebin
@@ -37,8 +37,8 @@ def findRecycled(recycleDir): # Start of the function, list the contents of the
3737
user = sid2user(sid)
3838
print '\n[*] Listing Files for User: ' + str(user)
3939
for file in files:
40-
print '[+] Found File: ' + str(file)
41-
40+
print '[+] Found File: ' + str(file)
41+
4242
def main():
4343
recycleDir = returnDir()
4444
findRecycled(recycleDir)

0 commit comments

Comments
 (0)