tux indimail user adding script with python

#!/usr/bin/python
import os
for i in range(1,500):
	cmd = '/var/indimail/bin/vadduser mal'+str(i)+'@domain.com password'
	os.system(cmd)
	print cmd

indimail batch user adding like:
mail1@domain.com with password
mail2@domain.com with password
mail3@domain.com with password
..
..

March 7, 2011
Posted in Python — admin @ 12:29 pm

tux reading utf-8 files with python

Reading UTF-8 Files

You can manually convert strings that you read from files, however there is an easier way:

import codecs
fileObj = codecs.open( "someFile", "r", "utf-8" )
u = fileObj.read() # Returns a Unicode string from the UTF-8 bytes in the file

The codecs module will take care of all the conversions for you. You can also open a file for writing and it will convert the Unicode strings you pass in to write into whatever encoding you have chosen. However, take a look at the note below about the byte-order marker (BOM).

January 26, 2011
Posted in Python — admin @ 3:33 am

tux eclipse and python in ubuntu (installing pydev on ubuntu)

Eclipse

Writing a Python program can be done using any editor, even a text editor. If you are running Ubuntu Linux, you may want to edit your code using Eclipse. Eclipse is an Integrated Development Environment or IDE for building, deploying and managing software. It is a source code editor and provides trace and debugging facilities. The Eclipse Project was originally created by IBM in November 2001 and supported by a consortium of software vendors. Today, the Eclipse community consists of individuals and organizations from a cross section of the software industry.

(more…)

January 19, 2011
Posted in Python — admin @ 2:00 pm

tux python smtplib 535 authorization failed (#5.7.1)

smtplib.SMTPAuthenticationError 535 authorization failed (#5.7.1

[root@proxy1 ~]# ./mail.py
send: ‘ehlo sender.host.net\r\n’
reply: ‘250-smtp.host.net\r\n’
reply: ‘250-AUTH LOGIN PLAIN CRAM-MD5\r\n’
reply: ‘250-AUTH=LOGIN PLAIN CRAM-MD5\r\n’
reply: ‘250-PIPELINING\r\n’
reply: ‘250-8BITMIME\r\n’
reply: ‘250-SIZE 10000000\r\n’
reply: ‘250-ETRN\r\n’
reply: ‘250-ATRN\r\n’
reply: ‘250 HELP\r\n’
reply: retcode (250); Msg: smtp.host.net
AUTH LOGIN PLAIN CRAM-MD5
AUTH=LOGIN PLAIN CRAM-MD5
PIPELINING
8BITMIME
SIZE 10000000
ETRN
ATRN
HELP
send: ‘STARTTLS\r\n’
reply: ‘454 TLS missing certificate: error:02001002:system library:fopen:No such file or directory (#4.3.0)\r\n’
reply: retcode (454); Msg: TLS missing certificate: error:02001002:system library:fopen:No such file or directory (#4.3.0)
send: ‘AUTH CRAM-MD5\r\n’
reply: ‘334 ***************************=\r\n’
reply: retcode (334); Msg: ***************************=
send: ‘ ***************************\r\n’
reply: ‘535 authorization failed (#5.7.1)\r\n’
reply: retcode (535); Msg: authorization failed (#5.7.1)
Traceback (most recent call last):
File “./mail.py”, line 31, in ?
smtpserver.login(sender,password)
File “/usr/lib64/python2.4/smtplib.py”, line 587, in login
raise SMTPAuthenticationError(code, resp)
smtplib.SMTPAuthenticationError: (535, ‘authorization failed (#5.7.1)’)

solution

ADD redline after ehlo()

smtpserver.ehlo()
smtpserver.esmtp_features["auth"] = “LOGIN PLAIN”
smtpserver.starttls()
..

also you can pass into debug mode with “smtpserver.set_debuglevel(1)

November 19, 2010
Posted in Python — admin @ 12:12 am

tux lightweight mail server with python twisted

i just found a new mail server daemon, developed with python twisted

codes are simple and can be implemented quickly.

project home: https://launchpad.net/txmailserver
to download :

bzr branch lp:txmailserver

November 17, 2010
Posted in Python — admin @ 1:07 am

tux How to Decoding Morse and Encoding Morse with Python

Python Morse Converter

Maybe one day you can meet an asume alien girl however she don’t know any language except morse alphabet (she communicates only this way:-)). So, what will you do? Dont be sad cause i wrote a python code to decode what she says and encode yours.
(more…)

November 30, 2009
Posted in Python — banias @ 12:35 pm

tux How Can You Run a Program With Arguments in Command-Line(Python,C++)

A command-line argument is the information that follows the name of the program on the command line of the operating system.

(more…)

November 15, 2009
Posted in C++, Programming, Python — TaZ @ 10:58 pm