Форум сайта python.su
DATABASE_ENGINE = 'sql_server.pyodbc'
C:\djproject\mysite>manage.py syncdb
Traceback (most recent call last):
File "C:\djproject\mysite\manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
340, in execute_manager
utility.execute()
File "C:\Python25\lib\site-packages\django\core\management\__init__.py", line
295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 77,
in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python25\lib\site-packages\django\core\management\base.py", line 87,
in execute
translation.activate('en-us')
File "C:\Python25\lib\site-packages\django\utils\translation\__init__.py", lin
e 73, in activate
return real_activate(language)
File "C:\Python25\lib\site-packages\django\utils\translation\__init__.py", lin
e 43, in delayed_loader
return g['real_%s' % caller](*args, **kwargs)
File "C:\Python25\lib\site-packages\django\utils\translation\trans_real.py", l
ine 209, in activate
_active[currentThread()] = translation(language)
File "C:\Python25\lib\site-packages\django\utils\translation\trans_real.py", l
ine 198, in translation
default_translation = _fetch(settings.LANGUAGE_CODE)
File "C:\Python25\lib\site-packages\django\utils\translation\trans_real.py", l
ine 181, in _fetch
app = getattr(__import__(appname[:p], {}, {}, [appname[p+1:]]), appname[p+1:
])
File "C:\Python25\lib\site-packages\django\contrib\admin\__init__.py", line 1,
in <module>
from django.contrib.admin.options import ModelAdmin, HORIZONTAL, VERTICAL
File "C:\Python25\lib\site-packages\django\contrib\admin\options.py", line 5,
in <module>
from django.contrib.contenttypes.models import ContentType
File "C:\Python25\Lib\site-packages\django\contrib\contenttypes\models.py", li
ne 1, in <module>
from django.db import models
File "C:\Python25\lib\site-packages\django\db\__init__.py", line 34, in <modul
e>
(settings.DATABASE_ENGINE, ", ".join(map(repr, available_backends)), e_user)
django.core.exceptions.ImproperlyConfigured: 'sql_server.pyodbc' isn't an availa
ble database backend. Available options are: 'dummy', 'mysql', 'oracle', 'postgr
esql', 'postgresql_psycopg2', 'sql_server', 'sqlite3'
Error was: No module named sql_server.pyodbc.base
DATABASE_ENGINE = 'sql_server'
class Webber(QtGui.QMainWindow):
def __init__(self,cookieFile):
QtGui.QMainWindow.__init__(self)
self.resize(800,600)
quit = QtGui.QPushButton('Cookies', self)
quit.setGeometry(10, 10, 60, 35)
self.connect(quit, QtCore.SIGNAL('clicked()'),self.printer)
cj = cookielib.LWPCookieJar()
if os.path.isfile(cookieFile):
cj.load(cookieFile)
self.view = QtWebKit.QWebView(self)
self.page=QtWebKit.QWebPage()
self.manager=QtNetwork.QNetworkAccessManager()
self.cj=QtNetwork.QNetworkCookieJar()
self.manager.setCookieJar(self.cj)
#manger.setProxy(QtWebKit.QNetworkProxy)
self.page.setNetworkAccessManager(self.manager)
self.view.setPage(self.page)
self.view.setGeometry(100, 200, 500, 300)
self.view.load(QtCore.QUrl('http://www.google.com.ua/'))
self.view.show()
def printer(self):
print self.cj.allCookies()
#!/usr/bin/python
"""Hello, wxPython! program."""
import wx
class Frame(wx.Frame):
"""Frame class that displays an image."""
def __init__(self, image, parent=None, id=1,
pos=wx.DefaultPosition,
title='Hello, wxPython!'):
"""Create a Frame instance and display image."""
temp = image.ConvertToBitmap()
size = temp.GetWidth(), temp.GetHeight()
wx.Frame.__init__(self, parent, id, title, pos, size)
self.bmp = wx.StaticBitmap(parent=self, bitmap=temp)
class App(wx.App):
"""Application class."""
def OnInit(self):
image = wx.Image('wxPython.jpg', wx.BITMAP_TYPE_JPEG)
self.frame = Frame(image)
self.frame.Show()
self.SetTopWindow(self.frame)
return True
def main():
app = App()
app.MainLoop()
if __name__ == '__main__':
main()
/* potok.c */
#include <stdio.h>
#include <pthread.h>
#include <signal.h>
pthread_t potok_id;
void * mypotok()
{
while (1) { fprintf(stderr,"СиПоток\n"); sleep(1); }
}
void pusk() {
pthread_create(&potok_id,NULL,&mypotok,NULL);
sleep(3);
pthread_cancel(potok_id);
if( !pthread_equal( pthread_self(),potok_id ) )
{
printf("\n%d\n", pthread_equal( pthread_self(), potok_id ));
fprintf(stderr,"поток завершен\n");
pthread_join(potok_id,NULL);
}
int i;
for (i=0; i<3; i++) {
fprintf(stderr,"СиПроцесс\n"); sleep(1);
}
}
%module potok
%include potok.c
>>> import potok
>>> potok.pusk()
СиПоток
СиПоток
СиПоток
0
поток завершен
СиПроцесс
СиПроцесс
СиПроцесс
>>>
/* Npotok.c */
#include <stdio.h>
#include <pthread.h>
#include <signal.h>
pthread_t potok_id ; /* идентификатор потока */
void * mypotok()
{
while (1) { fprintf(stderr,"СиПоток\n"); sleep(1); }
}
void start()
{
pthread_create(&potok_id,NULL,&mypotok,NULL);
}
void finish()
{
pthread_cancel(potok_id);
if( !pthread_equal( pthread_self(),potok_id ) )
{
printf("\n%d\n", pthread_equal( pthread_self(), potok_id ));
fprintf(stderr,"поток завершен\n");
pthread_join(potok_id,NULL);
}
}
void pusk()
{
start();
sleep (3);
finish();
int i;
for (i=0; i<3; i++) {
fprintf(stderr,"СиПроцесс\n"); sleep(1);
}
}
self.ctrl.SetItemState(row_id,wx.LIST_STATE_SELECTED,wx.LIST_STATE_SELECTED)
(r'^$', 'django.views.generic.simple.direct_to_template', {
'template': 'base.html',
'extra_context' : {'title':'Main page',},
'title' : ''Main page',
}),
<title>{{ title }}</title>
<p>{{ params.title }}</p>
ICONS_PATH = u'C:\\Data\\python\\pytree\\'
basic = pyTreeControl(None, user_callback = key_callback) # название basic осталось от примера на основе которого делал, но это не важно
appuifw.app.body = basic.control()
tree = cTreeOssa(u'----')
controll = pyTreeControl(tree, user_callback = key_callback)
basic.set_tree(tree) # после этого вызова контрол сам перерисует дерево
# -*- coding: cp1251 -*-
import wx
from wx.lib.mixins import listctrl
import locale
locale.setlocale(locale.LC_ALL,'Russian_Russia.1251')
import wx.lib.customtreectrl, wx.gizmos
from wx.lib.mixins import treemixin
from random import randint
class VirtualTreeListCtrl(treemixin.VirtualTree, wx.gizmos.TreeListCtrl,listctrl.ListCtrlAutoWidthMixin):
''' View:Виртуальное дерево
'''
def __init__(self, *args, **kwargs):
''' Виртуальное дерево
'''
self.model = kwargs.pop('treemodel')
kwargs['style'] = wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_ROW_LINES | wx.TR_COLUMN_LINES
super(VirtualTreeListCtrl, self).__init__(*args, **kwargs)
listctrl.ListCtrlAutoWidthMixin.__init__(self)
size = (16, 16)
self.imageList = wx.ImageList(*size)
self.red16 = self.imageList.Add(wx.Bitmap('red16.gif', wx.BITMAP_TYPE_GIF))
self.silver16 = self.imageList.Add(wx.Bitmap('silver16.gif', wx.BITMAP_TYPE_GIF))
self.green16 = self.imageList.Add(wx.Bitmap('green16.gif' ,wx.BITMAP_TYPE_GIF))
self.ivory16 = self.imageList.Add(wx.Bitmap('ivory16.gif' ,wx.BITMAP_TYPE_GIF))
self.AssignImageList(self.imageList)
columns = ['0','1','2','3','4','5','6']
for item in columns:
self.AddColumn(item[0])
def UpdateAllData(self):
''' обновить данные в модели.
'''
self.model.UpdateAllData()
self.RefreshItems()
def OnGetChildrenCount(self,indices):
return self.model.GetChildrenCount(indices)
def OnGetItemBackgroundColour(self,indices):
if indices[0] % 2 == 0:
return wx.Colour(207,229,255)
if indices[0] % 2 == 1:
return wx.Colour(217,255,237)
def OnGetItemText(self, indices, column=0):
return '%s' % (self.model.GetText(indices,column))
def OnGetItemImage(self, indices, which, column=0):
''' вернуть имидж в колонке
'''
return -1
class TreeModel(object):
''' Model:Модель обеспечивающая данные для виртуального дерева
'''
def __init__(self, *args, **kwargs):
self._DoSort()
super(TreeModel, self).__init__(*args, **kwargs)
self.k = 0
def UpdateAllData(self):
self._DoSort()
def GetItem(self, indices):
return self.jobs[indices[0]][0]
def _DoSort(self):
self.orig_items = []
count = 1000
for i in xrange(count):
a = [i,]
for i in xrange(6):
a.append(randint(0, 1000))
self.orig_items.append(a)
self.jobs = self.orig_items
def GetText(self, indices,column):
""" Запрос отображения строки, колонки
"""
return self.jobs[indices[0]][column]
def GetChildren(self, indices):
return "GetChildren"
def GetChildrenCount(self, indices):
try:
self.jobs
except:
return 0
if indices == ():
return len(self.jobs)
else:
return 0
class Job2Panel(wx.Panel):
def __init__(self, parent):
super(Job2Panel, self).__init__(parent)
self.treemodel = TreeModel()
sizer = wx.BoxSizer()
self.tree = VirtualTreeListCtrl(self,treemodel=self.treemodel)
sizer.Add(self.tree, proportion=1, flag=wx.EXPAND)
self.SetSizer(sizer)
# #зарядка дерева
self.tree.RefreshItems()
self.tree.SetFocus()
def UpdateAllData(self):
self.tree.UpdateAllData()
class App(wx.App):
def __init__(self):
wx.App.__init__(self, True, 'log.txt')
frame = wx.Frame(None, size=(800, 500))
frame.panel = Job2Panel(frame)
self.SetTopWindow(frame)
frame.Show()
if __name__ == "__main__":
app = App()
app.MainLoop()
def createDataModel(self):
self.treestore = gtk.TreeStore(str, str, int, int, int)
for product in Product.query.all():
self.treestore.append(None, [product.name, product.category, product.fat, product.protein, product.carbo])
return self.treestore