Category Archives: Uncategorized

Python GMail SMTP Send Email Script

Here is a small script that i made some time ago , it uses GMail’s mail servers to send an email.

#!/usr/bin/python
# PyGms 1.0
# Gmail SMTP  Script Made by Djays


import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEBase import MIMEBase
from email.MIMEText import MIMEText
from email import Encoders
import os

ver = "v1.0"
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+="nnn_________________________nMail generated By  PyGmS "+ver+"n       - Made By Djaysn        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()

mailto   =  raw_input("Enter Recepients (Seperated By a Comma): ")
mailtoBcc=  raw_input("Enter BCCRecepients (Seperated By a Comma): ")
mailsubj =  raw_input("Enter Subject: ")
mailmsg  =  raw_input("Enter Message: ")
mailattch = ""
newmail  = mailz()

while 1:
 mailattch = ""
 c = raw_input("Attach a File ? (y/n)")
 if c == 'n':
   break
 if c != 'y':
   continue
 mailattch = raw_input("Enter Path of file: ")
 newmail.attach(mailattch)
newmail.mailprep(mailto,mailsubj,mailmsg)

newmail.sendmail()

Get updates of completed torrents via SMS Part 2

The other day one of my friends Ankur , made a python script to get updates via sms using twitter account.
Check here :http://tinyurl.com/djbnon

I have changed the script to use Gmail SMTP instead .
Enjoy

import dbus,base64,urllib2,urllib
from dbus.mainloop.glib import DBusGMainLoop
import smtplib
from email.MIMEMultipart import MIMEMultipart
from email.MIMEText import MIMEText
from email import Encoders
import os

ver = "v1.0"
gmail_user = ""				                #Gmail Username

gmail_pwd  = ""					#Gmail Password
gmail_alias=" "+gmail_user                       #Gmail Nickname
gateway=""	# Check http://tinyurl.com/d5ghcv

def mailz(text):

    mail = MIMEMultipart()
    mail['From'] = gmail_alias

    mail['To'] = gateway
    mail.attach(MIMEText(text))
    mailServer = smtplib.SMTP("smtp.gmail.com", 587)
    mailServer.ehlo()
    mailServer.starttls()
    mailServer.ehlo()
    mailServer.login(gmail_user, gmail_pwd)
    mailServer.sendmail(gmail_user, gateway, mail.as_string())
    mailServer.close()

DBusGMainLoop(set_as_default=True)

s = dbus.SessionBus()
kt = s.get_object("org.ktorrent.ktorrent","/core")

def update(k):
        torrent = s.get_object("org.ktorrent.ktorrent","/torrent/"+k)
        name = torrent.get_dbus_method("name","org.ktorrent.torrent")
        mailz("ktorrent: finished " +name())

kt.connect_to_signal("finished",update)

import gobject
loop = gobject.MainLoop()
loop.run()

Fedora 10 Fglrx

Finally the RPMFusion Stable NonFree Updates repositories have the fglrx driver
All steps are to be executed in root/super-user mode

1) Get RPMFusion Repos.

rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm

2) Install Fglrx

yum  install akmod-fglrx xorg-x11-drv-fglrx xorg-x11-drv-fglrx-libs -y

3) Blacklist radeon
Add

blacklist radeon

to /etc/modprobe.d/blacklist

4) Reboot

5) Make initrd

– While booting at grub press ‘e’ in line starting with kernel. Add ‘single’ to the end. Press ‘ESC’ & press ‘b’

cd /boot/
rm initrd-`uname -r`.img
mkinitrd initrd-`uname -r`.img `uname -r` --with=fglrx

6)Reboot

NOTE: You might have to do

aticonfig --initial -f

Install fglrx from rpmfusion testing repos

Now the fglrx driver is available in testing repos it can be installed .Since its in testing repos it is not recommended.
Older Guide: http://fglrx.djsh.net Older Guide’s Install Script: http://installfglrx.djsh.net

Make sure you have rpm-fusion repo installed

rpm -Uvh http://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-stable.noarch.rpm http://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-stable.noarch.rpm

Install Driver using yum

yum --enablerepo=rpmfusion-nonfree-updates-testing install akmod-fglrx xorg-x11-drv-fglrx xorg-x11-drv-fglrx-libs.

fglrx Install script fedora 10

THIS SCRIPT IS NO LONGER REQUIRED SINCE PACKAGES IN RPMFUSION REPO WORK .

http://djsh.net/2009/01/26/fedora-10-fglrx/

Note:

– Remove all packages related to previous attempts to install fglrx

– It now supports x86_64 but requires more testing on the platform

– Since its new it will have many unobserved bugs even though it has been tested

-This uses the ati driver at http://ati.amd.com/support/driver.html

-For x86_64 bit OS you can either select  64 bit driver (while installing) or install 32 bit driver and remove # sign in front of a section called NOTE.

-If any bugs are encountered please comment about them (with details) at this blog.

To install put driver and script in same folder and run sh installfglrx (root mode)

DOWNLOAD LINK

AFTER INSTALL(if everything is working_:

edit /boot/grub/menu.conf

instead  of nomodset put vga=0xA

A is the VESA mode http://en.wikipedia.org/wiki/VESA_BIOS_Extensions


Using Mandriva 2009 , GeexBox 1.2 beta

I think its a kernel issue with 2.6.27 that acpi is switched on unsupported bios models.

Hence In Mandirva 2009

boot to live cd Press F3 then F4 select acpi=off. (Or the system will crawl)

If you are not able to get a GUI boot like me then ..

1)login with username  root

2)run drakX11 then configure various your graphics card and Resolution (Dont forget to use the ‘Test’ option)

(For ATI x1250 use fglrx (faster) or radeonhd (slower))

3) After install  edit /boot/grub/menu.lst

and add acpi=off to your options in kernel line if ts not there already

GeexBox 1.2 beta

Same story

While booting press ‘TAB’ add acpi=off in kernel line.

Currently HDMode doesn’t work with many Graphics Cards like ATI x1250 (again xorg issues)

so Start in non HD mode only.