sending HTML emails with inline images attached

#! /usr/bin/python
# -*- coding: utf-8 -*-
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.header import Header

def sendEmail(you,greatingLine):
        # me == my email address
        # you == recipient's email address
        me = "VFSN Praesident "

        # Create message container - the correct MIME type is multipart/alternative.
        #msg = MIMEMultipart('alternative')
        msg = MIMEMultipart('related')
        msg['Subject'] = Header("Verein Flugschneise Süd - NEIN","utf-8")
        msg['From'] = me
        msg['To'] = you

        # Create the body of the message (a plain-text and an HTML version).
        f = open('Mail_4.html', 'r')
        mail_content = f.read()
        f.close()
        mail_content = mail_content.replace('%Anrede%',greatingLine)
        mail_content = mail_content.replace('vfsn.gif','cid:vfsn.gif')
        html = mail_content
                                                                                                                                                                                                
        # Record the MIME types of both parts - text/plain and text/html.                                                                                                                       
        part2 = MIMEText(html, 'html')                                                                                                                                                          
                                                                                                                                                                                                
        part3_data = open('vfsn.gif', 'rb').read()                                                                                                                                              
        part3 = MIMEImage(part3_data, 'gif')                                                                                                                                                    
        part3.add_header('Content-ID', '')                                                                                                                                            
        part3.add_header('Content-Disposition', 'attachment', filename='vfsn.gif')
        part3.add_header('Content-Disposition', 'inline', filename='vfsn.gif')

        part4_data = open('Bauverbot im Sueden_2_LQ.pdf', 'rb').read()
        part4 = MIMEImage(part4_data, 'pdf')
        part4.add_header('Content-Disposition', 'attachment', filename='Bauverbot im Sueden_2_LQ.pdf')
        part4.add_header('Content-Disposition', 'inline', filename='Bauverbot im Sueden_2_LQ.pdf')

        # Attach parts into message container.
        # According to RFC 2046, the last part of a multipart message, in this case
        # the HTML message, is best and preferred.
        msg.attach(part2)
        msg.attach(part3)
        msg.attach(part4)

        # Send the message via local SMTP server.
        s = smtplib.SMTP('localhost')
        # sendmail function takes 3 arguments: sender's address, recipient's address
        # and message to send - here it is sent as one string.
        s.sendmail(me, you, msg.as_string())
        s.quit()

csv = open('Adressen_4.csv','r').read()
for line in csv.split('\n')[1:]:
        lineArray=line.split(',')
        try:
                ret=lineArray[7]+" "+lineArray[4]+" "+lineArray[5]
                ret=ret.strip()
                if ret=="":
                        ret=False
        except:
                ret=False

        Anrede=ret

        try:
                ret=lineArray[12]
                ret=ret.strip()
                if ret=="":
                        ret=False
        except:
                ret=False

        Mail = ret

        if Mail and Anrede:
                print 'Sending to '+Mail+' with rcp message '+Anrede
                try:
                        sendEmail(Mail,Anrede)
                except:
                        continue

openerp on CentOS-6 (with RPM)

Howdy
First fit the package depencies like described here: http://gurn3ys.tuxfamily.org/?p=65
Somehow the installation prefix of the RPMs from the daily build service(http://nightly.openerp.com/7.0/nightly/rpm/) points to /usr/local which is… unhandy
The solution is to overwrite some rpm macros which check for unpacked files…
echo “%__os_install_post %{nil}” >> ~/.rpmmacros
And then installing and rebuilding the srpm with rpmbuild -ba

networkboot, u-boot, tftp

Hi
I’m using the following boot script in order to boot uImage and device tree blob directly from my PC.
No SD card removal, no flashing.
It boots out of RAM immediately
Edit ips and ethernet address accordingly to your network and hardware configuration.
Enjoy

setenv initrd_high 0xffffffff                                                      
setenv fdt_high 0xffffffff
setenv bootargs "root=/dev/mmcblk0p1  rootdelay=10 rw console=ttyS0,115200 panic=10 clk_ignore_unused"
setenv ethaddr D2:91:80:B7:AB:5C
setenv serverip 192.168.1.147
setenv ipaddr 192.168.1.145
ext4load mmc 0 0x43000000 boot/script.bin
tftp 0x49000000 sun7i-a20-cubieboard2.dtb
tftp 0x46000000 uImage
bootm 0x46000000 - 0x49000000

linux-next on INet-97F Rev 02

As you might recall from my last post, I was trying to get linux-next running on the INet-97F Rev 02 as it can be found within the Odys Xelio and many other low cost consumer tablets made in China.
I now successfully managed to boot the linux-next uImage with a rudimentary DTB on it.
You can find the commit with the DTS added on my git repository: http://git.o2s.ch/?p=linux-next.git;a=commit;h=5495b546b3572f001c84a8c74e7547c5cc88d704
Unfortunately mainline doesn’t yet contain the sunxi-kms graphics driver since it yet needs to be finally developed and ported forward by Luc Verhaegen.
As soon as his driver patches hit mainline, as well as the ones from Boris Brezillon (for NAND) I will be able to provide fully functional vanilla kernel builds for MER-Project and openSUSE builds.
So stay tuned! 😉

linux-next on cubieboard2

It lives! *muahahaha*
U-Boot from https://github.com/jwrdegoede/u-boot-sunxi with branch sunxi-next
Kernel from https://github.com/linux-sunxi/linux-sunxi with branch sunxi-devel (which is the next development branch of the sunxi upstream community)

cubie:~ # cat /proc/cpuinfo
processor       : 0
model name      : ARMv7 Processor rev 4 (v7l)
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 4

processor       : 1
model name      : ARMv7 Processor rev 4 (v7l)
Features        : swp half thumb fastmult vfp edsp thumbee neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae 
CPU implementer : 0x41
CPU architecture: 7
CPU variant     : 0x0
CPU part        : 0xc07
CPU revision    : 4

Hardware        : Allwinner sun7i (A20) Family
Revision        : 0000
Serial          : 0000000000000000

Mein potentielles schlechte Laune Ablassventil