Форум сайта python.su
string2 = u"Введите login: "
login = raw_input(string2).strip()
EOFError: EOF when reading a line
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
access_log logs/access.log;
server {
listen 443;
server_name localhost;
ssl on;
ssl_certificate ssl/cert.pem;
ssl_certificate_key ssl/cert.key;
ssl_session_timeout 5m;
ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
ssl_prefer_server_ciphers on;
location / {
uwsgi_pass unix:///tmp/uwsgi.sock;
include uwsgi_params;
}
location /static/ {
root /www/mysite;
}
}
}
<uwsgi>
<pythonpath>/www/mysite</pythonpath>
<module>webapp</module>
<socket>/tmp/uwsgi.sock</socket>
<process>1</process>
<master/>
<enable-threads/>
<uid>80</uid>
<gid>80</gid>
<pidfile>/var/run/uwsgi.pid</pidfile>
</uwsgi>
# -*- coding: utf-8 -*-
import sys, os
import django.core.handlers.wsgi
sys.path.insert(0, os.path.abspath(os.path.dirname(__file__)) + "/mysite")
os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
application = django.core.handlers.wsgi.WSGIHandler()
wsgi.url_scheme 'http'
SERVER_PROTOCOL 'HTTP/1.1'
class Area:
def __init__(self):
self.x = 10
self.y = 10
self.obj = None
self.value_delete = False # для проверки при удалении объекта/метки
self.dictionary_obj = {} # Словарь для объектов (изображений) в Event Box
self.dictionary_lbl = {} # Словарь для объектов (меток) в Event Box
self.dictionary_handler_id = {} # Словарь для блокировки сигналов
self.window = gtk.Window(gtk.WINDOW_TOPLEVEL)
self.window.set_resizable(False)
self.window.set_title('Редактирование')
screen = gtk.gdk.Screen()
self.window.set_size_request(screen.get_width(), screen.get_height())
self.window.fullscreen()
# self.window.maximize()
self.window.connect("destroy", lambda w: gtk.main_quit())
self.window.connect("key-press-event", self.keyboard_event)
self.t = gtk.Table(100, 100, True)
self.fixed = gtk.Fixed()
self.t.attach(self.fixed, 0,100,5,100)
self.window.add(self.t)
self.menu_items = (
( "/_Меню", None, None, 0, "<Branch>" ),
( "/Меню/Создать объект", "<control>N", self.great_obj, 0, None ),
( "/Меню/Создать метку", "<control>L", self.great_lbl, 0, None ),
# ( "/Меню/Сохранить", None, None, 0, None ),
( "/Меню/sep1", None, None, 0, "<Separator>" ),
( "/Меню/Выход", "<control>Q", gtk.main_quit, 0, None ),
( "/_Правка", None, None, 0, "<Branch>" ),
( "/Правка/Редактировать объект", None, self.edit_obj, 0, None ),
( "/Правка/Редактировать метку", None, self.edit_lbl, 0, None ),
( "/Правка/Удалить объект", None, self.delete_obj, 0, None ),
( "/Правка/Удалить метку", None, self.delete_lbl, 0, None ),
)
menubar = self.get_main_menu(self.window)
def great_obj(self, w, data): # Создать объект
#Вот здесь ~470 строк кода
def great_lbl(self, w, data): # Создание метки
#Вот здесь ~80 строк кода
def edit_obj(self, w, data): # Редактирование объекта
#Вот здесь ~300 строк кода
def edit_lbl(self, w, data): # Редактирование метки
#Вот здесь ~200 строк кода
import ftputil
from Queue import Queue
import os
import zipfile
from threading import Thread
from time import sleep
import re
from zipfile import ZipFile
class download(Thread):
def __init__(self, path, file, host, queue, tid):
Thread.__init__(self);
self.file = file
self.path = path
self.host = host
self.fullpath = path + "/" + file
self.queue = queue
self.tid = tid
def run(self):
if(os.path.exists(self.fullpath[0:-4]) == False and re.search('readme', self.fullpath) == None):
try:
os.system('wget -N -c -q ftp://free:free@77.246.101.195/' + self.fullpath + ' -P ' + self.path);
if(zipfile.is_zipfile(self.fullpath)):
zip = zipfile.ZipFile(self.fullpath, 'r')
zip.extractall(self.path)
os.remove(self.fullpath)
result = True
rtrn = (self.tid, result, self.file, self.path)
self.queue.put(rtrn)
except:
result = False
rtrn = (self.tid, result, self.file, self.path)
self.queue.put(rtrn)
pass
else:
result = True
rtrn = (self.tid, result, self.file, self.path)
self.queue.put(rtrn)
def new_thread(path, file, host, queue, tid):
thread = download(path, file, host, queue, tid)
thread.start()
return thread
threads = []
queue = Queue()
host = ftputil.FTPHost('77.246.101.195', 'free', 'free')
for (path, dirs, files) in host.walk(host.curdir):
if path != ".":
count = len(files)
try:
os.mkdir(path)
except:
pass
for i in range(min(20, len(files))):
threads.append(new_thread(path, files.pop(), host, queue, i))
for _ in xrange(count):
tid, result, file, path2 = queue.get()
if(result):
if len(files):
print("OK \t" + path + ' remain: ' + str(len((files))))
threads[tid] = new_thread(path, files.pop(), host, queue, tid)
else:
print("NOT OK \t" + path + ' remain: ' + str(len((files))))
threads[tid] = new_thread(path2, file, host, queue, tid)
print('The end.')
>>> import glcanvas>>> glcanvas.GLCanvas(None)Traceback (most recent call last): File "<console>", line 1, in <module>RuntimeError: eglCreateContext failed [Errno 12291]>>>
class StatusIcon(gtk.Builder):
def __init__(self):
super(StatusIcon, self).__init__()
self.statusicon = gtk.StatusIcon()
self.statusicon.set_from_file("../../images/favicon.png")
self.statusicon.connect("popup-menu", self.right_click_event)
self.statusicon.set_tooltip("StatusIcon Example")
def right_click_event(self, icon, button, time):
menu = gtk.Menu()
update = gtk.ImageMenuItem(gtk.STOCK_REFRESH)
about = gtk.ImageMenuItem(gtk.STOCK_ABOUT)
settings = gtk.ImageMenuItem(gtk.STOCK_PREFERENCES)
quit = gtk.ImageMenuItem(gtk.STOCK_QUIT)
about.connect("activate", self.show_about_dialog)
settings.connect("activate", self.settings)
quit.connect("activate", gtk.main_quit)
menu.append(settings)
menu.append(update)
menu.append(about)
menu.append(quit)
menu.show_all()
menu.popup(None, None, gtk.status_icon_position_menu, button, time, self.statusicon)
def __getattr__(self, attr):
obj = self.get_object(attr)
if not obj:
raise AttributeError('object %r has no attribute %r' % (self,attr))
setattr(self, attr, obj)
return obj
def settings(self, widget):
self.add_from_file("./1.glade")
self.connect_signals(self)
agroup = gtk.AccelGroup()
self.window1.add_accel_group(agroup)
self.window1.show_all()