python,cx-oracleRelated issues-Collection of common programming errors
nutship
python list python-2.7 with-statement
I want to read from a .txt file, which has data saved as in list format. [‘http://www.example.com/?date=20080301′,’http://www.example.com/?date=20080302′,’http://www.example.com/?date=20080303’]I have the following code:with open(“test.txt”, ‘r’) as file_name:for urls in file_name:for url in eval(urls):print urlIt worked well with exactly idential file (only different links) and now out of a sudden, it raises an exception:File “<string>”, line 1[‘http://www.example.com/?date=20080301’,^ Sy
AlexNasonov
python templates multiline web.py
I have a snippet in template like this:$ html = “””<p id=”address”>?????:<span id=”postcode”>123456</span>,<span id=”city”>??????</span>,<span id=”street”>??????? ???????</span>,<span id=”houseNumber”>?.1</span>,<span id=”addhouseNumber”>???.1</span>,<span id=”officeNumber”>???? 12</span> </p>””” $:htmlLoop(entry, ‘address’, html)When I try to render it I get traceback:extend_([u'</p>”””\n’])^ SyntaxError:
glglgl
python memoization
The call to GetData1 works well and prints:hello 67 8.3the call to GetData2 fails:TypeError: __call__() got an unexpected keyword argument ‘arg1’My code isclass Memoized(object):def __init__(self, func):self.func = funcself.cache = {}def __call__(self, *args):print argswith Locker:try:return self.cache[args]except KeyError:self.cache[args] = value = self.func(*args)return valuedef GetData1(arg1, arg2, arg3) :print arg1, arg2, arg3@Memoized def GetData2(arg1, arg2, arg3) :print arg1, arg2, arg3r
jack
python django utf-8
I got the following error when tried to add an entry to a Django model via generic relations.django.utils.encoding.DjangoUnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xb8 in position 24: unexpected code byte. You passed in ‘ASL/60Styles_Timeless-3_\xb8 CaLe.asl’ (<type ‘str’>)The model is like this:class MD5(models.Model):value = models.CharField(max_length=32, db_index=True)filename = models.CharField(max_length=100)content_type = models.ForeignKey(ContentType)object_id = models.Pos
J.F. Sebastian
python
I have some scripts in the folder ~/Scripts which I have added to the path. So I tried to test if I can run them, just by calling them. I have python 3.1 over Linux Mint 11.user@pc ~/Scripts $ python aek.py AEKuser@pc ~/Scripts $ aek.py/home/user/Scripts/aek.py: line 1: syntax error near unexpected token `’AEK”/home/user/Scripts/aek.py: line 1: `print(‘AEK’)’The code is just this one line:print(‘AEK’)
tehryan
python cherrypy
For instance I want to visit http://localhost:8080/?var=val or similar with POST, but I get a 500 server error:500 Internal Server ErrorThe server encountered an unexpected condition which prevented it from fulfilling the request.Traceback (most recent call last):File “c:\python26\lib\site-packages\cherrypy\_cprequest.py”, line 606, in respondcherrypy.response.body = self.handler()File “c:\python26\lib\site-packages\cherrypy\_cpdispatch.py”, line 25, in __call__return self.callable(*self.args, *
user216485
python
Looking at this django code from the djangobook:from django.http import Http404, HttpResponse import datetimedef hours_ahead(request, offset):try:offset = int(offset)except ValueError:raise Http404()dt = datetime.datetime.now() + datetime.timedelta(hours=offset)html = “<html><body>In %s hour(s), it will be %s.</body></html>” % (offset, dt)return HttpResponse(html)after the try, it converts offset into an integer, right? and in the line ‘datetime.timedelta(hours=offset)’,
Tim Cooper
python regex html-parsing beautifulsoup urllib
Here is the html I am trying to parse.<TD>Serial Number</TD><TD>AB12345678</TD>I am attempting to use regex to parse the data. I heard about BeautifulSoup but there are around 50 items like this on the page all using the same table parameters and none of them have ID numbers. The closest they have to unique identifiers is the data in the cell before the data I need.serialNumber = re.search(“Serial Number</td><td>\n(.*?)</td>”, source)Source is simply the
diegoaguilar
python
At this code snippet:def taylorVazquez(fx,a,b,n,puntos):puntosX = linspace(a,b,num=puntos)aproxY = []puntosY = [] def toFloat():puntosX = [float(x) for x in puntosX]aproxY = [float(y) for y in aproxY]puntosY = [float(y) for y in puntosY]I’m getting the error message:UnboundLocalError: local variable ‘puntosX’ referenced before assignment And so I know same would happen to the other two variables. What can I do it’s the outer taylorVazquez’s variables the ones I manipulate at inner function, i
Deniz Dogan
python django utf-8 lxml decoding
I have a strange problem with lxml when using the deployed version of my Django application. I use lxml to parse another HTML page which I fetch from my server. This works perfectly well on my development server on my own computer, but for some reason it gives me UnicodeDecodeError on the server.(‘utf8’, “\x85why hello there!”, 0, 1, ‘unexpected code byte’)I have made sure that Apache (with mod_python) runs with LANG=’en_US.UTF-8′.I’ve tried googling for this problem and tried different approa
Danny Beckett
django centos mod-wsgi cx-oracle centos6
I´m having serious trouble to get Django to work with my Apache/mod_wsgi installation accessing Oracle. I have this setup running on a CentOS 6 host, and I’m getting this error in my Apache logs:Error loading cx_Oracle module: libclntsh.so.10.1: cannot open shared object file: No such file or directoryIf I try to import cx_Oracle from the Python command line it works fine in both root and apache users. I set ORACLE_HOME and LD_LIBRARY_PATH ($ORACLE_HOME/lib) correctly: in ~/.bashrc, /etc/ld.so.c
ftartaggia
django apache oracle11g httpd cx-oracle
This is my application environment:Redhat 6.0 Apache 2.2 Django 1.3.0 Python 2.6.6 cx_Oracle 5.1 mod_wsgi 3.2 Oracle DBMS 11.2 (on a different machine)Issue: accessing my django website from a web browser fails because cx_Oracle can’t acquire Oracle handle.Tests:running django-admin.py shell to query the db DOES WORK (running from a bash session with ORACLE_HOME and LD_LIBRARY_PATH vars set) running a custom script that adds ORACLE_HOME and LD_LIBRARY_PATH to os.environ and uses cx_Oracle to con
Sean McCully
python cx-oracle
My python application is dying, this oracle trace file is being generated. I am using cx_Oracle, how do I go about using this trace file to resolve this crash?ora_18225_139690296567552.trc kpedbg_dmp_stack()+360<-kpeDbgCrash()+192<-kpureq2()+3194<-OCIStmtPrepare2()+157<-Cursor_InternalPrepare()+298<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010<-0000000000EA3010
Dougman
python oracle pyodbc cx-oracle instantclient
I can connect to a Oracle 10g release 2 server using instant client. Using pyodbc and cx_Oracle.Using either module, I can execute a select query without any problems, but when I try to update a table, my program crashes.For example,SELECT * FROM table WHERE col1 = ‘value’; works fine.UPDATE table SET col2 = ‘value’ WHERE col1 = ‘val’; does not workIs this a known limitation with instant client, or is there a problem with my installation?Thanks in advance for your help.
Uniphase38
python cx-oracle
I’m trying to call an oracle pl/sql function returning an oracle object by using cx_Oracle’s cursor.callfunc() but cannot bring it to work and found no help neither in the documentation nor on the net. my code:connection = cx_Oracle.connect(‘myuser/mypass@myservice’) cursor = connection.cursor() result = cursor.var(cx_Oracle.OBJECT) cursor.callfunc(‘myfunction’, result , [an_arg]) Traceback (most recent call last):File “…”, line nn, in <module>result = cursor.var(cx_Oracle.OBJECT) TypeEr
Pat
python cx-oracle
First, the SQL that I’m dealing with:CREATE OR REPLACE TYPE address_t AS OBJECT ( street VARCHAR2(80), city VARCHAR2(80), state_abbr CHAR(2), zip_code DECIMAL(5) ) /CREATE TABLE branch ( id DECIMAL(12) NOT NULL, address address_t PRIMARY KEY(id) ) /I’ve verified that the data is correct in the database (after putting in some test data). I’m trying to now write a JSONEncoder for parsing the Oracle address_t type as a serializable JSON type. Here’s the function I’ve been
Mark
python osx oracle cx-oracle instantclient
So I followed these directions here to install Oracle InstantClient,installing Oracle Instantclient on Mac OS/X without setting environment variables?But when I try to install cx_oracle I get the following stack trace,python setup.py build running build running build_ext building ‘cx_Oracle’ extension creating build creating build/temp.macosx-10.6-universal-2.6-10g gcc-4.2 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -fwrapv -Os -Wall -Wstrict-prototypes -DENABLE_DTRACE -arch i386 -arc
Andrew
python apache2 mingw lxml cx-oracle
when I launch my application with apache2+modwsgi I catch Exception Type: ImportError Exception Value: DLL load failed: The specified module could not be found.in linefrom lxml import etreewith Django dev server all works fine Visual C++ Redistributable 2008 installedDependency walker told that msvcrt90.dll is missed but there is same situation with cx_Oracle, but cx_Oracle’s dll loads correctany ideas?windows 2003 server 64bit and windows XP sp3 32bit python 2.7 32 bit cx_Oracle 5.0.4 32bitU
nashr rafeeg
python cx-oracle
I am having issiues installing cx_oracle. I have installed oracle instantclient and cx_oracle oracle packages ones installed i am getting this error while importing cx_oracle. i am running ubuntu 11.10 as host. import cx_Oracle Traceback (most recent call last): File “<console>”, line 1, in <module> ImportError: /usr/lib/python2.7/dist-packages/cx_Oracle.so: undefined symbol:PyUnicodeUCS2_AsEncodedStringany one have any idea how to resolve this issue cheers
cwallenpoole
python cx-oracle
I’m trying to install the cx_Oracle for Python 2.6, but it is failing. I don’t know enough about C or MS Vis. Studio’s compiler to even approach fixing it myself.This is what is output on the command line:C:\pydev\cx_Oracle-5.0.1>C:\python26\python setup.py install running install running build running build_ext building ‘cx_Oracle’ extension C:\Program Files\Microsoft Visual Studio 9.0\VC\BIN\cl.exe /c /nologo /Ox /MD /W3 /GS- /DNDEBUG -IC:\Oracle\instantclient\sdk\include -IC:\p ython26\in
Web site is in building