Форум сайта python.su
# -*- coding: utf-8 -*-
import sqlite3
import Tkinter
import Image
import ImageTk
def insimg():
# c.delete(slide)
cu.execute('select imgdb from dbimg where id = 1')
for row in cu:
fileimg1 = row[0]
img = ImageTk.PhotoImage(data = fileimg1)
c.create_image(0, 0, image=img, anchor="nw")
cc = sqlite3.connect(database="files.s3db")
cu = cc.cursor()
tup = Tkinter.Tk()
F = Tkinter.Frame(tup)
F.pack()
numfiles = Tkinter.StringVar()
# Номер изображения
s1 = Tkinter.Spinbox(F, from_=0, to=72, textvariable=numfiles, command = insimg)
s1.grid(row=0, column=0)
# Выводим изображение
c = Tkinter.Canvas(F, width=32, height=32)
c.grid(row=1, column=0)
# ---------------------
cu.execute('select imgdb from dbimg where id = 0')
for row in cu:
fileimg = row[0]
# ---------------------
#src_img = Image.open(r'C:\BASE\baseico\ico_00.bmp')
img = ImageTk.PhotoImage(data = fileimg)
slide = c.create_image(0, 0, image=img, anchor="nw")
#Закрываем GUI
btclose = Tkinter.Button(F, text = u'Закрыть', command = lambda: tup.destroy())
btclose.grid(row=2, column=0)
tup.mainloop()
cc.close()
try: # Нас случай если self.menu еще не создано
if self.menu.get_snapshot(): # Если скрин не пустой
self.activate() # выполняю функцию
except AttributeError:
pass
import feedparser,sys
def f(data):
return data.encode("latin1","ignore")
try:
feed = sys.argv[1]
except IndexError:
feed = "http://lenta.ru/r/EX/import.xml"
d = feedparser.parse(feed)
#print f(d.feed.title),";",f(d.feed.link),";",f(d.feed.subtitle),";",f(d.version),";",f(d.encoding),";",len(d.entries)
for entry in d.entries:
print f(entry.title),";",
print f(entry.link),";",
try:
print f(entry.author_detail.name),";",
except AttributeError:
pass
try:
print f(entry.content)
except AttributeError:
pass
import pexpect
import sys
gen = pexpect.spawn('./build-key-pkcs12 client2')
gen.expect('Country Name (2 letter code)*')
gen.sendline('\n')
gen.expect('State or Province Name*')
gen.sendline('\n')
gen.expect('Locality Name (eg, city)*')
gen.sendline('\n')
gen.expect('Organization Name (eg, company)*')
gen.sendline('\n')
gen.expect('Organizational Unit Name*')
gen.sendline('\n')
gen.expect('Common Name*')
gen.sendline('\n')
gen.expect('Email Address*')
gen.sendline('\n')
gen.expect('A challenge password*')
gen.sendline('\n')
gen.expect('An optional company name*')
gen.sendline('\n')
gen.expect('Sign the certificate?.*', timeout=2)
gen.sendline("y\n")
gen.expect('1 out of 1 certificate requests certified, commit?.*', timeout=2)
gen.sendline('y\r')
gen.expect('Enter Export Password')
gen.sendline('lalala')
gen.expect('Verifying - Enter Export Password')
gen.sendline('lalala')
gen.interact()
args:Подскажите пожалуйста, как исправить этот косяк, чувствую, что это может быть связано с переводами строк при запросе …:
searcher: searcher_re:
0: re.compile(“1 out of 1 certificate requests certified, commit?.*”)
buffer (last 100 chars):
before (last 100 chars):
y
after: pexpect.EOF
match: None
match_index: None
exitstatus: 0
flag_eof: True
pid: 25793
child_fd: 3
closed: False
timeout: 30
delimiter: pexpect.EOF
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
#
Certificate is to be certified until Nov 17 01:15:52 2019 GMT (3650 days)
Sign the certificate? :y
1 out of 1 certificate requests certified, commit? y
Write out database with 1 new entries
Data Base Updated
Enter Export Password:
///////////////////////////////////////////////////////////////////////////////////////////////////////////
// Get image alpha mask to byte buffer.
// input: QImage image.
// output: str maskBuf.
static PyObject *gray_c32GetAlphaMask(PyObject *self, PyObject *args) {
PyObject *image; // input ARGB32 QImage
// parse function parameters
if (!PyArg_ParseTuple(args, "O", &image)) return NULL;
// get image width and height
U32 w = PyInt_AsLong(PyObject_CallMethod(image, "width", NULL));
U32 h = PyInt_AsLong(PyObject_CallMethod(image, "height", NULL));
if (w*h > 0) {
// pointer to first color pixel
U32 *c32Buf = PyCObject_AsVoidPtr(PyObject_CallMethod(PyObject_CallMethod((PyObject *)image, "bits", NULL), "ascobject", NULL));
U8 *maskBuf = PyMem_Malloc(w * h); // allocate output buffer
for (U32 yCnt=0; yCnt<h; yCnt++) { // y loop
for (U32 xCnt=0; xCnt<w; xCnt++) { // x loop
*maskBuf = *c32Buf >> 24; // get pixel alpha value
c32Buf++;
maskBuf++;
}
}
return Py_BuildValue("s#", maskBuf, w*h);
}
return Py_BuildValue("O", Py_None);
}
<span style="color: rgb(255, 0, 0);">
<span style="font-size: xx-small;">F</span>
</span>
<span style="font-size: xx-small;">
<span style="color: rgb(255, 255, 0);">A</span>
</span>