Sending emails

I have taken this data tracking on-board as I am needing to do some reporting in the coming weeks.
I have made a quick python code Id like to share of my workflow.
This creates a blank text file of a timestamp, for each user of a machine, in a specified local or network location.
(As long as users have write access there)
Just swap out the @INSERT FOLDER HERE@ with your location. :grinning:

# Original Script by EwanO 2018 (Sastrugi Package) 
# Use as you like :-)
# This code creates a blank text file in a specified location that
# contains generic data.

import clr
import System
from System.IO import Directory

import sys
# load python
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
sys.path.append(pyt_path)

from datetime import datetime

# get the current date and time
datestamp = datetime.today().strftime("%Y-%m-%d")
timestamp = datetime.now().strftime("%H-%M-%S")

import os

## set the output directory and gather log data
main_dir = '@INSERT FOLDER HERE@'
user = os.environ.get('USERNAME')
computer = os.environ.get('COMPUTERNAME')
dir = main_dir + '\\' + computer + '\\' + user

# create a directory for each user of a machine
Directory.CreateDirectory(dir)

# generate the file name for the log file
filename = (str(datestamp) + '_' + str(timestamp) + '.txt')

# create the log file (blank text file)
logger = open(dir + '\\' + filename,'w+')

OUT = str("Run Logged")
8 Likes