File: open_close.py

package info (click to toggle)
libewf 20140816-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 20,940 kB
  • sloc: ansic: 347,781; sh: 8,203; cpp: 3,819; makefile: 2,096; yacc: 1,104; python: 439; lex: 394; sed: 16
file content (61 lines) | stat: -rwxr-xr-x 1,208 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#! /usr/bin/env python
#
# Python script to open and close Expert Witness Compression format file(s) using pyewf
#
# Author:            Joachim Metz
# Creation date:     September 29, 2010
# Modification date: January 26, 2013
#

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

import sys
import pyewf

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

print "open_close.py " + __version__ + " (libewf " + pyewf.get_version() + ")\n"

argc = len( sys.argv )

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

	sys.exit( 1 )

filenames = sys.argv[ 1: ]

handle = pyewf.handle();

if handle == None:
	print "Missing handle object\n"

	sys.exit( 1 )

try:
	# Open requires a list of filenames
	handle.open(
	 filenames )

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

	sys.exit( 1 )

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

sys.exit( 0 )