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
# Modifications : 1.1 - 28-02-2012 - CR - Changed inside github and development functions, so instead of if os.name = "posix" do this else do this etc
# : I used os.path.join, so it condensed 4 lines down to 1
# : 1.2 - 10-05-2012 - CR - Added a line to include PHP scripts.
# : 1.3 - 20-07-2012 - CR - Added the line to include Batch scripts
# Description : This scans my scripts directory and gives a count of the different types of scripts
importos# Load the library module
path=os.getenv("scripts") # Set the variable path by getting the value from the OS environment variable scripts
dropbox=os.getenv("dropbox") # Set the variable dropbox by getting the value from the OS environment variable dropbox
defclear_screen(): # Function to clear the screen
ifos.name=="posix": # Unix/Linux/MacOS/BSD/etc
os.system('clear') # Clear the Screen
elifos.namein ("nt", "dos", "ce"): # DOS/Windows
os.system('CLS') # Clear the Screen
defcount_files(path, extensions): # Start of the function to count the files in the scripts directory, it counts the extension when passed below
counter=0# Set the counter to 0
forroot, dirs, filesinos.walk(path): # Loop through all the directories in the given path
forfileinfiles: # For all the files
counter+=file.endswith(extensions) # Count the files
returncounter# Return the count
defgithub(): # Start of the function just to count the files in the github directory
github_dir=os.path.join(dropbox, 'github') # Joins the paths to get the github directory - 1.1
github_count=sum((len(f) for_, _, finos.walk(github_dir))) # Get a count for all the files in the directory
ifgithub_count>5: # If the number of files is greater then 5, then print the following messages
print'\nYou have too many in here, start uploading !!!!!'
print'You have: '+str(github_count) +' waiting to be uploaded to github!!'
elifgithub_count==0: # Unless the count is 0, then print the following messages
print'\nGithub directory is all Clear'
else: # If it is any other number then print the following message, showing the number outstanding.
print'\nYou have: '+str(github_count) +' waiting to be uploaded to github!!'
defdevelopment(): # Start of the function just to count the files in the development directory
dev_dir=os.path.join(path, 'development') # Joins the paths to get the development directory - 1.1
dev_count=sum((len(f) for_, _, finos.walk(dev_dir))) # Get a count for all the files in the directory
ifdev_count>10: # If the number of files is greater then 10, then print the following messages
print'\nYou have too many in here, finish them or delete them !!!!!'
print'You have: '+str(dev_count) +' waiting to be finished!!'
elifdev_count==0: # Unless the count is 0, then print the following messages
print'\nDevelopment directory is all clear'
else:
print'\nYou have: '+str(dev_count) +' waiting to be finished!!'# If it is any other number then print the following message, showing the number outstanding.
clear_screen() # Call the function to clear the screen
print'\nYou have the following :\n'
print'AutoIT:\t'+str(count_files(path, '.au3')) # Run the count_files function to count the files with the extension we pass