File: open_close.py

package info (click to toggle)
libpff 20120802-5
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 13,524 kB
  • ctags: 6,784
  • sloc: ansic: 214,206; sh: 11,485; makefile: 1,229; python: 138; java: 137; sed: 16
file content (57 lines) | stat: -rwxr-xr-x 1,128 bytes parent folder | download | duplicates (2)
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
#! /usr/bin/env python
#
# Python sccript to open and close a Personal Folder File using pypff
#
# Author:            Joachim Metz
# Creation date:     July 24, 2010
# Modification date: October 14, 2010
#

__author__    = "Joachim Metz"
__version__   = "20101014"
__date__      = "Oct 14, 2010"
__copyright__ = "Copyright (c) 2010, Joachim Metz <joachim.metz@gmail.com>"
__license__   = "GNU LGPL version 3"

import sys
import pypff

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

print "open_close.py " + __version__ + " (libpff " + pypff.get_version() + ")\n"

if len( sys.argv ) != 2:
	print "Usage: open_close.py filename\n"

	sys.exit( 1 )

file = pypff.new_file();

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

	sys.exit( 1 )

try:
	file.open(
	 sys.argv[ 1 ],
	 pypff.get_access_flags_read() )

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

	sys.exit( 1 )

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

sys.exit( 0 )