getting a "simple" program to work

John Haggerty bouncyinc at gmail.com
Sat Aug 15 00:46:19 EDT 2009


I'm checking back with some new info.

Apparently the maintainer of the ogss package indicated that this is
definately an issue with the libgmail package.

Now I have already submtted help to the maintainer of libgmail to get some
help it making his project work again.

I am also interesetd in how roundabout smtp support could be added to that
program specifically

    print "Seding back results"
                    account.sendMessage(tosend)
                    print "Logging..."
                    execd.append(int(maxmessage.id,16))
                    towrite = str(int(maxmessage.id,16))+"~ "
                    for arg in command:
                        towrite += arg+" "
                    w.write(towrite+"\n")
                    print "Listening for commands"

in the code sample from ogss.py to take that subroutine and turn it around
to allow the same arguments

basically take the above

and add

-----------------------------------------

gmail_user = ""    #Username
gmail_pwd  = ""        #Password
gmail_alt  = " "        #Alias ID
gmail_alias = ""+gmail_alt        #nickname
mailing_list = ""
class mailz:
  def __init__(self):
    self.files=[""]
    self.mail = MIMEMultipart()

  def attach(self,fil):
    self.files.append(fil)

  def mailprep(self,to, subject, text):
    self.to = to
    self.mail['From'] = gmail_alias
    self.mail['To'] = to
    self.mail['Subject'] = subject
    if (mailtoBcc !="") :
      self.mail['BCC'] = mailtoBcc

    text+="\n\n\n_________________________\nMail generated By  PyGmS
"+ver+"\n - Made By Djays\n        http://djsh.net"

    self.mail.attach(MIMEText(text))
    print self.files

    for attach in self.files:
      if (attach != "") :
          part = MIMEBase('application', 'octet-stream')
          part.set_payload(open(attach, 'rb').read())
          Encoders.encode_base64(part)
          part.add_header('Content-Disposition','attachment; filename="%s"'
%
os.path.basename(attach))
          self.mail.attach(part)

  def sendmail(self):
    self.mailServer = smtplib.SMTP("smtp.gmail.com", 587)
    self.mailServer.ehlo()
    self.mailServer.starttls()
    self.mailServer.ehlo()
    self.mailServer.login(gmail_user, gmail_pwd)
    self.mailServer.sendmail(gmail_user, self.to, self.mail.as_string())
    self.mailServer.close()
----------------------------------------------------------------------------

I hate to sound like a newb but the problem is that I'm running into
apathetic maintainers of the software in question which has yet to be
redacted as "working" and at the present time I have to deal with
multi-server conglomerates like "Request Tracker" or "Roundup" both of which
are simply not authenticating into gmail at all.

At first I thought this was an issue of the ssl certificates not working but
hen how come it's possible to have any of the code working when it's just
the sending?

And how is it possible that generic but different code can be working when
it's all broken?

Not to sound in any way belligerent but when this would be my 5th program
language to solve a simple problem I think this is solveable w/o having to
resort to the equivalent to a half semester of CS I in python imho.

On Wed, Aug 12, 2009 at 10:41 PM, John Haggerty <bouncyinc at gmail.com> wrote:

> Just checking to see if this is more adequate to what you would have wanted
> to see I didn't get any feedback so I wasn't quite sure of this at the
> present time.
>
>
> On Tue, Aug 11, 2009 at 11:02 PM, John Haggerty <bouncyinc at gmail.com>wrote:
>
>>
>>
>> On Tue, Aug 11, 2009 at 10:46 PM, Chris Rebert <clp2 at rebertia.com> wrote:
>>
>>> On Sun, Aug 9, 2009 at 8:42 PM, John Haggerty<bouncyinc at gmail.com>
>>> wrote:
>>> > ok so I know this is one of those "weird" requests but here me out.
>>> > So far I have an issue with a package for python called "libgmail"
>>> which is
>>> > basically a gmail interface for python to send messages remoetly.
>>> > Works ok except that the 'sendMessage' routine is bad.
>>>
>>> How is it "bad" precisely? Be specific (e.g. error message(s),
>>> description of observed incorrect behavior).
>>>
>>
>> In regards to bad would be failing to transmit claiming that the submittal
>> is wrong for the transmit string.
>>
>> (where username is my gmail username and "password" is my gmail password
>> to the test account, 6666666969 is the mobile number in question '00' is my
>> "carrier id" from the ogss code example which is just an array location from
>> a preformatted part of the string [probably from wikipedia on mobile carrier
>> email addresses to cell phones], I actually got desperate and commented out
>> the first attempt to transmit which I located in the code as just the
>> "instructions" the code fails on re-transmission, I later on looked at the
>> file and located that it was a zero byte file of no content. The program
>> itself looks for a command from the user's cell phone directly from mms sent
>> to the target gmail account prefaced by "Ogss" and anything else is treated
>> as a command but since the command failed on the first transmit I don't
>> think it's the command per se).
>>
>> owner at bouncyinc:~/Desktop/OGSS$ python ogss.py username password
>> 6666666969 00
>> Starting ogss
>> Logfile at:/home/owner/ogss.log
>> Opening log file for reading
>> Parsing user input
>> Connecting to Gmail
>> Logging into Gmail
>> Opening log file for writing
>> Listening for commands
>> Processing Command
>> ls: unrecognized option `---------------------------------------------'
>> Try `ls --help' for more information.
>> Seding back results
>> Traceback (most recent call last):
>>   File "ogss.py", line 127, in <module>
>>     main(sys.argv)
>>   File "ogss.py", line 110, in main
>>     account.sendMessage(tosend)
>>   File "/usr/lib/python2.5/site-packages/libgmail.py", line 615, in
>> sendMessage
>>     raise GmailSendError, resultInfo[SM_MSG]
>> libgmail.GmailSendError: Please try again.
>>
>> I traced the result to the sendMessage routine and noted that anytime it
>> tries to send anything it fails this also fails with the standard "docs"
>> package for libgmail 0.30 docs from the maintainer's site.
>>
>> Now the part where it *does* fail is where it has an issue with looking at
>> the trailing info but then it would have logged the info to the file and
>> emailed me back junk (which it didn't)
>>
>> I assume this could be done on any system just replace 'ls' with 'dir' or
>> the equivalent.
>>
>>
>>>
>>> > This is included in the above attachment
>>> > it's used in a program called "ogss" which is an sms interface to gmail
>>> to
>>> > basically read gmail and then have a command done on a remote machine
>>> and
>>> > then spat out on the local machine to a log file that's opened and then
>>> > emailed back
>>> > problem is that the sending back routine fails.
>>>
>>> Which routine is that exactly? Please also specify exactly how it is
>>> failing (e.g. error message(s), description of observed incorrect
>>> behavior).
>>>
>>> I apologize if these questions are answered in comments in the
>>> attachments, but to be honest, the fact that you didn't (or couldn't)
>>> put the specific problematic sections of code (and/or error messages)
>>> inline in your message makes it less likely that people (such as
>>> myself) will try to help you due to the volume of code you're making
>>> people wade through (i.e. people tend not to read large code dumps,
>>> /especially/ in attachments).
>>>
>>> Cheers,
>>> Chris
>>> --
>>> http://blog.rebertia.com
>>>
>> That's ok I understand I hope that helps at least in part.
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20090814/5c5d956f/attachment.html>


More information about the Python-list mailing list