#! /usr/bin/env python
#
# Python script to open and close a Windows XML EventLog (EVTX) file using pyevtx
#
# Author:            Joachim Metz
# Creation date:     October 25, 2012
# Modification date: January 13, 2013
#

__author__    = "Joachim Metz"
__version__   = "20130113"
__date__      = "Jan 13, 2013"
__copyright__ = "Copyright (c) 2011-2013, Joachim Metz <joachim.metz@gmail.com>"
__license__   = "GNU LGPL version 3"

import sys
import pyevtx

# ----------------------------------------------------------------------------
# Main
# ----------------------------------------------------------------------------

print "open_close.py " + __version__ + " (libevtx " + pyevtx.get_version() + ")\n"

argc = len( sys.argv )

if argc < 2:
	print "Usage: open_close.py filename\n"

	sys.exit( 1 )

evtx_file = pyevtx.file();

if evtx_file == None:
	print "Missing EVTX file object\n"

	sys.exit( 1 )

try:
	evtx_file.open(
	 sys.argv[ 1 ] )

except:
	print "Unable to open file\n"
	print sys.exc_info()[ 1 ]

	sys.exit( 1 )

try:
	evtx_file.close()
except:
	print "Unable to close file\n"
	print sys.exc_info()
 
	sys.exit( 1 )

sys.exit( 0 )

