problem installing a module
Hello i try to install pyvisa under winxp sp3 i get this error: home_dir =os.environ['HOME'] return self.data[key.upper()] key error : 'HOME' i have installed a lot of tyme pyvisa and this is the first time that i get this error. Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
invio di una stringa
ciao a tutti sniffando i dati del protocollo irc con wireshark noto che a un certo punto per il resume di un trasferimento un noto programma manda questa stringa: PRIVMSG Ex|testtrasf|001 :\001DCC RESUME prova_trasferimento.pdf 58772 5016204\001 a questo punto il server risponde. Utilizzando i socket io riesco a connettermi al server ed a inviargli tuti i messaggi che voglio, ma quando mando il comando sopra scritto il server non mi risponde. La mia domanda è \001 a cosa corrisponde? penso che l'inghippo sia li, perche gli altri comandi che non hanno lo \001 vengono digeriti bene? Grazie Luca -- http://mail.python.org/mailman/listinfo/python-list
Signal on qt
hello i have this: def mytest(self): for a in xrange(self.tableWidget.rowCount()): self.combo_test = QtGui.QComboBox() self.connect(self.combo_test, QtCore.SIGNAL("currentIndexChanged(int)"), self.metto_test) self.combo_test.addItems(self.lista_def) self.tableWidget.setCellWidget(a, 4, self.combo_test) def metto_test(self, index): print index I he no connection what is wrong? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
file deleted
hello i'm working with eric, running a program eric crash and when i try to open my project again with eric i see that myproject.py is deleted, but my project is still running there is a way to find myprogram.py file aving it in execution? -- http://mail.python.org/mailman/listinfo/python-list
pyc to py
I have pyc file written with python 2.6.5 and i need to return to py file, can you give me some ideas tools script etc. Luca -- http://mail.python.org/mailman/listinfo/python-list
write file to a server
Hello i'm under windows, i have to write a file from my computer to a local server like taht "\\DOCUMENTALE\my_folder\". How i have to proceed ? Thanks -- https://mail.python.org/mailman/listinfo/python-list
Re: write file to a server
thanks for the reply i have resolve with the r'.' i have another question on linux i write cp -Ruv source destination There is one way to do it in python? with shutil there is copythree but if the dest dir exist he give back an error. Can you give me some ideas Thanks Luca -- https://mail.python.org/mailman/listinfo/python-list
matplotlib on osx 10.6
hello i try to install matplotlib on osx 10.6 , i have also installed freetype libpng and numpy but i get this error: BUILDING MATPLOTLIB matplotlib: 1.1.0 python: 2.6.1 (r261:67515, Jun 24 2010, 21:47:49) [GCC 4.2.1 (Apple Inc. build 5646)] platform: darwin REQUIRED DEPENDENCIES numpy: 1.2.1 freetype2: found, but unknown version (no pkg-config) * WARNING: Could not find 'freetype2' headers in any * of '.', './freetype2'. OPTIONAL BACKEND DEPENDENCIES libpng: found, but unknown version (no pkg-config) * Could not find 'libpng' headers in any of '.' Tkinter: Tkinter: 67083, Tk: 8.5, Tcl: 8.5 Gtk+: no * Building for Gtk+ requires pygtk; you must be able * to "import gtk" in your build/install environment Mac OS X native: yes Qt: no Qt4: Qt: 4.7.0, PyQt4: 4.8.2 Cairo: no OPTIONAL DATE/TIMEZONE DEPENDENCIES datetime: present, version unknown dateutil: present, version unknown pytz: matplotlib will provide adding pytz OPTIONAL USETEX DEPENDENCIES dvipng: no ghostscript: /bin/sh: gs: command not found latex: no [Edit setup.cfg to suppress the above messages] pymods ['pylab'] packages ['matplotlib', 'matplotlib.backends', 'matplotlib.backends.qt4_editor', 'matplotlib.projections', 'matplotlib.testing', 'matplotlib.testing.jpl_units', 'matplotlib.tests', 'mpl_toolkits', 'mpl_toolkits.mplot3d', 'mpl_toolkits.axes_grid', 'mpl_toolkits.axes_grid1', 'mpl_toolkits.axisartist', 'matplotlib.sphinxext', 'matplotlib.tri', 'matplotlib.delaunay', 'pytz'] running build running build_py copying lib/matplotlib/mpl-data/matplotlibrc -> build/lib.macosx-10.6- universal-2.6/matplotlib/mpl-data copying lib/matplotlib/mpl-data/matplotlib.conf -> build/ lib.macosx-10.6-universal-2.6/matplotlib/mpl-data running build_ext building 'matplotlib.ft2font' extension gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv - Os -Wall -DENABLE_DTRACE -arch i386 -arch ppc -arch x86_64 -pipe - DPY_ARRAY_UNIQUE_SYMBOL=MPL_ARRAY_API -DPYCXX_ISO_CPP_LIB=1 -I/System/ Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/python/ numpy/core/include -I. -I/System/Library/Frameworks/Python.framework/ Versions/2.6/Extras/lib/python/numpy/core/include/freetype2 -I./ freetype2 -I/System/Library/Frameworks/Python.framework/Versions/2.6/ include/python2.6 -c src/ft2font.cpp -o build/temp.macosx-10.6- universal-2.6/src/ft2font.o In file included from src/ft2font.h:16, from src/ft2font.cpp:3: /usr/local/include/ft2build.h:56:38: error: freetype/config/ ftheader.h: No such file or directory In file included from src/ft2font.cpp:3: src/ft2font.h:17:10: error: #include expects "FILENAME" or src/ft2font.h:18:10: error: #include expects "FILENAME" or src/ft2font.h:19:10: error: #include expects "FILENAME" or src/ft2font.h:20:10: error: #include expects "FILENAME" or src/ft2font.h:21:10: error: #include expects "FILENAME" or In file included from src/ft2font.cpp:3: src/ft2font.h:35: error: ‘FT_Bitmap’ has not been declared src/ft2font.h:35: error: ‘FT_Int’ has not been declared src/ft2font.h:35: error: ‘FT_Int’ has not been declared src/ft2font.h:91: error: expected ‘,’ or ‘...’ before ‘&’ token src/ft2font.h:91: error: ISO C++ forbids declaration of ‘FT_Face’ with no type src/ft2font.h:138: error: ‘FT_Face’ does not name a type src/ft2font.h:139: error: ‘FT_Matrix’ does not name a type src/ft2font.h:140: error: ‘FT_Vector’ does not name a type src/ft2font.h:141: error: ‘FT_Error’ does not name a type src/ft2font.h:142: error: ‘FT_Glyph’ was not declared in this scope src/ft2font.h:142: error: template argument 1 is invalid src/ft2font.h:142: error: template argument 2 is invalid src/ft2font.h:143: error: ‘FT_Vector’ was not declared in this scope src/ft2font.h:143: error: template argument 1 is invalid src/ft2font.h:143: error: template argument 2 is invalid src/ft2font.h:149: error: ‘FT_BBox’ does not name a type src/ft2font.cpp:51: error: ‘FT_Library’ does not name a type src/ft2font.cpp:114: error: variable or field ‘draw_bitmap’ declared void src/ft2font.cpp:114: error: ‘FT_Bitmap’ was not declared in this scope src/ft2font.cpp:114: error: ‘bitmap’ was not declared in this scope src/ft2font.cpp:115: error: ‘FT_Int’ was not declared in this scope src/ft2font.cpp:116: error: ‘FT_Int’ was not declared in this scope /System/Library/Frameworks/Python.framework/Versions/2.6/Extras/lib/ python/numpy/core/include/numpy/__multiarray_api.h:958: warning: ‘int _import_array()’ defined but not used In file included from src/ft2font.h:16,
installeventfilter
helo i have this form how i can install the event filter: Class Form(QWidget, Ui_Form): """ Class documentation goes here. """ def __init__(self, parent = None): """ Constructor """ QWidget.__init__(self, parent) self.setupUi(self) Thanks -- http://mail.python.org/mailman/listinfo/python-list
matplotlib real time grap.
Hello at all. I need to do a real time plot where on the frame i have this like limit line: import math dati = [] for freq in range(int(freqiniziale), (int(freqfinale )+ 1)): forza = float(massa) * ((2*math.pi*freq)**2)/10 dati.append(forza) ax1 = subplot(111) plot(dati) xlabel('Frequenza HZ') ylabel('Deg') title('Grafico Calibrazione') ax2 = twinx() plot([0.1,0.2,0.3],'r-') ylabel('Forza') ax2.yaxis.tick_right() #dlg = wx.FileDialog(self, "Choose a file", ".", "", "*.*", wx.SAVE) #try: # if dlg.ShowModal() == wx.ID_OK: #filename = dlg.GetPath() # savefig(filename+'.pdf') #finally: # dlg.Destroy() show() with this i have the grap on the screen but i have to update every time that i receive others data coming from two instruments (10 seconds), how i can update the grap? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Pycrypto
Hello I have to make an easy operation but reading the pycrypto doc. a never see AES example I have to cript this key 'ea523a664dabaa4476d31226a1e3bab0' with the AES. Can you help me for make it with pycrypto Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycrypto
Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycrypto
Excuse me again, If the string is not a sting but hex number how i have to proced : look this page: http://www.cs.eku.edu/faculty/styer/460/Encrypt/JS-AES.html Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycrypto
Hello again i have solve doing this: from Crypto.Cipher import AES stri=(chr(int('9b',16))+chr(int('d3',16))+chr(int('2d',16))+chr(int('24',16))+chr(int('af',16))+chr(int('c9',16))+chr(int('e9',16))+chr(int('d7',16))+chr(int('46',16))+chr(int('69',16))+chr(int('71',16))+chr(int('32',16))+chr(int('45',16))+chr(int('5f',16))+chr(int('27',16))+chr(int('0b',16))) luca = str(stri) crypt = AES.new(luca, AES.MODE_ECB) testo=(chr(int('ea',16))+chr(int('52',16))+chr(int('3a',16))+chr(int('66',16))+chr(int('4d',16))+chr(int('ab',16))+chr(int('aa',16))+chr(int('44',16))+chr(int('76',16))+chr(int('d3',16))+chr(int('12',16))+chr(int('26',16))+chr(int('a1',16))+chr(int('e3',16))+chr(int('ba',16))+chr(int('b0',16))) testo = str(testo) c = crypt.encrypt(testo) I don't know if this is the best way , but anyway it work Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycrypto
> In [26]:import binascii > > In [27]:binascii.unhexlify('ea523a664dabaa4476d31226a1e3bab0') > Out[27]:'\xeaR:fM\xab\xaaDv\xd3\x12&\xa1\xe3\xba\xb0' > > Ciao, > Marc 'BlackJack' Rintsch Ciao Marc Grazie Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: Pycrypto
Hello again You know if is possible save all the encryption process in a text file and not only the result? This will be wery helpful for compare the pycrypto step by step operation, with the hand made operation and see where hand made make a mistake -- http://mail.python.org/mailman/listinfo/python-list
Pyserial never read
Hello at all sorry for my english but i'm Italian. I use pyserial to communicate via rs232 with an extarnal device called smartmouse. I write the exact line that i want , but when i read i read only the echo ond not the other bytes. When i meke the same project with delphi i solve this problem with the call of the sleep. But in python it don't work. Have you got some ideas for solve my problem? Best Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial never read
Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial never read
Thanks for your help, but it don't solve the problem. I receive only the echo and full stop. Many Thanks Best Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial never read
Thanks to all for the help, here you find the code, pls note if i use handshaking = 1 the application don't start. in the delphi configuratio of com port if i use or not handshaking the application work. Best Regards at all Luca import serial import win32file port = 2 baudrate = 38400 bytesize =serial.EIGHTBITS parity =serial.PARITY_ODD stopbits =serial.STOPBITS_TWO timeout = 1 ser = serial.Serial(2, baudrate=38400, bytesize=8, parity=serial.PARITY_ODD, stopbits=2, timeout=3) ct = '' ch = '' a = self.textCtrl1.GetValue() ind = 0 ind1 = 2 lunghezza = len(a) while ind < lunghezza : b = a[ind:ind1] b = int(b,16) b = ~b c = ''.join([str((b >> Digit) & 1) for Digit in range(7, -1, -1)]) c1 = c[0:4] c2 = c[4:] c1 = c1[3:] + c1[2:3] + c1[1:2] + c1[0:1] c2 = c2[3:] + c2[2:3] + c2[1:2] + c2[0:1] c1 = hex(int(c1,2)) c2 = hex(int(c2,2)) c1 = c1[2:] c2 = c2[2:] c = c2+c1 ct = ct + c ind = ind + 2 ind1 = ind1 + 2 c = int(c,16) c = chr(c) ch = ch + c ser.write(ch) elf.textCtrl2.SetValue(ct) ser.readline() Pls.Note i hove also try with read(number of byte ) with inWaiting(), flush etc But no result. Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial never read
Hello ALSO... YOU NEVER SPECIFY A VARIABLE TO RECEIVE THE DATA -- ANYTHING YOU DO READ IS BEING DUMPED ON THE FLOOR! I see the read data with a sniffer. with the same serial caracteristic in delphi i obtain the right answer. I use serial writestr and serial readstr. If the serial package is anything like regular file I/O, that line will buffer/block until a new-line character is received, then return data upto/including the new-line. If the inbound data has multiple lines, you need individual readlines. For example i i send D036EC the right answer is D036ECFFBC35DC44 etc... i need new Line? why if i use ser.read(10) i see only the first 5 byte and not the rest, why if i use the inwaigth i answer that i have only 5 byte to read. Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
chrtohex
Hello again my friends here's my new problem. How i can translate chr in to hex or int to integer value? Best Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial never read
Hello i how can set with pyserial the following data? > byte delay= 4 > serial control line: > dtr = high > rts= low Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Pyserial again
Hello I have solve the problem of configuration with pyserial but i have another question. The serial port close every time i make the read and re-open when i do i new write. In my script there is not write close , why it close ? Thaks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Hello here is a part of code, the values for settings comes from combo box: here i take the ATR of the smartcard inserted in the reader, and than i store the read data in a textctrl. Sniffing the data with serial port monitor i see that the answer is ok but after the answer the port close, why? Another point is the textctrl: it store only the first byte and not the other why?, the byte are like 22 and all are readed Thaks ser = serial.Serial(porta) ser.baudrate = (atr) ser.parity = (parity) ser.stopbits = (stop) ser.bytesize = (size) ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = (time) a = ser.readline() a = self.textCtrl3.SetValue(a + ' ') self.lettura() ser.setBaudrate(baud) -- http://mail.python.org/mailman/listinfo/python-list
qpushbutton
hello again i have another stupid question. How i can set a qpushbutton invisible? thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
qt4 setFlags
Hello I make this code: row = self.tableWidget.rowCount() for a in range(row): self.tableWidget.item(row, 0).setFlags(Qt.IsSelectable) i have this erroror : global name Qt is not definied Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
ni pci-6010 Analog Input Multifunction DAQ
Hello there is someone that have experience with the ni-pci-6010 Analog Input Multifunction DAQ and python? -- http://mail.python.org/mailman/listinfo/python-list
QPainter
Hello using qt3 i do the follow for paint some line in a frame gr = QPainter(self.frame3) gr drawLine(30,10,30,490) and the line is draw. Whit qt4 : gr = QtGui.QPainter(self.frame3) #gr.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.SolidLine)) gr.drawLine(30,10,30,490) and nothing is draw but i have no error The frame is the same with the same dimension and relative dimension. where is the error? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
unify els database
Hello How i can use to connect to a unify els database with python Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: unify els database
Hello and thanks for your answer, the unify db is on unix-sco and i need to connect with linux machine with python Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: unify els database
Many thanks I will try with Jython Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
qt doevent
Hello at all I try to use qt , but i have problem, i don't find the command like wx.Yield() in wx or doevent in vb. Can you tell me the same command in qt Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
csv module
Hello at all i have a problem with the csv module, really i don't undestud the writerows: if i have to write only one row i do as follow: def scrivo_csv(self): import csv q_righe = self.tableWidget.rowCount() for row in range(q_righe) : e_vuota = self.tableWidget.item(row, 5) if e_vuota == None : ultima = row break writerdocs = open("some.csv", "wb") scritt = csv.writer(writerdocs, delimiter='|') q_colonne = self.tableWidget.columnCount() ss = 0 while ss < row : riga = [] for val in range(q_colonne): esiste = self.tableWidget.item(ss, val) if esiste == None : luca = '' else : luca = str(QtGui.QTableWidgetItem.text(esiste)) riga.append(luca) scritt.writerow(riga) ss+=1 This work only with one row in the tablewidget, but if i have more than one row how i have to proceed? Thanks for the help Luca -- http://mail.python.org/mailman/listinfo/python-list
Sip4.7
Hello i have python2.5 with sip4.6 installed on a linux machine, i need to install sip4.7 but i get a lot of error like this: sip.h:525: error: expected specifier-qualifier-list before 'PyMethodDef' sip.h:609: error: expected specifier-qualifier-list before 'sipForceConvertToFunc' sip.h:666: error: expected specifier-qualifier-list before 'PyObject' sip.h:902: error: expected specifier-qualifier-list before 'PyTypeObject sipint.h:81: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token sipint.h:86: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token sipint.h:87: error: expected '=', ',', ';', 'asm' or '__attribute__' before '*' token siplib.c:39: error: expected ')' before '*' token siplib.c:41: error: expected ')' before '*' token siplib.c:43: error: expected ')' before '*' token siplib.c:45: error: expected ')' before '*' token siplib.c:48: error: expected ')' before '*' token plib.c:285: error: expected specifier-qualifier-list before 'PyObject' siplib.c:290: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'sipWrapperType_Type' Have you some idea why? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
file resume
Hello at all: if i have one file written in binary mode, how can i append others binary data to this file after the its closure. ex my_file = open('blabal', 'wb') then i write something and then my_file.close() now if i need to open it again and append other binary data how can i proceed? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
QPicture and Qpainter PyQt4
Hello at all I have made this small tests: this is the form implementation: # -*- coding: utf-8 -*- """ Module implementing Form. """ from PyQt4.QtGui import QWidget from PyQt4.QtCore import pyqtSignature from PyQt4 import * from disegni import PictureFrame from Ui_form import Ui_Form class Form(QWidget, Ui_Form): """ Class documentation goes here. """ def __init__(self, parent = None): """ Constructor """ QWidget.__init__(self, parent) self.setupUi(self) @pyqtSignature("") def on_pushButton_clicked(self): """ Slot documentation goes here. """ # TODO: not implemented yet #raise "Not implemented yet" #gr = QtGui.QPainter() picture = QtGui.QPicture() gr = QtGui.QPainter() gr.begin(picture) gr.setPen(QtGui.QPen(QtCore.Qt.black, 1, QtCore.Qt.SolidLine)) gr.drawLine(70,100,150,100) gr.end() picture.save('dis.pic') self.frame.update() and this is the clas that implements the paint event: from PyQt4.QtGui import QWidget from PyQt4.QtCore import pyqtSignature from PyQt4 import * class PictureFrame(QtGui.QFrame): def __init__(self, parent = None): QFrame.__init__(self, parent) picture = QtGui.QPicture() def paintEvent(self, event): picture.load('dis.pic') gr = QtGui.QPainter() gr.begin(self.frame) gr.drawPicture(0, 0, picture) gr.end() But nothing is paint. Can you give me some help Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
cxfreeze
Hello i use under linux cx-freeze My python program import a small module were i set the encoding to iso 8859-1. When i make the executable with cxfreeze and i run it i get this error: Traceback (most recent call last): File "/home/luca72/Desktop/Luca/python/cx_Freeze-3.0.3/initscripts/ Console.py", line 27, in exec code in m.__dict__ File "main.py", line 4, in File "form_pack_impl.py", line 13, in File "sitecustomize.py", line 3, in LookupError: unknown encoding: iso-8859-1 Can you help me Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
PyQt ProgressBar
Hello i have made anly one test like this: from time import sleep barra = QtGui.QProgressBar() barra.setMinimum(0) barra.setMaximum(10) for a in range(10): sleep(1) barra.setValue(a) app.processEvents() But the bar remain fix to 0% don't increase. can you tell me how to prooced Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: PyQt ProgressBar
No one can help pls Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
pyuno and calc
Hello Can you tell me where i can find some example that's show how to open an existing oocalc document and get some data from it? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Direct acces to db unify on unix sco
Is it possible or i must use odbc? Rergards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Direct acces to db unify on unix sco
Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
encoding
hello i'm writing an irc client, i use for encoding the utf-8 but i never see all the typed sign in the correct way, anyone know the standard encodind for the irc channels? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
xchat
Hello i have installed xchat on suse11 i see that there is the possibility to use python for make some script, i see also that the python interface is loaded, but when in python i type import xchat i get that the module don't exist. where is the module? I try also to ask in the xchat forum but i get no reply so i try here Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
beutifulsoup
Hello I try to use beautifulsoup i have this: sito = urllib.urlopen('http://www.prova.com/') esamino = BeautifulSoup(sito) luca = esamino.findAll('tr', align='center') print luca[0] >>>href="#">#144.4MB>align="left"> Pc-prova.rar I need to get the following information: 1)Only|G|BoT|05 2)#1 3)44.4MB 4)Pc-prova.rar with: print luca[0].a.stringi get #1 with print luca[0].td.stringi get 44.4MB can you explain me how to get the others two value Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Ascii codec can't encode
hello i have this problem: UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 8: ordinal not in range(128) Generally i solve the problem inserting : # -*- coding: ISO-8859-1 -*- at the top of the file but now he don't work can you help me thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii codec can't encode
On 30 Ott, 10:27, luca72 <[EMAIL PROTECTED]> wrote: > Hy the code is this: > > Pok\xe9mon > > Luca Sorry is the é -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii codec can't encode
Hello Again the code is this # -*- coding: ISO-8859-1 -*- from BeautifulSoup import BeautifulSoup import urllib sito = urllib.urlopen('http://text.net/') esamino = BeautifulSoup(sito) luca = esamino.findAll('tr', align='center') lunghezza = len(luca) messaggio_per_scar = open('me', 'wb') file_ricerca = open('ri', 'wb') for dati in range(lunghezza): gino = luca[dati] test = gino.findAll(text=True) print test valori_a = gino.find("a")["onclick"].split("'") print valori_a nome_boot = valori_a[1] print nome_boot frase_scar = '/msg '+nome_boot+' xdcc send '+test[0]+'\n\r' messaggio_per_scar.write(frase_scar) nome = test[2] if nome ==' ': nome = test[4] frase_ric = nome+' '+test[1]+' '+test[0]+'\n\r' file_ricerca.write(frase_ric) #here i have the error messaggio_per_scar.close() file_ricerca.close() Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii codec can't encode
Hy the code is this: Pok\xe9mon Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Ascii codec can't encode
the arror are: >>> Error in sys.excepthook: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 1006, in __unhandled_exception self.mainThread.user_exception(None, (exctype,excval,exctb), 1) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugBase.py", line 538, in user_exception self._dbgClient.eventLoop() File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 921, in eventLoop self.readReady(self.readstream.fileno()) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ AsyncIO.py", line 67, in readReady self.handleLine(s) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 311, in handleLine self.__dumpVariables(int(frmnr), int(scope), filter) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 1128, in __dumpVariables vlist = self.__formatVariablesList(keylist, dict, scope, filter) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 1594, in __formatVariablesList valtypestr = unicode(type(value))[1:-1] TypeError: unbound method __unicode__() must be called with NavigableString instance as first argument (got nothing instead) Original exception was: Traceback (most recent call last): File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClient.py", line 38, in debugClient.main() File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 1900, in main self.__interact() File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 897, in __interact self.eventLoop() File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 921, in eventLoop self.readReady(self.readstream.fileno()) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ AsyncIO.py", line 67, in readReady self.handleLine(s) File "/usr/lib/python2.5/site-packages/eric4/DebugClients/Python/ DebugClientBase.py", line 445, in handleLine execfile(sys.argv[0], self.debugMod.__dict__) File "/home/luca11/Desktop/prova.py", line 36, in file_ricerca.write(frase_ric) UnicodeEncodeError: 'ascii' codec can't encode character u'\xe9' in position 8: ordinal not in range(128) I have solve in this way: file_ricerca = codecs.open('ri', 'wb', 'ISO-8859-15', 'repalce') That is not exact what i want because instead of the 'é' i get '?' but the loop contine. Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: beutifulsoup
hello Another stupit question instead of use sito = urllib.urlopen('http://www.prova.com/') esamino = BeautifulSoup(sito) i do sito = urllib.urlopen('http://onlygame.helloweb.eu/') file_sito = open('sito.html', 'wb') for line in sito : file_sito.write(line) file_sito.close() how can i pass the file sito.html to beautifulsoup? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
cxfreeze
Hello i try to use cxfreeze under linux with a easy project made with qt i run this : cxfreeze --install-dir=dist main.py and i get the error ImportError: No module named PyQt4._qt so i try : cxfreeze --install-dir=dist --include-modules='PyQt4._qt' main.py but i get the same error i try also including the sip module but i get the same error. Can you help me Thaks Luca -- http://mail.python.org/mailman/listinfo/python-list
Ip format
Hello i have this ip 1578568204 how socket function i can have the ip dotted-quad string? i have try socket.inet_aton get no error but only this ^ETB FF Thanks luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Ip format
Many thanks for your help I have also find the correct socket function: ip 1578568204 ip = socket.inet_aton(ip) ip_dot = socket.inet_ntoa(ip) Thanks Luca On 20 Nov, 12:36, Tim Chase <[EMAIL PROTECTED]> wrote: > > Hello i have this ip 1578568204 > > > how socket function i can have the ip dotted-quad string? > > > i have try socket.inet_aton get no error but only this ^ETB FF > > I've got the following program I threw together for one of my > junior developers: > > from sys import argv, exit > if len(argv) <> 2: > print "Usage:" > print "\t%s " % argv[0] > print "\t%s " % argv[0] > print "\nThe first form translates a dotted-quad format into > int format" > print "\nThe second form translates from int form to a > dotted-quad" > exit(1) > > src = argv[1] > > if src.count('.') == 3: > a,b,c,d = map(lambda s: 0xff and int(s), src.split('.')) > print ( > (a << (8*3)) | > (b << (8*2)) | > (c << (8*1)) | > d) > else: > i = int(src) > a = 0xff & (i >> (8*3)) > b = 0xff & (i >> (8*2)) > c = 0xff & (i >> (8*1)) > d = 0xff & (i) > print '%s.%s.%s.%s' % (a,b,c,d) > > The code you're looking for is in the bottom "else:" clause. > Yes, that could be optimized to just "c = 0xff & (i >> 8)" in the > 3rd case, but it made it easier for my junior developer to > understand what was going on. > > There might be some library function to do these transformations > for you, but after a quick look, I didn't find anything. > > -tkc -- http://mail.python.org/mailman/listinfo/python-list
c array
hello i'm using ctypes i have this c function PREF0 short usb_tc08_get_single ( short handle, float * temp, short * overflow_flags, short units); where : nt main(void) { short handle = 0; /* The handle to a TC-08 returned by usb_tc08_open_unit() */ char selection = 0; /* User selection from teh main menu */ float temp[9];/* Buffer to store temperature readings from the TC-08 */ int channel, reading; /* Loop counters */ int retVal = 0; /* Return value from driver calls indication success / error */ USBTC08_INFO unitInfo;/* Struct to hold unit information */ how i can pass the value using c types? strumento = ctypes.cdll.LoadLibrary('libusbtc08.so') and here is ok but when i call the function strumento.short usb_tc08_get_single(arg1, arg2,arg3,arg4) arg1 is 0 arg2 2 is a carray i dont know how to convert, arg3 is none and arg 4 is a string here is the c example usb_tc08_get_single(handle, temp, NULL, USBTC08_UNITS_CENTIGRADE) -- http://mail.python.org/mailman/listinfo/python-list
ctypes
can you explain how to use this function : this is the api documentation : PREF0 short usb_tc08_get_single ( short handle, float * temp, short * overflow_flags, short units); This is the sample made in c: int main(void) { short handle = 0; /* The handle to a TC-08 returned by usb_tc08_open_unit() */ char selection = 0; /* User selection from teh main menu */ float temp[9];/* Buffer to store temperature readings from the TC-08 */ int channel, reading; /* Loop counters */ int retVal = 0; /* Return value from driver calls indication success / error */ USBTC08_INFO unitInfo;/* Struct to hold unit information */ usb_tc08_get_single(handle, temp, NULL, USBTC08_UNITS_CENTIGRADE); i do strumento = ctypes.cdll.LoadLibrary('/home/luca/Desktop/luca/ progetti_eric/Pico/libusbtc08-1.7.2/src/.libs/libusbtc08.so') strumento.usb_tc08_get_single.argtypes = [ctypes.c_short, ctypes.c_float, ctypes.c_short, ctypes.c_short] is this correct? strumento.usb_tc08_get_single.restype = ctypes.c_short is this correct? now how i can use the function? leggo = strumento.usb_tc08_get_single(0, temp, 'NULL','USBTC08_UNITS_CENTIGRADE') how i can define ad pas the value temp, null,USBTC08_UNITS_CENTIGRADE thanks luca -- http://mail.python.org/mailman/listinfo/python-list
ctypes
hello i have this api PREF0 short usb_tc08_get_single ( short handle, float * temp, short * overflow_flags, short units); this is a sample program made in c int main(void) { short handle = 0; /* The handle to a TC-08 returned by usb_tc08_open_unit() */ char selection = 0; /* User selection from teh main menu */ float temp[9];/* Buffer to store temperature readings from the TC-08 */ int channel, reading; /* Loop counters */ int retVal = 0; /* Return value from driver calls indication success / error */ USBTC08_INFO unitInfo;/* Struct to hold unit information */ usb_tc08_get_single(handle, temp, NULL, USBTC08_UNITS_CENTIGRADE); handle is c_short, but how a can define temp and the other two value? myist.usb_tc08_get_single.argtypes = [ctypes.c_short, ctypes.c_float, ctypes.c_short, ctypes.c_short] --is correct? myist.usb_tc08_get_single.argtypes.restype = c_short --- is correct? but whe i call myist.usb_tc08_get_single(0, [9],NULL,USBTC08_UNITS_CENTIGRADE ) i get argument 2 wrong type can you explain how to execute this function Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
import cherrypy2
Hello i can't import cherrypy2 but i don't know why this is the sys path: '', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ setuptools-0.6c7-py2.5.egg', '/home/pirataja/opo.net/python/lib/ python2.5/site-packages/TurboGears-1.0.4.4-py2.5.egg', '/home/pirataja/ opo.net/python/lib/python2.5/site-packages/TurboKid-1.0.4-py2.5.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ TurboJson-1.1.2-py2.5.egg', '/home/pirataja/opo.net/python/lib/ python2.5/site-packages/TurboCheetah-1.0-py2.5.egg', '/home/pirataja/ opo.net/python/lib/python2.5/site-packages/simplejson-1.9.1-py2.5- linux-i686.egg', '/home/pirataja/opo.net/python/lib/python2.5/site- packages/RuleDispatch-0.5a0.dev_r2306-py2.5-linux-i686.egg', '/home/ pirataja/opo.net/python/lib/python2.5/site-packages/PasteScript-1.6.2- py2.5.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ FormEncode-1.0.1-py2.5.egg', '/home/pirataja/opo.net/python/lib/ python2.5/site-packages/DecoratorTools-1.7-py2.5.egg', '/home/pirataja/ opo.net/python/lib/python2.5/site-packages/configobj-4.5.2-py2.5.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ CherryPy-2.3.0-py2.5.egg', '/home/pirataja/opo.net/python/lib/ python2.5/site-packages/kid-0.9.6-py2.5.egg', '/home/pirataja/opo.net/ python/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux- i686.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg', '/home/pirataja/ opo.net/python/lib/python2.5/site-packages/PasteDeploy-1.3.1- py2.5.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ Paste-1.7-py2.5.egg', '/home/pirataja/opo.net/python/lib/ python25.zip', '/home/pirataja/pirata-jacopo.net/python/lib/ python2.5', '/home/pirataja/opo.net/python/lib/python2.5/plat- linux2', '/home/pirataja/opo.net/python/lib/python2.5/lib-tk', '/home/pirataja/opo.net/python/lib/python2.5/lib-dynload', '/home/ pirataja/opo.net/python/lib/python2.5/site-packages'] For my is all ok but whe i do import cherrypy2 i get no mudule name cherrypy2 Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: import cherrypy2
On 6 Giu, 10:31, Chris <[EMAIL PROTECTED]> wrote: > On Jun 6, 10:22 am, luca72 <[EMAIL PROTECTED]> wrote: > > > > > Hello i can't import cherrypy2 but i don't know why this is the sys > > path: > > > '', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > > setuptools-0.6c7-py2.5.egg', '/home/pirataja/opo.net/python/lib/ > > python2.5/site-packages/TurboGears-1.0.4.4-py2.5.egg', '/home/pirataja/ > > opo.net/python/lib/python2.5/site-packages/TurboKid-1.0.4-py2.5.egg', > > '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > > TurboJson-1.1.2-py2.5.egg', '/home/pirataja/opo.net/python/lib/ > > python2.5/site-packages/TurboCheetah-1.0-py2.5.egg', '/home/pirataja/ > > opo.net/python/lib/python2.5/site-packages/simplejson-1.9.1-py2.5- > > linux-i686.egg', '/home/pirataja/opo.net/python/lib/python2.5/site- > > packages/RuleDispatch-0.5a0.dev_r2306-py2.5-linux-i686.egg', '/home/ > > pirataja/opo.net/python/lib/python2.5/site-packages/PasteScript-1.6.2- > > py2.5.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > > FormEncode-1.0.1-py2.5.egg', '/home/pirataja/opo.net/python/lib/ > > python2.5/site-packages/DecoratorTools-1.7-py2.5.egg', '/home/pirataja/ > > opo.net/python/lib/python2.5/site-packages/configobj-4.5.2-py2.5.egg', > > '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > > CherryPy-2.3.0-py2.5.egg', '/home/pirataja/opo.net/python/lib/ > > python2.5/site-packages/kid-0.9.6-py2.5.egg', '/home/pirataja/opo.net/ > > python/lib/python2.5/site-packages/Cheetah-2.0.1-py2.5-linux- > > i686.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > > PyProtocols-1.0a0dev_r2302-py2.5-linux-i686.egg', '/home/pirataja/ > > opo.net/python/lib/python2.5/site-packages/PasteDeploy-1.3.1- > > py2.5.egg', '/home/pirataja/opo.net/python/lib/python2.5/site-packages/ > > Paste-1.7-py2.5.egg', '/home/pirataja/opo.net/python/lib/ > > python25.zip', '/home/pirataja/pirata-jacopo.net/python/lib/ > > python2.5', '/home/pirataja/opo.net/python/lib/python2.5/plat- > > linux2', > > '/home/pirataja/opo.net/python/lib/python2.5/lib-tk', > > '/home/pirataja/opo.net/python/lib/python2.5/lib-dynload', '/home/ > > pirataja/opo.net/python/lib/python2.5/site-packages'] > > > For my is all ok but whe i do import cherrypy2 i get no mudule name > > cherrypy2 > > > Regards > > > Luca > > because it's "import cherrypy" and not "import cherrypy2" sorry but from another python installation i import cherrypy2 as cherrypy and all works Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: import cherrypy2
No i haven't install lino but if frmp the python of this computer i make import cherrypy2 i import it without problem this is the python path: [EMAIL PROTECTED]:~> python Python 2.5.1 (r251:54863, Jan 10 2008, 18:00:49) [GCC 4.2.1 (SUSE Linux)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import cherrypy2 >>> import sys >>> sys.path ['', '/usr/lib64/python2.5/site-packages/setuptools-0.6c7-py2.5.egg', '/usr/lib64/python2.5/site-packages/TurboGears-1.0.4.4-py2.5.egg', '/ usr/lib64/python2.5/site-packages/TurboKid-1.0.4-py2.5.egg', '/usr/ lib64/python2.5/site-packages/TurboJson-1.1.2-py2.5.egg', '/usr/lib64/ python2.5/site-packages/TurboCheetah-1.0-py2.5.egg', '/usr/lib64/ python2.5/site-packages/simplejson-1.8.1-py2.5-linux-x86_64.egg', '/ usr/lib64/python2.5/site-packages/RuleDispatch-0.5a0.dev_r2306-py2.5- linux-x86_64.egg', '/usr/lib64/python2.5/site-packages/ PasteScript-1.6.2-py2.5.egg', '/usr/lib64/python2.5/site-packages/ FormEncode-1.0.1-py2.5.egg', '/usr/lib64/python2.5/site-packages/ DecoratorTools-1.7-py2.5.egg', '/usr/lib64/python2.5/site-packages/ configobj-4.5.2-py2.5.egg', '/usr/lib64/python2.5/site-packages/ CherryPy-2.3.0-py2.5.egg', '/usr/lib64/python2.5/site-packages/ kid-0.9.6-py2.5.egg', '/usr/lib64/python2.5/site-packages/ Cheetah-2.0.1-py2.5-linux-x86_64.egg', '/usr/lib64/python2.5/site- packages/PyProtocols-1.0a0dev_r2302-py2.5-linux-x86_64.egg', '/usr/ lib64/python2.5/site-packages/PasteDeploy-1.3.1-py2.5.egg', '/usr/ lib64/python2.5/site-packages/Paste-1.6-py2.5.egg', '/usr/local/lib64/ python2.5/site-packages/pagedemo1-1.0-py2.5.egg', '/usr/lib/ python25.zip', '/usr/lib64/python2.5', '/usr/lib64/python2.5/plat- linux2', '/usr/lib64/python2.5/lib-tk', '/usr/lib64/python2.5/lib- dynload', '/usr/lib64/python2.5/site-packages', '/usr/lib64/python2.5/ site-packages/Numeric', '/usr/lib64/python2.5/site-packages/PIL', '/ usr/lib64/python2.5/site-packages/gtk-2.0', '/usr/lib64/python2.5/site- packages/wx-2.8-gtk2-unicode', '/usr/local/lib64/python2.5/site- packages'] >>> Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Here is my code ; why after the readline the port close? ser = serial.Serial(0) ser.baudrate = 9600 ser.parity = serial.PARITY_ODD ser.stopbits = serial.STOPBITS_TWO ser.bytesize =serial.EIGHTBITS ser.setRTS(level = 0) ser.setDTR(level = 0) ser.timeout = 1 ser.readline() Why after this the port close. Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
def OnButton1Button(self, event): ser = serial.Serial(0) > ser.baudrate = 9600 > ser.parity = serial.PARITY_ODD > ser.stopbits = serial.STOPBITS_TWO > ser.bytesize =serial.EIGHTBITS > ser.setRTS(level = 0) > ser.setDTR(level = 0) > ser.timeout = 1 > ser.readline() no code before Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Hello Grant and Hello Steve. Pls. don't kill me, but if you try the code above written you see that after the read the port close. My question is only: why it close without the close command? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Ok you write that it close :Because the "ser" object is never used after that point, so it get's garbage collected and deleted. But for example if i make one button with the same caracteristic of the previous com port: def OnButton1Button(self, event): ser = serial.Serial(0) > ser.baudrate = 9600 > ser.parity = serial.PARITY_ODD > ser.stopbits = serial.STOPBITS_TWO > ser.bytesize =serial.EIGHTBITS > ser.setRTS(level = 0) > ser.setDTR(level = 0) > ser.timeout = 1 But with a = textCtrl1GetValue() # i put here some different string to send ser.write (a) b = ser.readline() textCtrl2SetValue(b) why at any read the serial close, is possible to prevent the closure of the port? -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Peter Hansen was asking you for the code AFTER the "ser.readline()" not BEFORE!! the code you have originally posted here OK IS MY MISTAKE; EXCUSE. I have read the example but if i ask is bucause i don't or maybe i don't understand the example Regaards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: Pyserial again
Dear All Thanks for your help, and patience. Now all works in the right mode. Belive me for a person of my age and my background ( i'm a physics, but at my time no computer was allowed) all that for you is simple, is not for me. So many Thanks and Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
excel application
Hello here is the code: from win32com.client import Dispatch packing = Dispatch("Excel.Application") packing.Visible = 1 packing.Workbooks.Add() #packing.Worksheets.Add() packing.ActiveSheet.Range("A1").ColumnWidth = 8 packing.ActiveSheet.Range("B1").ColumnWidth = 12 packing.ActiveSheet.Range("C1").ColumnWidth = 6 packing.ActiveSheet.Range("D1").ColumnWidth = 6 packing.ActiveSheet.Range("E1").ColumnWidth = 6 packing.ActiveSheet.Range("F1").ColumnWidth = 60 packing.ActiveSheet.Range("G1").ColumnWidth = 13 packing.ActiveSheet.Range("H1").ColumnWidth = 10 packing.ActiveSheet.Range("A8:H9").Select() packing.ActiveSheet.Selection.Borders(xlDiagonalDown).LineStyle = xlNone The error messege is global name xlNone is not definied what I have mistaken? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: excel application
Thanks a lot Luciano Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: excel application
Thanks Peter Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
wx.checklistbox
Hello I write one file using:...(i think that is ok for write all the lines of my list) luca = open('/tmp/luca', 'w') luca.writelines(list) when i open the application again i use: leggi = open('/tmp/luca', 'r') leggi.readlines() How can i store this line in to a wx.checkbox. Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
Sorry Philippe is a Wx.checklistbox -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
I have solved with appen.items() Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
sorry appenditems -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
i have again one simple problem: the script is this: def output(self): global lista2 lista2 = open('/lista2', 'w') iteminlista2 = self.checkListBox2.GetStrings() lista2.writelines(iteminlista2) def input1(self): lista2leggi = open('/lista2', 'r') cd = lista2leggi.readlines() self.checkListBox2.AppendItems(cd) The write file is like: item1item2item3 when i read the and i put the item in the checklistbox , i don't find : item1 item2 item3 but : item1item2item3 How to do for have it like : item1 item2 item3 Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
Thank Fredrik I try and then i will inform you Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
Hello Frefrik It works but sometimes it insert a blank row so the file is like: item1 item2 item3 item4 etc.. I don't inderstand why. But supposing that we can't solve this, is it possible to delete blanlk items in the checkListBox? -- http://mail.python.org/mailman/listinfo/python-list
Re: wx.checklistbox
I have solve in this way i'm sure it's not the best, but it works: lista1leggi = open('/lista1.txt', 'r') mt = lista1leggi.readlines() lunghezzamt = len(mt) lucianino = 0 while lucianino < (lunghezzamt - 1): if mt[lucianino] == '\n': del mt[lucianino] lucianino = lucianino - 1 lunghezzamt = lunghezzamt - 1 else: lucianino = lucianino + 1 pippo = self.checkListBox1.AppendItems(mt) Ragards Luca -- http://mail.python.org/mailman/listinfo/python-list
hex int and string
hello i have a problem i have this str = 'D3' and i need to trasform in 0xd3 type int and not type string how i can do this? if i do hex(int(str,16) ) i obtain a string and this is not what i need. thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: hex int and string
i'm using pyscard and for send a command he need a list like this: cmd = [0xdd,0xff, etc] the problem is that i get a text like dd and i need to trasform it in 0xdd for the list and if i use hex i have a sting that is not what i need Luca On 27 Nov, 10:22, Ben Finney wrote: > luca72 writes: > > str = 'D3' > > Be careful when choosing names. Here you have clobbered the existing > string type binding to the name ‘str’. > > > and i need to trasform in 0xd3 type int and not type string how i can > > do this? > > You already have the answer; you used it in your example below. I can > only assume you're wanting something additional; what is that? > > > if i do hex(int(str,16) ) i obtain a string and this is not what i > > need. > > You either want it as an int, or you want it as a string. Which is it? > > >>> foo = 'D3' > >>> int(foo, 16) > 211 > >>> 0xD3 > 211 > >>> int(foo, 16) == 0xD3 > True > > -- > \ “Human reason is snatching everything to itself, leaving | > `\ nothing for faith.” —Saint Bernard, 1090–1153 | > _o__) | > Ben Finney -- http://mail.python.org/mailman/listinfo/python-list
Re: hex int and string
i have checked and pyscard accept also the decimal notation, Thanks Luca On 27 Nov, 10:38, Lie Ryan wrote: > On 11/27/2009 8:28 PM, luca72 wrote: > > > i'm using pyscard > > > and for send a command he need a list like this: > > > cmd = [0xdd,0xff, etc] > > > the problem is that i get a text > > like dd > > and i need to trasform it in 0xdd for the list and if i use hex i have > > a sting that is not what i need > > >>> # Do you know that when you write > >>> somelist = [0xdd, 0xff, 0x34] > >>> # python read it as > >>> somelist > [221, 255, 52] > > All int in python (and in fact most computers) is stored as binary > digits; when you need a textual representation the binary digits is > transformed into string (even decimal representation [!]). When python > evaluates an integer literal expression, it converts them from whatever > base it is originally in [1] to binary. > > [1] determined by the prefix: 0b -> binary, 0x -> hexadecimal, 0o -> > octal, and unprefixed -> decimal. > > thus: > >>> [0xdd, 0xff, 0x34] == [221, 255, 52] > True -- http://mail.python.org/mailman/listinfo/python-list
dvb3
hello i try to use the python-dvb3 bindings, but i have some problem: fe = dvb3.frontend.Frontend(0) type = tipo_1 = fe.get_dvbtype() now i need to set the parameters parametri = dvb3.frontend.QPSKParameters(frequency=frequency, inversion=2 , symbol_rate=27500, fec_inner=9) but when i use fe.set_frontend(parametri) i get the error The debugged program raised the exception IOError "(22, 'Invalid argument')" File: frontend.pyx, Line: 364 thedef is as follow : def set_frontend(self, parameters): global cfrontend cdef cfrontend.dvb_frontend_parameters p if pack_parameters(&p, parameters) == 0: raise ParameterError, "Incorrect parameter type" if ioctl(self.fd, cfrontend.FE_SET_FRONTEND, &p) == -1: raise_ioerror() can you hel me Luca -- http://mail.python.org/mailman/listinfo/python-list
subprocess kill
Hello i'm using subprocess in this way: self.luca = subprocess.Popen(['/usr/bin/ dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) then i kill: self.luca.Kill() but the process is still active and the file self.f_s_l increase it size because the process is not killed. How i can kill the process? Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess kill
On 4 Dic, 23:23, Mike Driscoll wrote: > On Dec 4, 3:50 pm, luca72 wrote: > > > Hello i'm using subprocess in this way: > > self.luca = subprocess.Popen(['/usr/bin/ > > dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) > > > then i kill: > > self.luca.Kill() > > > but the process is still active and the file self.f_s_l increase it > > size because the process is not killed. > > > How i can kill the process? > > Regards > > > Luca > > Seehttp://lmgtfy.com/?q=python+kill+subprocess+linux > > When I do that on my machine, the 2nd result has the answer: > > http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kil... > > --- > Mike Driscoll > > Blog: http://blog.pythonlibrary.org Hello Mike i have also test but they never kill the process the file (stdout=self.f_s_l) increase it's size, haveyou some idea. also if i close the program the process is still active. Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess kill
On 5 Dic, 00:03, luca72 wrote: > On 4 Dic, 23:23, Mike Driscoll wrote: > > > > > On Dec 4, 3:50 pm, luca72 wrote: > > > > Hello i'm using subprocess in this way: > > > self.luca = subprocess.Popen(['/usr/bin/ > > > dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) > > > > then i kill: > > > self.luca.Kill() > > > > but the process is still active and the file self.f_s_l increase it > > > size because the process is not killed. > > > > How i can kill the process? > > > Regards > > > > Luca > > > Seehttp://lmgtfy.com/?q=python+kill+subprocess+linux > > > When I do that on my machine, the 2nd result has the answer: > > >http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kil... > > > --- > > Mike Driscoll > > > Blog: http://blog.pythonlibrary.org > > Hello Mike i have also test but they never kill the process the file > (stdout=self.f_s_l) increase it's size, haveyou some idea. > also if i close the program the process is still active. > > Regards > > Luca i'm able only to kill via shell like kill -9 process pid, Why? -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess kill
On 5 Dic, 00:14, luca72 wrote: > On 5 Dic, 00:03, luca72 wrote: > > > > > On 4 Dic, 23:23, Mike Driscoll wrote: > > > > On Dec 4, 3:50 pm, luca72 wrote: > > > > > Hello i'm using subprocess in this way: > > > > self.luca = subprocess.Popen(['/usr/bin/ > > > > dvbtune'+frase_sint],shell=True, stdout=self.f_s_l,stderr=self.f_s_e ) > > > > > then i kill: > > > > self.luca.Kill() > > > > > but the process is still active and the file self.f_s_l increase it > > > > size because the process is not killed. > > > > > How i can kill the process? > > > > Regards > > > > > Luca > > > > Seehttp://lmgtfy.com/?q=python+kill+subprocess+linux > > > > When I do that on my machine, the 2nd result has the answer: > > > >http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kil... > > > > --- > > > Mike Driscoll > > > > Blog: http://blog.pythonlibrary.org > > > Hello Mike i have also test but they never kill the process the file > > (stdout=self.f_s_l) increase it's size, haveyou some idea. > > also if i close the program the process is still active. > > > Regards > > > Luca > > i'm able only to kill via shell like kill -9 process pid, Why? Now the only way to solve the problem is to call a c program that kill the process via subprocess in other case i can't close it, i have also try with subprocess.Popen(['kill -9 dvbtune'] shell=True), but the process is still active Regards Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: subprocess kill
On 5 Dic, 03:06, Carl Banks wrote: > On Dec 4, 3:44 pm, luca72 wrote: > > > > > On 5 Dic, 00:14, luca72 wrote: > > > > On 5 Dic, 00:03, luca72 wrote: > > > > > On 4 Dic, 23:23, Mike Driscoll wrote: > > > > > > On Dec 4, 3:50 pm, luca72 wrote: > > > > > > > Hello i'm using subprocess in this way: > > > > > > self.luca = subprocess.Popen(['/usr/bin/ > > > > > > dvbtune'+frase_sint],shell=True, > > > > > > stdout=self.f_s_l,stderr=self.f_s_e ) > > > > > > > then i kill: > > > > > > self.luca.Kill() > > > > > > > but the process is still active and the file self.f_s_l increase it > > > > > > size because the process is not killed. > > > > > > > How i can kill the process? > > > > > > Regards > > > > > > > Luca > > > > > > Seehttp://lmgtfy.com/?q=python+kill+subprocess+linux > > > > > > When I do that on my machine, the 2nd result has the answer: > > > > > >http://stackoverflow.com/questions/1064335/in-python-2-5-how-do-i-kil... > > > > > > --- > > > > > Mike Driscoll > > > > > > Blog: http://blog.pythonlibrary.org > > > > > Hello Mike i have also test but they never kill the process the file > > > > (stdout=self.f_s_l) increase it's size, haveyou some idea. > > > > also if i close the program the process is still active. > > > > > Regards > > > > > Luca > > > > i'm able only to kill via shell like kill -9 process pid, Why? > > > Now the only way to solve the problem is to call a c program that kill > > the process via subprocess in other case i can't close it, i have also > > try with > > > subprocess.Popen(['kill -9 dvbtune'] shell=True), but the process is > > still active > > This is not working because the kill command does not accept the name > of a program. You have to give it a process id. > > As for your general question, we really can't answer it. There a lot > of reasons a process might not die when you try to kill it: it could > be trapping and ignoring signals (which is rude but it happens), it > could be stuck in a critical section, the program might be threaded > and not handling signals well, the program might have forked itself > and the original process id has disappeared, etc. We can't read your > mind or divine what's running on your computer, so we can't answer > your question. We can only suggest things that might be wrong. It's > up to you to investigate and/or dig deeper. > > Carl Banks The firs thing that i have tested is with the process id get by Popen.pid ,but it don't works. Thanks -- http://mail.python.org/mailman/listinfo/python-list
read from bin file
I have a bin file that i read as: in_file = open('primo.ske', 'rb') leggo = luca.readlines() i get a list like : ['\x00\x80p\x8b\x00\x00\x01\x19\x9b\x11\xa1\xa1\x1f\xc9\x12\xaf\x81! \x84\x01\x00\x01\x01\x02\xff\xff\x80\x01\x03\xb0\x01\x01\x10m\x7f\n', etc...] but if i try to print luca[0] i get not the the string in the list but i get some like " {" how i can get a string like the string in the list? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
pythonpath
Sorry for my stupid question if i have to load module from a folder i have to append it to the sys path the folder? ex: if my folder module is /home/lucak904/Scrivania/Luca/enigma2 i do this : import sys sys.path.append('/home/lucak904/Scrivania/Luca/enigma2') If this is correct why when i write: form enigma2 import * i get no module named enigma2 Thanks Luca I'm under linux -- http://mail.python.org/mailman/listinfo/python-list
python and enigma2
Hello i have a dvb decoder with enigma2 inside, The enigma2 plugin can be made with python. In my plugin i have to use pyserial, but in the decoder the python2.5 reply in this way: r...@bm750:/var/pyserial-2.5-rc2# python setup.py install Traceback (most recent call last): File "setup.py", line 8, in from distutils.core import setup ImportError: No module named distutils.core How i can install distutils? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: python and enigma2
On 12 Apr, 19:10, luca72 wrote: > Hello i have a dvb decoder with enigma2 inside, The enigma2 plugin can > be made with python. > In my plugin i have to use pyserial, but in the decoder the python2.5 > reply in this way: > r...@bm750:/var/pyserial-2.5-rc2# python setup.py install > Traceback (most recent call last): > File "setup.py", line 8, in > from distutils.core import setup > ImportError: No module named distutils.core > > How i can install distutils? > > Thanks > > Luca Sorry i try to install setuptolls i get this : r...@bm750:/var# sh setuptools-0.6c11-py2.5.egg exec: 8: python2.5: not found I see anly the python executable andno other folder can you hel me Regards -- http://mail.python.org/mailman/listinfo/python-list
python glibc crypt() function
Hello i have to do this : glibc crypt() function, using salt $1$abcdefgh$ cryptPw = crypt(plainPw, "$1$abcdefgh$") I can do it in python, with package i need? Thanks -- http://mail.python.org/mailman/listinfo/python-list
Re: python glibc crypt() function
On 20 Apr, 19:38, Peter Otten <__pete...@web.de> wrote: > luca72 wrote: > > Hello i have to do this : > > glibc crypt() function, using salt $1$abcdefgh$ > > > cryptPw = crypt(plainPw, "$1$abcdefgh$") Thanks The result is correct i obtain the same with ctypes and crypt module, so i think that is better to use the crypt module is correct? Luca > > > I can do it in python, with package i need? > > Thanks > >>> import ctypes > >>> lib = ctypes.CDLL("libcrypt.so.1") > >>> crypt = lib.crypt > >>> crypt.restype = ctypes.c_char_p > >>> crypt("password", "$1$abcdefgh$") > > '$1$abcdefgh$G//4keteveJp0qb8z2DxG/' > > Is that what it's supposed to return? > > Peter -- http://mail.python.org/mailman/listinfo/python-list
socked and bytes operation
Hello i have this question : i connect to the server in this way: sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect(('192.168.1.11',11502)) rcv = sock.recv(8124) here i get 14 random bytes , in a string with strange chars like : ¬¨^.á‹•Ò a„ãj I think because sock.recv return a string. Now i have to xor this 14 bytes with a key stored in file as a sting. Can you help me to understand how to do it. Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: socked and bytes operation
On 21 Apr, 20:42, John Nagle wrote: > luca72 wrote: > > Hello i have this question : > > i connect to the server in this way: > > sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) > > sock.connect(('192.168.1.11',11502)) > > rcv = sock.recv(8124) > > here i get 14 random bytes , in a string with strange chars like : > > ¬¨^.á‹•Ò > > a„ãj > > I think because sock.recv return a string. > > Now i have to xor this 14 bytes with a key stored in file as a sting. > > Can you help me to understand how to do it. > > Port 11502? What are you talking to? An eSoft Distributed > Intelligent Architecture node? Unlikely. Let me guess. A Counter-Strike > server. > > John Nagle i'm tolking to a cardserv in a dvb decoder with linux inside -- http://mail.python.org/mailman/listinfo/python-list
string caracters:
i get a string from a web server and i save it in to a file, that i open the file and i read the string: the string looks like : http://lhti.gs/JKBTYD after the read i use webbrowser open (sting), but i get the error because at the end of the string are added '%0D%0A', and if i ask for the len of the sting it include also the"'%0D%0A". My question is how i can cut the last part of the string if it is every time different? Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: socked and bytes operation
i attach some part of the server so maybe you can help me to understand : Packet description (before encryption) Messages sent back and forth between newcamd and a cardserver always consist of a three byte header and (optional) data bytes. The header always starts with a command tag byte. This is always the first byte (byte 1) of a message. In case of an ECM or EMM this is simply the table id of the ECM (0x80, 0x81) or EMM (0x82 - 0x8f). Other commands use cmd tags starting from 0xe0 like this: #define CWS_FIRSTCMDNO 0xe0 typedef enum { MSG_CLIENT_2_SERVER_LOGIN = CWS_FIRSTCMDNO, MSG_CLIENT_2_SERVER_LOGIN_ACK, MSG_CLIENT_2_SERVER_LOGIN_NAK, MSG_CARD_DATA_REQ, MSG_CARD_DATA, MSG_SERVER_2_CLIENT_NAME, MSG_SERVER_2_CLIENT_NAME_ACK, MSG_SERVER_2_CLIENT_NAME_NAK, MSG_SERVER_2_CLIENT_LOGIN, MSG_SERVER_2_CLIENT_LOGIN_ACK, MSG_SERVER_2_CLIENT_LOGIN_NAK, MSG_ADMIN, MSG_ADMIN_ACK, MSG_ADMIN_LOGIN, MSG_ADMIN_LOGIN_ACK, MSG_ADMIN_LOGIN_NAK, MSG_ADMIN_COMMAND, MSG_ADMIN_COMMAND_ACK, MSG_ADMIN_COMMAND_NAK, MSG_KEEPALIVE = CWS_FIRSTCMDNO + 0x1d, } net_msg_type_t; Client to Server Login This describes how to login . Remember each card has its own dedicated TCP port, this is how you choose, which card you want. Client <- Server 1/5 - 090f - Thu Jan 8 17:20:17 CET 2004 encryption: none -- 00: 77 9d cc 5d d2 0d 59 2e dc ed b8 17 c1 ab w ] Y. (this are the bites that i receive ofter the connection) After opening a TCP connection to the server, the client first receives 14 random bytes. These bytes are to be XORed to the Triple-DES key from the config file. (cardserver: DESKEY = 0102030405060708091011121314). The result forms the Triple DES key to be used to send Username and Password to the cardserver, I call it the login key. for make this i do : import socket,crypt, itertools sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) sock.connect(('192.168.1.11',11502)) ricevo = sock.recv(8192) stringa = '0102030405060708091011121314' ricevo = map(ord, ricevo) print ricevo #print '\n' #luca= [] stringa = map(ord, stringa) print stringa plain_chars = [] for cypher_char, key_char in zip(ricevo, itertools.cycle(stringa)): plain_char = (cypher_char) ^ (key_char) plain_chars.append(plain_char) print plain_chars i get: [133, 234, 201, 215, 129, 130, 252, 113, 15, 226, 29, 193, 67, 103] Client -> Server 1/5 - 090f - Thu Jan 8 17:20:18 CET 2004 encryption: login -- 00: e0 00 29 64 75 6d 6d 79 00 24 31 24 61 62 63 64 )dummy $1$abcd 10: 65 66 67 68 24 6e 70 53 45 54 51 73 72 49 6d 33 efgh$npSETQsrIm3 20: 35 4d 51 66 69 55 49 41 64 6e 2e 00 5MQfiUIAdn. Next the client has to send a packet with cmd = MSG_CLIENT_2_SERVER_LOGIN (e0) including username and password in the data field. The username is sent as a C-String (NULL terminated), the password follows directly after the zero termination byte of the username. The password has to be put through the glibc crypt() function, using salt $1$abcdefgh$. The password in the data field has to be NULL terminated and the packet encrypted with the login key. cryptPw = crypt(plainPw, "$1$abcdefgh$"); If i understand right i have to do this : ris = cript.crypt(password,"$1$abcdefgh$") than sock.send('e0'+password+ris) and than read again is this correct? -- http://mail.python.org/mailman/listinfo/python-list
pysms
Hello Has anyone used pysms can you tell me with wich gsm module it works? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
stupid question about html page
hello with webbrowser i open the html or php etc page, how i can save the opened page with python? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list
Re: stupid question about html page
On 1 Lug, 10:16, Mithrandir wrote: > luca72 wrote in news:abfb7720-6132-4b7b-8084- > 5c1a48164...@y11g2000yqm.googlegroups.com: > > > hello > > with webbrowser i open the html or php etc page, how i can save the > > opened page with python? > > > Thanks > > > Luca > > Not sure of a way to capture info from a browser (like Firefox.) I know > though that you can save the source of an page with: > > import urllib > urllib.urlretrieve("http://www.example.com/";, "Fun.html") > > You still need a web browser to read it formatted. (If you are on a web > page in Firefox, and want to save it, click File>Save Page As...) > > If you want to save a picture from the Net see: > > http://www.daniweb.com/code/snippet216796.html > > Good luck! > > -- > People should read > more.https://secure.wikimedia.org/wikipedia/en/wiki/User:MithrandirAgain > "All that is gold does not glitter, > not all those who wander are lost; > the old that is strong does not wither, > deep roots are not reached by the frost. > From the ashes a fire shall be woken, > a light from the shadows shall spring; > renenwed shall be blade that was broken, > the crownless again shall be king." Thanks for your reply, the problem is that i don't want to save it with file-> save. there is any way to save the page by script. please note that when i save the page with firefox, it save the html page and also make a folder with the script used in the page, how i can make it also with python script? Thanks Luca -- http://mail.python.org/mailman/listinfo/python-list