Skip to content
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

Adding check for log file/log directory existence #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dewhurstwill
Copy link

Adding check for log file/log directory existence - Had to manually create the location when installed on OSX

Adding check for log file/log directory existence - Had to manually create the location when installed on OSX
Copy link
Owner

@ceuk ceuk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A couple of changes there mate. I'd suggest deleting the log file/dir locally and running your branch just to make sure it's doing what you want it to do

with open('sample.csv', 'w') as creating_new_log_file:
pass

logging.basicConfig(filename, filemode='w',
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logging.basicConfig doesn't take any position args. If you look at the original code (or just check the function signature) you'll see it expects filename as a keyword arg. I'd suggest running your code at least once just to sanity check this kind of thing


# if log file doesn't exist
if not os.path.isfile(filename):
with open('sample.csv', 'w') as creating_new_log_file:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sample.csv?

try:
os.makedirs(os.path.dirname(filename))
except OSError as exc: # prevent race condition
if exc.errno != errno.EEXIST:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't import errno

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants