Форум сайта python.su
# recipy1.py # как написать import для module1? import unittest class Test1(unittest.TestCase): def test_testtest(self): self.assertEquals(100,100) def test_fakeclass(self): obj = module1.SomeClass( 10 ) self.assertEquals(10, obj.GetValue() ) if __name__ == '__main__': unittest.main()
# module1.py class SomeClass(): def __init__(self, value): self.value = value def GetValue(self): return self.value
Traceback (most recent call last):
File "D:\Program Files\eclipse\plugins\org.python.pydev.debug_2.4.0.2012020116\pysrc\pydevd_comm.py", line 253, in OnRun
r = r.decode('utf-8')
UnicodeDecodeError: 'utf8' codec can't decode byte 0xea in position 25: invalid continuation byte
struct AuthSalt {
1: required i64 client, /* случайные данные генерируемы клиентом. */
2: required i64 server, /* salt-данные из предыдущего ответа сервера. */
}
struct AuthRequest {
1: required AuthSalt bootstrap,
2: required string who, /* логин пользователя. */
3: required string signature, /* SHA-1 дайджест от слияния bootstrap + password + who + bootstrap. */
}
exception NotAuthorisedException {
1: required string description
}
service Bookworm {
AuthResponse Authenticate( 1: required AuthRequest a, 2: required string locale )
throws ( 1: NotAuthorisedException e )
}
bw_authsalt = AuthSalt(0,0) #создаем объект, который будем использовать при создании AuthRequest
dig.update(bw_authsalt)
dig.update(password + login)
dig.update(bw_authsalt)
SHA_CTX c;
::SHA1_Init(&c);
::SHA1_Update(&c, &bootstrap, sizeof(bootstrap));
::SHA1_Update(&c, password.c_str(), password.size());
::SHA1_Update(&c, who.c_str(), who.size());
::SHA1_Update(&c, &bootstrap, sizeof(bootstrap));
::SHA1_Final(digest, &c);
Traceback (most recent call last):
File "./bw_client.py", line 44, in <module>
client.Authenticate(bw_authreq, 'rus')
File "./gen-py/bookworm/Bookworm.py", line 50, in Authenticate
self.send_Authenticate(a, locale)
File "./gen-py/bookworm/Bookworm.py", line 58, in send_Authenticate
args.write(self._oprot)
File "./gen-py/bookworm/Bookworm.py", line 213, in write
self.a.write(oprot)
File "./gen-py/bookworm/ttypes.py", line 161, in write
oprot.writeString(self.digest)
File "/usr/local/lib/python2.6/dist-packages/thrift/protocol/TBinaryProtocol.py", line 122, in writeString
self.writeI32(len(str))
TypeError: object of type '_hashlib.HASH' has no len()
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b76250), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b76250), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::LabelEngine(0x2b77b20), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::LabelEngine(0x2b77b20), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QPixmap: It is not safe to use pixmaps outside the GUI thread
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
QObject: Cannot create children for a parent that is in a different thread.
(Parent is Oxygen::WidgetStateEngine(0x2b70370), parent's thread is QThread(0x1b6c7f0), current thread is QThread(0x302f600)
[xcb] Unknown request in queue while dequeuing
[xcb] Most likely this is a multi-threaded client and XInitThreads has not been called
[xcb] Aborting, sorry about that.
python2: /var/calculate/tmp/portage/x11-libs/libX11-1.4.4/work/libX11-1.4.4/src/xcb_io.c:178: dequeue_pending_request: Проверочное утверждение «!xcb_xlib_unknown_req_in_deq» не выполнено.
Аварийный останов
from miro.platform import xlibhelper
if xlibhelper.XInitThreads() == 0:
print "WARNING: XInitThreads() failed!"
class UserTableModel(QtCore.QAbstractTableModel):
def __init__(self, data = [[]], headers = [], parent = None):
QtCore.QAbstractTableModel.__init__(self, parent)
if headers:
self.__data = [[[]] * len(headers)] # just for DEBUG
else:
self.__data = data
self.__headers = headers
........
# ВОТ ТАК:
def clear(self):
self.beginResetModel()
self.__data = []
self.endResetModel()
PMTEMsg = ^TMTEMsg;
TMTEMsg = record
DataLen: Integer; // Длина следующих далее данных
Data: record end; // Данные переменной длины
end;
function MTEStructure(Idx: Integer; var Msg: PMTEMsg): Integer;
import ctypes as cc
bridge=cc.WinDLL("my.dll")
idx=0
struct=bridge.MTEStructure(idx,Msg)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import PyQt4.QtGui as QtGui
import PyQt4.Qt as Qt
import PyQt4.QtCore as QtCore
import sys
class MainTab(QtGui.QTabWidget):
def focusInEvent (self, ev):
print "MainTab focus event"
QtGui.QTabWidget.focusInEvent(self, ev)
def init(self):
self.connect(self, QtCore.SIGNAL("currentChanged (int)"), self.currentChanged_slot)
def currentChanged_slot(self, i):
print "MainTab currentChanged_slot ", i
self.currentWidget().setFocus()
class SecondTab(QtGui.QTabWidget):
def focusInEvent(self, ev):
print "SecondTab focus event"
QtGui.QTabWidget.focusInEvent(self, ev)
app = QtGui.QApplication(sys.argv)
MWin = QtGui.QMenuBar()
tab = MainTab(MWin)
tab.init()
tab0 = SecondTab()
tab1 = SecondTab()
wdg0 = QtGui.QWidget()
wdg1 = QtGui.QWidget()
tab0.addTab(wdg0, '1')
tab1.addTab(wdg1, '2')
tab.addTab(tab0, 'one')
tab.addTab(tab1, 'two')
MWin.resize(790, 590)
MWin.show()
sys.exit(app.exec_())
class r1_S:
"""Мощность одной фазы и одного стержня"""
def __init__(self, product):
self.name = 'r1_S'
self.product = product
# Данные, которые используются в этой формуле
self.S = product.ut['S_kVA'] # Полная мощность
self.m = product.ut['phase_num'] # Число фаз
def count(self):
# Вычисление
self.Sf = float(self.S) / self.m
# Запись результатов
self.product.math['Sf'] = self.Sf
def text(self):
# Текстовая аннотация
self.product.text += [
"""Мощность одной фазы и одного стержня:
S_ф = S\' = S/m = {0}/{1} = {2}""".format(self.S, self.m, self.Sf)]
def to_journal(self):
# Запись в журнал Изделия
self.product.journal.append( {'handler_name': self.name, 'Sf': self.Sf} )
def to_journal(self):
# Запись в журнал Изделия
self.product.journal.append( {'handler_name': self.name, 'Sf': self.Sf} )
obj = MyObject()
obj.attr1 = ...
obj.attr2 = ...
...
obj.attrn = ...
obj = {}
obj['attr1'] = ...
obj['attr2'] = ...
...
obj['attrn'] = ...