annotate python/test.py @ 195:320cfcba8058

add python module interface to the shared library for easy scripting. the shared library must never write to stdout or stderr. fix pst_attach_to_mem so the caller does not need to initialize the buffer pointer.
author Carl Byington <carl@five-ten-sg.com>
date Mon, 20 Apr 2009 19:39:26 -0700
parents
children ffd1503a7530
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
195
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 import _libpst, sys
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 for i in range(1,len(sys.argv)):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4 print "try file %s" % (sys.argv[i])
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 pst = _libpst.pst(sys.argv[i])
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 topf = pst.pst_getTopOfFolders()
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8 while (topf):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 #print "topf d_id is %d\n" % (topf.d_id)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 item = pst.pst_parse_item(topf, None)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 if (item):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 if (item.type == 1):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13 em = item.email
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14 if (em):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 if (em.messageid.str):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 print "message id is |%s|" % (em.messageid.str)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 subj = item.subject;
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 if (subj.str):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 print "subject is %s" % (subj.str)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 body = item.body
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 #if (body.str):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22 # print "message body is %s" % (body.str)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23 att = item.attach
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 while (att):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 attid = att.i_id
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 print "attachment id %d" % (attid)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 att1 = att.filename1
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28 att2 = att.filename2
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29 print "attachment file name %s %s" % (att1.str, att2.str)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 attdata = pst.pst_attach_to_mem(att)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 if (attdata):
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 print "data size %d" % (len(attdata))
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 att = att.next
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 topf = pst.pst_getNextDptr(topf)
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 print "done"
320cfcba8058 add python module interface to the shared library for easy scripting.
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36