openfile(): Go back to opening the files in text mode. This undoes
[python/dscho.git] / Mac / Unsupported / PythonScript / testeudora.py
blobba676a34bf86440b923bb6c85d6dd4df52da699b
1 """A test program that allows us to control Eudora"""
3 import sys
4 import MacOS
5 import PythonScript
7 # The Creator signature of eudora:
8 SIGNATURE="CSOm"
9 TIMEOUT = 10*60*60
13 def main():
14 PythonScript.PsScript(SIGNATURE, TIMEOUT)
15 talker = PythonScript.PyScript
16 ev = PythonScript.PsEvents
17 pc = PythonScript.PsClass
18 while 1:
19 print 'get, put, name (of first folder), list (foldernames), quit (eudora) or exit (this program) ?'
20 line = sys.stdin.readline()
21 try:
22 if line[0] == 'g':
23 print 'check'
24 print talker(ev.Activate)
25 print talker(ev.Connect, Checking=1)
26 elif line[0] == 'p':
27 print talker(ev.Connect, Sending=1)
28 elif line[0] == 'n':
29 id = talker(ev.Get, pc.Mail_folder("").Mailbox(1).Name())
30 print "It is called", id, "\n"
31 elif line[0] == 'l':
32 id = talker(ev.Count, pc.Mail_folder(""), Each='Mailbox')
33 print "There are", id, "mailboxes"
34 elif line[0] == 'q':
35 print talker(ev.Quit)
36 elif line[0] == 'e':
37 break
38 except MacOS.Error, arg:
39 if arg[0] == -609:
40 print 'Connection invalid, is eudora running?'
41 else:
42 print 'MacOS Error:', arg[1]
44 main()