Last active
August 29, 2015 14:11
-
-
Save HotelCalifornia/a3f685b15124b18f88ff to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: utf-8 -*- | |
import os | |
import fnmatch as fn | |
FILTER = '*.log' | |
PATH = '//fs_02/2016$/618616/PLTW Sftw Engineering/Python' | |
def run(): | |
log = '"' + get_last_log(PATH) + '"' | |
command = u'%logstart -ort ' + log + ' append' | |
get_active_task().python_pane.execute_command(command) | |
def get_logs(path): | |
for root, dirs, files in os.walk(path): | |
for f in fn.filter(files, FILTER): | |
yield root + '/' + f | |
def get_last_log(path): | |
"""get the most recently edited log file | |
Keyword arguments: | |
path -- the path of the working directory | |
""" | |
return max(get_logs(path), key=os.path.getmtime).replace('\\', '/') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment