[Tutor] Scripting Outlook

2008-03-27 Thread Justin Cardinal
Can anyone direct me to some examples/documentation for using python to work
with Outlook? So far, the most useful thing I've come across is a post from
someone with problems adding an attachment:
http://mail.python.org/pipermail/python-list/2002-August/160894.html

 

That actually got me far enough to create a basic message and send it with
"To" recipients, subject and body filled out. I get a warning that a program
is trying to access Outlook, which I then have to manually allow, and I
think I've seen it suggested that this can be worked around. Also, I'd like
to learn more, like how to use signatures and encryption, adding recipients
to the "Cc" and "Bcc" fields, etc. Any suggestions would be much
appreciated. Thanks!

 

Justin Cardinal | EXB Solutions, Inc

 

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Mail? What's that?

2007-12-06 Thread Justin Cardinal

Ricardo Aráoz wrote:
>Are From: To: Date: and Subject: mandatory in the contents of the

>email(text)?  Do I have to put "real" address in  From when calling

>sendmail()? And in the contents?
Here's the page I used to learn on this subject.
http://www.thinkspot.net/sheila/article.php?story=20040822174141155
 
I'm definitely not a pro in this area, so what comes next are merely
assumptions made after toying around a bit.
I don't believe the From, To, Date, Subject are required, but if you play
around sending some test messages to yourself, you'll see that excluding
them makes the message look very suspicious. As far as using your real
address, that might depend on your email server...but yes, you can most
likely spoof other addresses. Please use this for good, not evil.
 
-Justin Cardinal
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] Working with bash (subversion)

2007-07-18 Thread Justin Cardinal
That fixed it, thanks! Now I just need to do some studying on working with
lists (or whatever this output is...) so I can filter out the results I
don't want. Here's an updated version of the program:

#!/usr/bin/env python
 
import commands as c

lsout = c.getoutput('ls -d /home/svn/repository/*/').split('\n')
results = []
for row in lsout:
  temp = c.getoutput('svnadmin lslocks ' + row).split('\n')
  if temp != ['']:
results.append(temp)
print results 

...and the output:

['Path: /test/trunk/data.bin', 'UUID Token:
opaquelocktoken:9ee85aae-c9dc-4388-8958-87b708e628a3', 'Owner: jcardinal',
'Created: 2007-07-17 14:36:18 -0500 (Tue, 17 Jul 2007)', 'Expires: ',
'Comment (1 line):', '', '']


Thanks very much to all who replied, it's amazing how quick help arrives!
-Justin

> Here's what I've got so far:
> =
> #!/usr/bin/env python
>  
> import commands as c
>  
> lsout = c.getoutput('ls -d /home/svn/repository/*/').split('\n')
> results = file("results.txt", "w")
> for row in lsout:
>   results.write(c.getoutput('svnadmin lslocks ' + eval(row))) 
> ===
> Traceback (most recent call last):
>   File "checklocks.py", line 8, in ?
> results.write(c.getoutput('svnadmin lslocks ' + eval(row)))
>   File "", line 1
> /home/svn/repository/projecta/
> ^
> SyntaxError: invalid syntax
> ===
>  
> Any advice would be much appreciated. Thanks!
eval evaluates the string as a python command.
Because there are no Python commands that start with a forward slash,
Python's pointing to this as a syntax error.
Because row is a string already (and note that 'column' would be a more apt
term for this, as a 1-dimensional list is more similar to a single row than
a single column) you can just do simple string concatenation (or you can use
string substitution but in this case it's not necessary and would just make
your code less readable.) Here's a basic example:
 >>> 'hello ' + 'world!'
'hello world!'

Does that tell you everything you need to know?
(recall that whether 'world!' is referenced using a variable name or used
directly, the effect will be the same.  I.E.
a = 'ba'
a + 'nana'
has the same end result as
'ba' + 'nana'with the exception being that the variable 'a' is not 
defined or is not bound to a new value after this statement.)

HTH,
-Luke

___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Working with bash (subversion)

2007-07-18 Thread Justin Cardinal
I'm trying to write a program that will list all subversion repository
directories, then issue a command using each directory as an argument, then
parse those results. So far, I'm able to get a list of the directories...and
that's it!
Here's what I've got so far:
=
#!/usr/bin/env python
 
import commands as c
 
lsout = c.getoutput('ls -d /home/svn/repository/*/').split('\n')
results = file("results.txt", "w")
for row in lsout:
  results.write(c.getoutput('svnadmin lslocks ' + eval(row)))
=
lsout is a list of repository directories, like I wanted.
(['/home/svn/repository/projecta/', '/home/svn/repository/projectb/',
'/home/svn/repository/projectc/']
The next 3 lines are probably totally wrong. I want to perform the following
bash command for each directory...
==
svnadmin lslocks /home/svn/repository/projecta
==
...and then parse the results. I just don't know where/how to store the
results from each svnadmin command. When I run the program in its current
form, I get the following error:
===
Traceback (most recent call last):
  File "checklocks.py", line 8, in ?
results.write(c.getoutput('svnadmin lslocks ' + eval(row)))
  File "", line 1
/home/svn/repository/projecta/
^
SyntaxError: invalid syntax
===
 
Any advice would be much appreciated. Thanks!
 
-Justin Cardinal
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor