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
Here is some more detailed information about the scripts I have written. I do not consider myself a programmer, I create these little programs as experiments to have a play with the language, or to solve a problem for myself. I would gladly accept pointers from others to improve the code and make it more efficient, or simplify the code. If you would like to make any comments then please feel free to email me at [email protected].
2
+
3
+
In the scripts the comments etc are lined up correctly when they are viewed in [Notepad++](https://notepad-plus-plus.org/). This is what I use to code Python scripts.
4
+
5
+
-`batch_file_rename.py` - This will batch rename a group of files in a given directory, once you pass the current and new extensions.
6
+
7
+
-`create_dir_if_not_there.py` - Checks to see if a directory exists in the users home directory, if not then create it.
8
+
9
+
-`dir_test.py` - Tests to see if the directory `testdir` exists, if not it will create the directory for you.
10
+
11
+
-`env_check.py` - This script will check to see if all of the environment variables I require are set.
12
+
13
+
-`fileinfo.py` - Show file information for a given file.
14
+
15
+
-`folder_size.py` - This will scan the current directory and all subdirectories and display the size.
16
+
17
+
-`logs.py` - This script will search for all `*.log` files in the given directory, zip them using the program you specify and then date stamp them.
18
+
19
+
-`move_files_over_x_days.py` - This will move all the files from the source directory that are over 240 days old to the destination directory.
20
+
21
+
-`nslookup_check.py` - This very simple script opens the file `server_list.txt` and the does an nslookup for each one to check the DNS entry.
22
+
23
+
-`osinfo.py` - Displays some information about the OS you are running this script on.
24
+
25
+
-`ping_servers.py` - This script will, depending on the arguments supplied will ping the servers associated with that application group.
26
+
27
+
-`ping_subnet.py` - After supplying the first 3 octets it will scan the final range for available addresses.
28
+
29
+
-`powerdown_startup.py` - 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.
30
+
31
+
-`puttylogs.py` - This zips up all the logs in the given directory.
32
+
33
+
-`script_count.py` - This scans my scripts directory and gives a count of the different types of scripts.
34
+
35
+
-`script_listing.py` - This will list all the files in the given directory, it will also go through all the subdirectories as well.
36
+
37
+
-`testlines.py` - This very simple script open a file and prints out 100 lines of whatever is set for the line variable.
# Description : This will go through and backup all my automator services workflows
10
+
11
+
importshutil# Load the library module
12
+
importdatetime# Load the library module
13
+
importos# Load the library module
14
+
15
+
today=datetime.date.today() # Get Today's date
16
+
todaystr=today.isoformat() # Format it so we can use the format to create the directory
17
+
18
+
confdir=os.getenv("my_config") # Set the variable by getting the value from the OS setting
19
+
dropbox=os.getenv("dropbox") # Set the variable by getting the value from the OS setting
20
+
conffile= ('services.conf') # Set the variable as the name of the configuration file
21
+
conffilename=os.path.join(confdir, conffile) # Set the variable by combining the path and the file name
22
+
sourcedir=os.path.expanduser('~/Library/Services/') # Source directory of where the scripts are located
23
+
destdir=os.path.join(dropbox, "My_backups"+"/"+"Automater_services"+todaystr+"/") # Combine several settings to create the destination backup directory
24
+
25
+
forfile_nameinopen(conffilename): # Walk through the configuration file
26
+
fname=file_name.strip() # Strip out the blank lines from the configuration file
27
+
iffname: # For the lines that are not blank
28
+
sourcefile=os.path.join(sourcedir, file_name.strip()) # Get the name of the source files to backup
29
+
destfile=os.path.join(destdir, file_name.strip()) # Get the name of the destination file names
30
+
shutil.copytree(sourcefile, destfile) # Copy the directories
defputty_sessions(): # Function to load the putty sessions I need
33
+
forserverinopen(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
+
defrdp_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
+
defeuroclear_docs():
41
+
# The command below opens IE and loads the Euroclear password document
0 commit comments