Skip to content

added exceptions #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 23, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions create_dir_if_not_there.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,17 @@
# Script Name : create_dir_if_not_there.py
# Author : Craig Richards
# Created : 09th January 2012
# Last Modified :
# Last Modified : 22nd October 2015
# Version : 1.0
# Modifications :
# Modifications : Added exceptions

# Description : Checks to see if a directory exists in the users home directory, if not then create it

import os # Import the OS module
home=os.path.expanduser("~") # Set the variable home by expanding the users set home directory
print home # Print the location
if not os.path.exists(home+'/testdir'): # Check to see if the directory exists
os.makedirs(home+'/testdir') # If not create the directory, inside their home directory
import os # Import the OS module
try:
home=os.path.expanduser("~") # Set the variable home by expanding the users set home directory
print home # Print the location
if not os.path.exists(home+'/testdir'):
os.makedirs(home+'/testdir') # If not create the directory, inside their home directory
except Exceptions as e:
print e