Форум сайта python.su
import smtplib
from email.MIMEText import MIMEText
from extract import MAILS
def send(to):
you = to
# текст письма
text = 'Здравствуйте!'
# заголовок письма
subj = 'САБЖ'
server = "smtp.km.ru"
name,pwd,me = "pythont","123456","pythont@km.ru"
user_name = name
user_passwd = pwd
msg = MIMEText(text, "", "utf-8")
msg['Subject'] = subj
msg['From'] = me
msg['To'] = you
s = smtplib.SMTP(server, port)
s.starttls()
s.login(user_name, user_passwd)
s.sendmail(me, you, msg.as_string())
s.quit()
send("youmail@yandex.ru")
client = suds.client.Client(WSDLfile)
client.service.Login('mylogin', 'mypass')
print client.options.transport.cookiejar
<cookielib.CookieJar[<Cookie sessnum=9WAXQ25D37XY535F6SZ3GXKSCTZG8CVJ for .IP.IP.IP.IP/>]>
<cookielib.CookieJar[]>
# -*- coding: utf-8 -*-
import pythoncom, pyHook
import codecs, sys, os
outf = codecs.getwriter('cp866')(sys.stdout, errors='replace')
sys.stdout = outf
def OnKeyboardEvent(event):
print event.Ascii
if event.KeyID == 192:
exit(1)
return True
hm = pyHook.HookManager()
hm.KeyDown = OnKeyboardEvent
hm.HookKeyboard()
pythoncom.PumpMessages()
class srcTableModel(QtCore.QAbstractTableModel):
def __init__(self, fileName = QtCore.QString()):
super (srcTableModel, self).__init__()
self.ships = []
self.fileName = fileName
self.dirty = True
def rowCount (self, index=QtCore.QModelIndex()):
return len(self.ships)
def columnCount (self, index=QtCore.QModelIndex()):
return 11
def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole):
if role != QtCore.Qt.DisplayRole:
return
if orientation == QtCore.Qt.Horizontal:
if section == EQUIPMENT:
return (QtGui.QApplication.translate("MainWindow", "Виробництво", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCCODE:
return (QtGui.QApplication.translate("MainWindow", "№ дж.", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCNAME:
return (QtGui.QApplication.translate("MainWindow", "Найменув. дж.", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCX1:
return (QtGui.QApplication.translate("MainWindow", "X,м", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCY1:
return (QtGui.QApplication.translate("MainWindow", "Y,м", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCTYPE:
return (QtGui.QApplication.translate("MainWindow", "Тип дж.", None, QtGui.QApplication.UnicodeUTF8))
elif section == ZONESIZE:
return (QtGui.QApplication.translate("MainWindow", "Розмір СЗЗ", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCHEIGHT:
return (QtGui.QApplication.translate("MainWindow", "Висота дж., м", None, QtGui.QApplication.UnicodeUTF8))
elif section == SRCDIAMETER:
return (QtGui.QApplication.translate("MainWindow", "Діаметер дж., м", None, QtGui.QApplication.UnicodeUTF8))
elif section == GASDEPLETION:
return (QtGui.QApplication.translate("MainWindow", "Витрата ПГВС, м3/с", None, QtGui.QApplication.UnicodeUTF8))
elif section == GASTEMPERATURE:
return (QtGui.QApplication.translate("MainWindow", "Темпер. ПГВС", None, QtGui.QApplication.UnicodeUTF8))
return int(section + 1)
def data (self, index, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len(self.ships):
ship = self.ships [index.row()]
column = index.column()
if role == QtCore.Qt.DisplayRole:
if column == EQUIPMENT:
return QtCore.QVariant(ship.equipment)
elif column == SRCCODE:
return QtCore.QVariant(ship.srcCode)
elif column == SRCNAME:
return QtCore.QVariant(ship.srcName)
elif column == SRCX1:
return QtCore.QVariant(ship.srcX1)
elif column == SRCY1:
return QtCore.QVariant(ship.srcY1)
elif column == SRCTYPE:
return QtCore.QVariant(ship.srcType)
elif column == ZONESIZE:
return QtCore.QVariant(ship.zoneSize)
elif column == SRCHEIGHT:
return QtCore.QVariant(ship.srcHeight)
elif column == SRCDIAMETER:
return QtCore.QVariant(ship.srcDiameter)
elif column == GASDEPLETION:
return QtCore.QVariant(ship.gasDepletion)
elif column == GASTEMPERATURE:
return QtCore.QVariant(ship.gasTemperature)
return
def flags(self, index):
if not index.isValid():
return QtCore.Qt.ItemIsEnabled
return QtCore.Qt.ItemFlags(QtCore.QAbstractTableModel.flags(self, index)|QtCore.Qt.ItemIsEditable)
def setData (self, index, value, role=QtCore.Qt.DisplayRole):
if index.isValid() and 0 <= index.row() < len (self.ships):
ship = self.ships [index.row()]
column = index.column()
if column == EQUIPMENT:
ship.equipment = value.toString()
elif column == SRCCODE:
value, ok = value.toInt()
if ok:
ship.srcCode = value
elif column == SRCNAME:
ship.srcName = value.toString()
elif column == SRCX1:
value, ok = value.toInt()
if ok:
ship.srcX1 = value
elif column == SRCY1:
value, ok = value.toInt()
if ok:
ship.srcY1 = value
elif column == SRCTYPE:
ship.srcType = value.toString()
elif column == ZONESIZE:
value, ok = value.toInt()
if ok:
ship.zoneSize = value
elif column == SRCHEIGHT:
value, ok = value.toInt()
if ok:
ship.srcHeight = value
elif column == SRCDIAMETER:
value, ok = value.toInt()
if ok:
ship.srcDiameter = value
elif column == GASDEPLETION:
value, ok = value.toInt()
if ok:
ship.gasDepletion = value
elif column == GASTEMPERATURE:
value, ok = value.toInt()
if ok:
ship.gasTemperature = value
self.dirty = True
self.emit(QtCore.SIGNAL("dataChanged(QModelIndex, QModelIndex)"), index, index)
return True
return False
def insertRows (self, position, rows=1, index=QtCore.QModelIndex()):
self.beginInsertRows(QtCore.QModelIndex(), position, position + rows - 1)
for row in range(rows):
self.ships.insert(position + row, srcShip("Unknown", 0, "Unknown", 0, 0, "Unknown", 0, 0, 0, 0, 0))
self.endInsertRows()
self.dirty = True
return True
def removeRows(self, position, rows=1, index=QtCore.QModelIndex()):
self.beginRemoveRows(QtCore.QModelIndex(), position, position + rows - 1)
self.ships = self.ships[:position] + self.ships [position + rows:]
self.endRemoveRows()
self.dirty = True
return True
def loadFile(self, fileName):
exception = None
fh = None
self.fileName = QtCore.QString(fileName)
try:
if self.fileName.isEmpty():
raise IOError, "no fileName specified for loading"
fh = QtCore.QFile(self.fileName)
if not fh.open(QtCore.QIODevice.ReadOnly):
raise IOError, unicode(fh.errorString())
stream = QtCore.QDataStream(fh)
magic = stream.readInt32()
if magic != MAGIC_NUMBER:
raise IOError, "unrecognized file type"
fileVersion = stream.readInt16()
if fileVersion != FILE_VERSION:
raise IOError, "unrecognized file type version"
stream.setVersion(QtCore.QDataStream.Qt_4_5)
self.ships = []
while not stream.atEnd():
equipment = QtCore.QString()
stream >> equipment
srcCode = stream.readInt32()
srcName = QtCore.QString()
stream >> srcName
srcX1 = stream.readInt32()
srcY1 = stream.readInt32()
srcType = QtCore.QString()
stream >> srcType
zoneSize = stream.readInt32()
srcHeight = stream.readInt32()
srcDiameter = stream.readInt32()
gasDepletion = stream.readInt32()
gasTemperature = stream.readInt32()
self.ships.append(srcShip(equipment, srcCode, srcName, srcX1, srcY1, srcType, zoneSize, srcHeight, srcDiameter, gasDepletion, gasTemperature))
self.reset()
self.dirty = False
except (IOError, OSError), e:
exception = e
finally:
if fh is not None:
fh.close()
if exception is not None:
raise exception
def saveFile(self):
exception = None
fh = None
try:
if self.fileName.isEmpty():
self.fileName = QtGui.QFileDialog.getSaveFileName(None, "Ships - Choose Save File", "", "Trianon project (*.tri)")
fh = QtCore.QFile(self.fileName)
if not fh.open(QtCore.QIODevice.WriteOnly):
raise IOError, unicode(fh.errorString())
stream = QtCore.QDataStream(fh)
stream.writeInt32(MAGIC_NUMBER)
stream.writeInt16(FILE_VERSION)
stream.setVersion(QtCore.QDataStream.Qt_4_5)
for ship in self.ships:
stream << QtCore.QString(ship.equipment)
stream.writeInt32(ship.srcCode)
stream << QtCore.QString(ship.srcName)
stream.writeInt32(ship.srcX1)
stream.writeInt32(ship.srcY1)
stream << QtCore.QString(ship.srcType)
stream.writeInt32(ship.zoneSize)
stream.writeInt32(ship.srcHeight)
stream.writeInt32(ship.srcDiameter)
stream.writeInt32(ship.gasDepletion)
stream.writeInt32(ship.gasTemperature)
self.dirty = False
except IOError, e:
exception = e
finally:
if fh is not None:
fh.close()
if exception is not None:
raise exception
Mb-3:mysite dmitryvinogradov$ python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 362, in execute_manager
utility.execute()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/__init__.py", line 303, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 195, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 221, in execute
self.validate()
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/base.py", line 249, in validate
num_errors = get_validation_errors(s, app)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/core/management/validation.py", line 22, in get_validation_errors
from django.db import models, connection
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 41, in <module>
backend = load_backend(settings.DATABASE_ENGINE)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/__init__.py", line 17, in load_backend
return import_module('.base', 'django.db.backends.%s' % backend_name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 13, in <module>
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
django.core.exceptions.ImproperlyConfigured: Error loading MySQLdb module: dynamic module does not define init function (init_mysql)
Mb-3:mysite dmitryvinogradov$ easy_install MySQL-python
Searching for MySQL-python
Best match: MySQL-python 1.2.3c1
Processing MySQL_python-1.2.3c1-py2.6-macosx-10.3-fat.egg
MySQL-python 1.2.3c1 is already the active version in easy-install.pth
Using /Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-packages/MySQL_python-1.2.3c1-py2.6-macosx-10.3-fat.egg
Processing dependencies for MySQL-python
Finished processing dependencies for MySQL-python
import curses
screen = curses.initscr()
urlpatterns = patterns('',
...
(r'^tag/ (?P<tag>[^/]+)/$', 'tagging.views.tagged_object_list'),
)
class BlogPost(models.Model):
...
tags = TagField ()
{% load tagging_tags cache %}
{% cache 20 tags %}
{% tag_cloud_for_model blog.BlogPost as tags with steps=300 distribution=log min_count=2 %}
{% for tag in tags %}
<a href="/news/tag/{{tag.slug}}/" style="font-size: {{tag.font_size|add:"60"}}%;" title="{{ tag.count }}">
{{tag.name}}
</a>
{% endfor %}
{% endcache %}
self.ppmenu_xml = """
<popup name="button3">
<menuitem name="Обновить цитаты" verb="Reload" stockid="gtk-refresh" />
<menuitem name="O программе" verb="About" stockid="gtk-about" />
</popup>
"""
self.ppmenu_verbs = [
("About", self.on_ppm_about),
("Reload", self.reload_quote)
]
self.applet.setup_menu(self.ppmenu_xml, self.ppmenu_verbs, None)
from __future__ import unicode_literals, print_function # anything?
def test():
"""
>>> 1+1
2
"""
pass
import doctest
doctest.testmod()
...>"c:\Program Files (x86)\IronPython 2.6\ipy.exe" test.py
**********************************************************************
File "test.py", line 5, in __main__.test
Failed example:
1+1
Exception raised:
Traceback (most recent call last):
File "c:\Program Files (x86)\IronPython 2.6\Lib\doctest.py", line 1240, in
_DocTestRunner__run
exec compile(example.source, filename, "single",
ValueError: unrecognized flags
**********************************************************************
1 items had failures:
1 of 1 in __main__.test
***Test Failed*** 1 failures.