Форум сайта python.su
from django.http import HttpResponse
from subprocess import Popen
import threading
import os
import sys
import my_helper
def external(*args,**kwargs):
pid = os.fork()
if pid:
os.waitpid(pid,0)
print "Done"
return
log = open("/var/www/ext.log","a+",0)
log.truncate()
os.dup2(log.fileno(),1)
os.dup2(log.fileno(),2)
proc = Popen("ps aux",shell=True,bufsize=0)
proc.wait()
log.flush()
helper.one()
log.flush()
log.close()
sys.exit()
def start():
thread = threading.Thread(target=external)
thread.setDaemon(True)
thread.start()
import time
def my_view(request):
start()
return HttpResponse('Hello, world!')
from subprocess import Popen
def one():
proc = Popen("cat /proc/%s/maps" %(os.getpid()),shell=True,bufsize=0)
proc.wait()
def __init__(self):
self.im=g.Image.new((360,560))
self.ini_vars()
self.ini_img()
a.app.screen='full'
a.app.directional_pad=False
a.app.orientation='portrait'
self.canvas=a.Canvas(event_callback=self.ev_call, redraw_callback=self.redraw)
a.app.body=self.canvas
def ev_call(self, event):
if not event['type'] in [key_codes.EButton1Up, key_codes.EButton1Down, key_codes.EDrag]:
return
if event['type'] == key_codes.EButton1Down:
if event['pos'][1]>=560:
if self.panel==0:
if event['pos'][0]<=72:
self.panel=1
elif (event['pos'][0]<=144)and(event['pos'][1]>=72):
self.panel=2
elif (event['pos'][0]<=216)and(event['pos'][1]>=144):
self.panel=3
elif (event['pos'][0]<=288)and(event['pos'][1]>=216):
self.panel=4
elif (event['pos'][0]<=360)and(event['pos'][1]>=288):
self.panel=5
self.draw()
elif event['pos'][1]<560:
self.prev_x=event['pos'][0]
self.prev_y=event['pos'][1]
self.im.point((10,10), outline=self.colour, outline=5, width=10, fill=self.colour)
self.draw()
elif event['type'] == key_codes.EDrag:
qw=(self.prev_x, self.prev_y, event['pos'][0], event['pos'][1])
self.im.line(qw , outline=self.colour, outline=5, width=10, fill=self.colour)
self.prev_x=event['pos'][0]
self.prev_y=event['pos'][1]
self.draw()
q=e32.Ao_lock()
q.signal()
#!C:/Python31/python.exe -u
#encoding: cp1251
import codecs
s="\x86 1200.00 \x86 340.00 \x86 0"
u=s.encode("cp866","replace")
ss=codecs.decode(u,'cp866')
print(ss)
import dpkt
import pcap
import struct
pc = pcap.pcap()
pc.setfilter('dst port 5190')
for ts, pkt in pc:
pkt = dpkt.ethernet.Ethernet(pkt)
if(pkt.ip.len==40):
continue
src = int(struct.unpack('I', pkt.ip.src)[0])
dst = int(struct.unpack('I', pkt.ip.dst)[0])
srcport = int(pkt.ip.data.sport)
dstport = int(pkt.ip.data.dport)
print pkt.ip.data.data
from scapy.all import *
while True:
xxx = sniff(filter="dst port 5190", count=1, iface="eth1")
x = xxx[0]
if(x.__dict__['payload'].__dict__['fields']['len']>40):
print x.__dict__['payload'].__dict__['payload'].__dict__['payload'].__dict__['fields']['load']
from import${0}
re.match("^[\w_ -]+$", word) #1
re.match("^[а-яА-Я_ -]+$", word) #2
re.match("^[ю-ъЮ-Ъ_ -]+$", word) #3 - работает только из консоли с KOI8-r
def g0(T, dic, i):
......................
g0v = numpy.vectorize(g0)
...
def doing (event):
n=sca.get()
qst=qstn[n]
r_n=r[n]
label1.configure(text=qst)
rad0.configure(text="1 - "+r_n[0])
rad1.configure(text="2 - "+r_n[1])
def otvet(event):
n=sca.get()
i=var.get()
if i==i_p[n]:
label2.configure(text="BEPHO")
else:
label2.configure(text="HEBEPHO")
...
qst=""
qstn=["vpros1","vopros2","vopros3"]
r0=['v11','v12']
r1=['v21','v22']
r2=['v31','v32
r=[r0,r1,r2]
i_p=[1,0,1]
n=IntVar()
var=IntVar()
var.set(0)
rad0 = Radiobutton(frame,text="",variable=var,value=0)
rad1 = Radiobutton(frame,text="",variable=var,value=1)
...
but=Button(frame,text="OTBET")
but.bind("<Button-1>",otvet)
label2=Label(frame,text="")
label2.grid(row=4,column=1)
but_nxt=Button(frame,text="NEXT")
but_nxt.bind("<Button-1>",doing)
sca = Scale(root,orient=HORIZONTAL,length=100,from_=0,to=2,tickinterval=1,resolution=1)
...