Skip to content

Instantly share code, notes, and snippets.

@HotelCalifornia
Last active August 29, 2015 14:11
Show Gist options
  • Save HotelCalifornia/a3f685b15124b18f88ff to your computer and use it in GitHub Desktop.
Save HotelCalifornia/a3f685b15124b18f88ff to your computer and use it in GitHub Desktop.
# -*- 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