Форум сайта python.su
bot[0].RegisterHandler('message', messageIncoming)
bot[1].RegisterHandler('message', messageIncoming)
def OnSubindexGridCellLeftClick( self, event ):
....
dragSource = MyDropSource( self.grid )
dragSource.SetData( data )
dragSource.DoDragDrop()
event.Skip()
self.grid.Bind( wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick )
class VariableDropTarget(wx.TextDropTarget):
def __init__(self, parent):
wx.TextDropTarget.__init__(self)
self.ParentWindow = parent
def OnDropText(self, x, y, data):
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y)
....
self.VariablesGrid.SetDropTarget(VariableDropTarget(self))
class MyThread(QtCore.QThread):
def __init__(self, parent=None):
QtCore.QThread.__init__(self, parent)
def run(self):
print "do something"
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
def __init__(self):
QtGui.QMainWindow.__init__(self)
self.setupUi(self)
self.thread = MyThread()
self.connect(self.pushButton, QtCore.SIGNAL(_fromUtf8("clicked()")), self.thread.start)
self.connect(self.pushButton2, QtCore.SIGNAL(_fromUtf8("clicked()")), self.thread.exit)
serverSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
serverSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
serverSock.connect((serverHost, serverPort))
socksSock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
socksSock.connect((socksServName, socksServPort))
print "Connect to server successfuly"
socksSock.settimeout(2.0)
while(1):
clientId = (int) ( readControlField(serverSock) )
lenMsg = (int) ( readControlField(serverSock) )
print "Wait message from client"
msg = readMessage(serverSock, lenMsg)
try:
print "Send to socks server: \"",msg[0],"\" "
socksSock.sendall(msg[0])
except:
print "Error write data to server"
break
msg[0] = ""
lenMsg = 0
try:
while(True):
msg[0] += socksSock.recv(1)
print ".",
except socket.timeout:
print "timeout"
msg[0] = (str)(clientId) + "," + (str)( len(msg[0]) ) + "," + msg[0]
print "Send to client: \"",msg[0],"\""
serverSock.sendall(msg[0])
serverSock.close()
python ldap-test-starttls.py
Traceback (most recent call last):
File "ldap-test-starttls.py", line 9, in <module>
l.simple_bind_s( "cn=admin,ou=users,dc=test,dc=ru", "password" )
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 206, in simple_bind_s
msgid = self.simple_bind(who,cred,serverctrls,clientctrls)
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 200, in simple_bind
return self._ldap_call(self._l.simple_bind,who,cred,EncodeControlTuples(serverctrls),EncodeControlTuples(clientctrls))
File "/usr/lib/python2.7/dist-packages/ldap/ldapobject.py", line 96, in _ldap_call
result = func(*args,**kwargs)
ldap.SERVER_DOWN: {'info': 'A TLS packet with unexpected length was received.', 'desc': "Can't contact LDAP server"}
import ldap
host = 'ldaps://ldap:636'
l = ldap.initialize(host)
l.set_option( ldap.OPT_X_TLS_DEMAND, True )
l.set_option( ldap.OPT_DEBUG_LEVEL, 255 )
username = 'someUser'
new_pass = 'ne$wP4assw0rd3!'
new_password = ('"%s"' % new_pass).encode("utf-16-le")
l.simple_bind_s( "cn=admin,ou=users,dc=test,dc=ru", "password" )
mod_attrs = [(ldap.MOD_REPLACE, 'unicodePwd', new_password)],[( ldap.MOD_REPLACE, 'unicodePwd', new_password)]
l.modify_s('CN=%s,dc=users,dc=test,dc=ru' % username, mod_attrs)
l.unbind_s()
print "Successfully changed password."
layout.setContentsMargins(QMargins(0, 0, 0, 0))
layout.setProperty("qssMarginlessLayout", True)
QObject[qssMarginlessLayout="true"] {
margin: 0;
}
class EllipsisComboBox(QWidget):
def __init__(self, parent = None):
QWidget.__init__(self, parent)
self.horizontalLayout = QHBoxLayout(self)
self.horizontalLayout.setSpacing(0)
self.horizontalLayout.setMargin(0)
self.horizontalLayout.setObjectName(u'horizontalLayout')
self.cbCombo = QComboBox(self)
self.cbCombo.setObjectName(u'cbCombo')
self.horizontalLayout.addWidget(self)
self.tbEllipsis = QToolButton(self)
self.tbEllipsis.setObjectName(u'tbEllipsis')
self.tbEllipsis.setText(u'...')
self.horizontalLayout.addWidget(self.tbEllipsis)
void setEditorData(QWidget *editor, const QModelIndex &index) const
{
const QSqlRelationalTableModel *sqlModel = qobject_cast<const QSqlRelationalTableModel *>(index.model());
QComboBox *combo = qobject_cast<QComboBox *>(editor);
if (!sqlModel || !combo) {
QItemDelegate::setEditorData(editor, index);
return;
}
combo->setCurrentIndex(combo->findText(sqlModel->data(index).toString()));
}
def application(environ, start_response):
start_response('200 OK', [('Content-type', 'text/plain')])
return ['Hello here']
#uwsgi --uid 80 --gid 80 --http :8080 --wsgi-file test.py
#uwsgi --uid 80 --gid 80 --http :8080 --module test
[pid: 18730|app: 0|req: 1/1] 91.214.128.99 () {36 vars in 612 bytes} [Wed Sep 21 16:58:54 2011] GET / => generated [b]10[/b] bytes in 0 msecs (HTTP/1.1 200) 1 headers in 45 bytes (1 switches on core 0)
#telnet 127.0.0.1 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET / HTTP/1.1
HTTP/1.1 200 OK
Content-type: text/html
Connection closed by foreign host.
[pid: 22533|app: 0|req: 1/1] 91.214.128.99 () {36 vars in 612 bytes} [Wed Sep 21 17:27:36 2011] GET / => generated [b]100[/b] bytes in 0 msecs (HTTP/1.1 200) 1 headers in 45 bytes (1 switches on core 0)
company = models.ForeignKey(firms)
class MyAppRouter(object):
"""A router to control all database operations on models in
the myapp application"""
def db_for_read(self, model, **hints):
"Point all operations on myapp models to 'other'"
if model._meta.app_label == 'myapp':
return 'other'
return None
def db_for_write(self, model, **hints):
"Point all operations on myapp models to 'other'"
if model._meta.app_label == 'myapp':
return 'other'
return None
def allow_relation(self, obj1, obj2, **hints):
"Allow any relation if a model in myapp is involved"
if obj1._meta.app_label == 'myapp' or obj2._meta.app_label == 'myapp':
return True
return None
def allow_syncdb(self, db, model):
"Make sure the myapp app only appears on the 'other' db"
if db == 'other':
return model._meta.app_label == 'myapp'
elif model._meta.app_label == 'myapp':
return False
return None
class MasterSlaveRouter(object):
"""A router that sets up a simple master/slave configuration"""
def db_for_read(self, model, **hints):
"Point all read operations to a random slave"
return random.choice(['slave1','slave2'])
def db_for_write(self, model, **hints):
"Point all write operations to the master"
return 'master'
def allow_relation(self, obj1, obj2, **hints):
"Allow any relation between two objects in the db pool"
db_list = ('master','slave1','slave2')
if obj1._state.db in db_list and obj2._state.db in db_list:
return True
return None
def allow_syncdb(self, db, model):
"Explicitly put all models on all databases."
return True
<select name="rstatus" class="i-text">
<option value="" selected>-- АКТИВНЫЕ --
<option value="3">Заявка на оплату составлена
<option value="6">Комплектующие установлены
<option value="0">Новая
<option value="9">Отменена
<option value="1">Подписана
<option value="8">Ремонт выполнен
<option value="2">Согласована Фин. службой
<option value="4">Счет оплачен
<option value="5">Счет оплачен частично
<option value="7">Услуги по ремонту оказаны
</select>