Writing /var/lib/dokuwiki/data/meta/teaching/ie0117/proyectos/2012/i/metodos_de_utilidades.meta failed
teaching:ie0117:proyectos:2012:i:metodos_de_utilidades
This is an old revision of the document!
Métodos de utilidades
def login():
while True: os.system('clear') idnum =int(getInt('Enter your ID:',0,sys.maxint)) typed_pass= getpass.getpass('Enter your password:') key_file=open("system_key", "r") passphrase=key_file.readline(44) connection_name = MySQLdb.connect(host='localhost', user='root', passwd='K0p!r1nn4', db='DSS') cursor = connection_name.cursor() cursor.execute("SELECT AES_DECRYPT(Password,'%s') FROM USERS WHERE ID= %s " % (passphrase,idnum)) data= cursor.fetchall() real_pass=data[0][0] if(typed_pass==real_pass): cursor.execute("SELECT Privilege FROM USERS WHERE ID= %s " % (idnum)) data= cursor.fetchall() privilege=data[0][0] return privilege else: print 'Invalid ID or Password, Please try again.' time.sleep(5)
def send_mail():
connection_name = MySQLdb.connect(host='localhost', user='root', passwd='K0p!r1nn4', db='DSS') cursor = connection_name.cursor() cursor.execute("SELECT * FROM MAIL_LIST;") data= cursor.fetchall() mail_list= '' for i in xrange(len(data)): mail_list=mail_list+data[i][0]+', ' print mail_list fromaddr = 'system.inventory.alert@gmail.com' toaddrs = mail_list msg = 'Subject: %s\n%s' %('ALERT','There was a terrible error that occured and I wanted you to know!')
# Credentials (if needed)
username = 'system.inventory.alert@gmail.com' password = 'debian.debian'
# The actual mail send
server = smtplib.SMTP('smtp.gmail.com:587') server.starttls() server.login(username,password) server.sendmail(fromaddr, toaddrs, msg) server.quit()
def getInt(txt, low, high):
mode=True while True: try: mode=int(raw_input(txt)) except ValueError: print "Not a number, please try again." time.sleep(1) os.system('clear') if ((type(mode)==int) and (mode>=low) and (mode<=high)): break return mode
teaching/ie0117/proyectos/2012/i/metodos_de_utilidades.1457364358.txt.gz · Last modified: 2022/09/20 00:08 (external edit)