1 |
#!/usr/bin/python |
---|
2 |
# |
---|
3 |
# Copyright (C) 2008 Andreas Thienemann <andreas@bawue.net> |
---|
4 |
# |
---|
5 |
# This program is free software; you can redistribute it and/or modify |
---|
6 |
# it under the terms of the GNU Library General Public License as published by |
---|
7 |
# the Free Software Foundation; version 2 only |
---|
8 |
# |
---|
9 |
# This program is distributed in the hope that it will be useful, |
---|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
12 |
# GNU Library General Public License for more details. |
---|
13 |
# |
---|
14 |
# You should have received a copy of the GNU Library General Public License |
---|
15 |
# along with this program; if not, write to the Free Software |
---|
16 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
---|
17 |
# |
---|
18 |
|
---|
19 |
import optparse |
---|
20 |
import os |
---|
21 |
import sys |
---|
22 |
import pprint |
---|
23 |
import pickle |
---|
24 |
import IPy |
---|
25 |
import traceback |
---|
26 |
|
---|
27 |
def main(): |
---|
28 |
global db, cursor |
---|
29 |
# CLI Options |
---|
30 |
usage = "usage: %prog [options] <pklfile>" |
---|
31 |
parser = optparse.OptionParser(usage) |
---|
32 |
parser.add_option("-d", "--loglevel=debug", |
---|
33 |
action="store_const", const="DEBUG", dest="loglevel", |
---|
34 |
help="DEBUG loglevel", default="INFO") |
---|
35 |
(options, args) = parser.parse_args() |
---|
36 |
|
---|
37 |
if args == []: |
---|
38 |
print "Filename is needed" |
---|
39 |
sys.exit(1) |
---|
40 |
|
---|
41 |
# Unpickle the file and display it nicely. |
---|
42 |
try: |
---|
43 |
data_file = open(args[0], 'rb') |
---|
44 |
data = pickle.load(data_file) |
---|
45 |
data_file.close() |
---|
46 |
except: |
---|
47 |
trace = traceback.format_exc() |
---|
48 |
print trace |
---|
49 |
sys.exit(1) |
---|
50 |
|
---|
51 |
pprint.pprint(data) |
---|
52 |
|
---|
53 |
|
---|
54 |
if __name__ == "__main__": |
---|
55 |
main() |
---|
56 |
|
---|
57 |
|
---|