Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8206657
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:45:02+00:00 2026-06-07T08:45:02+00:00

I just get the error: AttributeError: SecondLife instance has no attribute ‘sendAMail’ Whats wrong?

  • 0

I just get the error:

AttributeError: SecondLife instance has no attribute 'sendAMail'

Whats wrong?
(I checked the formating and this is not the error.
I checked the syntax and also not the error.)

What in the script happens is that an url gets open with cookies and i want some information from it.

import urllib2, cookielib, re
import ClientForm
import re
import smtplib

kurse = ['Entwicklung von Multimediasystemen', 'Computergrafik', 'Gestaltung von Multimediasystemen', 'Verteilte Systeme']

class SecondLife:

    def __init__(self, usernames, password):
        self.username = usernames
        self.password = password
        self.url = 'https://lsf.htw-berlin.de/qisserver/rds?state=user&type=0&application=QISPOS'

        cookiejar = cookielib.LWPCookieJar()
        cookiejar = urllib2.HTTPCookieProcessor(cookiejar)
        # debugger = urllib2.HTTPHandler(debuglevel=1)

        opener = urllib2.build_opener(cookiejar)
        urllib2.install_opener(opener)

    def sendAMail(self, smtp_server, user, password, listener, subject, text):
        smtp = smtplib.SMTP(smtp_server)
        smtp.starttls()
        smtp.login(user,password)
        msg = "SUBJECT: " + subject + "\n\n" + text
        smtp.sendmail("bln.schade@gmail.com", listener, msg)
        smtp.quit()

    def login(self):
        response = urllib2.urlopen(self.url)
        forms = ClientForm.ParseResponse(response, backwards_compat=False)

        # forms[0] is 'GET', forms[1] is 'POST'
        form = forms[0]

        try:
            form['username'] = self.username
            form['password'] = self.password
        except Exception, e:
            print 'The following error occured: \n"%s"' % e
            print
            print 'A good idea is to open a browser and see if you can log in from there.'
            print 'URL:', self.url

            exit()

        self.page = urllib2.urlopen(form.click('submit')).read()

    def friends_online(self):

        self.login()

        final = ""
        final_asi = ""
        leistungsstand = ""
        match = re.search(r"asi=\w*\d*\"", self.page)

        if match:
            final = match.group()
            final_asi = re.sub("asi=", "", final)
            final_asi = re.sub("\"", "", final_asi)

            print "vorher: " + final
            print "nachher: " + final_asi

            leistungsstand_url = "https://lsf.htw-berlin.de/qisserver/rds?state=htmlbesch&application=sospos&moduleParameter=Student&navigationPosition=functions%2Cnotenspiegel&breadcrumb=notenspiegel&topitem=functions&subitem=notenspiegel&asi=" + final_asi
            leistungsstand = urllib2.urlopen(leistungsstand_url).read()
        else:
            print "not match"



        # Ausloggen
        logout = "https://lsf.htw-berlin.de/qisserver/rds?state=user&type=4&re=last&menuid=logout&category=auth.logout"
        urllib2.urlopen(logout).read()

        website = open("lsf.html", "w")
        website.write(leistungsstand)
        website.close()

        for kurs in kurse:
            print kurs

            if (re.search(kurs, "fajfjsjj Entwicklung von Multimediasystemen hahahah")):
                self.sendAMail("smtp.googlemail.com", "user", "passw", "bln.schade@gmail.com", "kurs" , "Eine neue Note ist im LSF eingetragen.")


        #self.final_asi.replace(new, "asi=","")
        #asi[0].replace("\"","")


        #print "Final " + asi





SL = SecondLife('xyz', 'xyz')
SL.friends_online()
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T08:45:04+00:00Added an answer on June 7, 2026 at 8:45 am

    Works for me: printing out self.sendAMail from within an instance gives

    <bound method SecondLife.sendAMail of <__main__.SecondLife instance at 0x101d91e18>>
    

    I think it is a formatting issue, though. If I copy and paste your code and look at the whitespace, I see mixed use of spaces and tabs. In particular:

    In [20]: [line for line in d if 'def' in line]
    Out[20]: 
    ['        def __init__(self, usernames, password):\n',
     '    \tdef sendAMail(self, smtp_server, user, password, listener, subject, text):\n',
     '        def login(self):\n',
     '        def friends_online(self):\n']
    

    The \t before def sendAMail looks very suspicious. I’m 75% sure the inconsistent whitespace is what’s causing the problem. Try running your script using python -tt scriptname.py, which will throw an error about inconsistent tab usage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am getting an error message that says AttributeError: 'NoneType' object has no attribute
I am just wondering how i can get the error causing LoginUser function to
Having just added a new button in my web application, I get an error
While consuming SOAP service, I am getting this error. I just dun get it
Pardon for this, i just get this error in console but i can't see
I am a little stuck. Why wont this work? I just get a error
I just get started using BDD in Rails application, but I'm not sure what
I just get a script from a website to put it on my own
I've just get a new machine and try to checkout, build and launch my
I want just get Image( .JPG , .PNG , .Gif ) File from my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.