Latest
While trying to get django's builtin testing system working (http://docs.djangoproject.com/en/dev/topics/testing/) with postgres/postgis and geodjango I hit a roadblock.
Basically, I was hoping it would just work, but my first attempt brought up an exception:
$ python manage.py test myapp
Creating new spatial database...
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python26\Lib\site-packages\django\core\management\__init__.py", line 340, in execute_manager
utility.execute()
File "C:\Python26\Lib\site-packages\django\core\management\__init__.py", line 295, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python26\Lib\site-packages\django\core\management\base.py", line 192, in run_from_argv
self.execute(*args, **options.__dict__)
File "C:\Python26\Lib\site-packages\django\core\management\base.py", line 219, in execute
output = self.handle(*args, **options)
File "C:\Python26\Lib\site-packages\django\core\management\commands\test.py", line 33, in handle
failures = test_runner(test_labels, verbosity=verbosity, interactive=interactive)
File "C:\Python26\Lib\site-packages\django\contrib\gis\tests\__init__.py", line 196, in run_tests
create_spatial_db(test=True, verbosity=verbosity)
File "C:\Python26\Lib\site-packages\django\contrib\gis\db\backend\postgis\creation.py", line 118, in create_spatial_dload_postgis_sql(db_name, verbosity=verbosity)
File "C:\Python26\Lib\site-packages\django\contrib\gis\db\backend\postgis\creation.py", line 189, in load_postgis_sql
raise Exception('Could not find PostGIS function definitions in %s' % lwpostgis_file)
Exception: Could not find PostGIS function definitions in C:/PROGRA~1/POSTGR~1/8.3/share\lwpostgis.sql
ugh! Ok, so searching around I found this nice series of posts describing the issue:
http://www.pointy-stick.com/blog/2009/03/03/testing-geodjango/
http://www.pointy-stick.com/blog/2009/03/06/testing-geodjango-part-2/
I'm running postgres/postgis on windows and so I added the following to my settings file (I'm using Django 1.0.2):
POSTGIS_SQL_PATH = 'C:\\Program Files\\PostgreSQL\\8.3\\share\\contrib'
TEST_RUNNER='django.contrib.gis.tests.run_tests'
Runnning tests for myapp again, asked for the postgres db password when trying to run some sql found in the contrib directory, but it now appears to run successfully!
monkut // May 7, 2009 // 8:04 a.m. // 622 CommentsI've been struggling to get sphinx (http://sphinx.pocoo.org/index.html) output working properly with Japanese text. (I assume this will also work with Chinese and Korean as well, but I haven't tested, and the encoding portion may not work or need to be changed)
I've finally got a solution that works for me.
Previously I had been using MiKTeX to convert sphinx's *.tex output to pdf, but hit a wall when trying to convert Japanese characters.
Latex seems to be a mess when dealing with non-ascii characters.
Using w32tex (http://www.fsci.fuk.kindai.ac.jp/kakuto/win32-ptex/web2c75.html) I was able to successfully convert the output *.tex file Sphinx creates to pdf.
The method I used is described below.
Installation Steps
====================
1. Create C:\w32tex directory
2. Create C:\w32tex\archivedpackages directory
3. Download "texinst757.zip" from http://www.fsci.fuk.kindai.ac.jp/kakuto/win32-ptex/web2c75.html
4. Unzip "texinst757.zip" into C:\w32tex
5. Download ALL files from the "最小インストール"(Minimal Install) and "標準インストール" (Standard install) lists and place them in C:\w32tex\archivedpackages
6. In addition download the following packages from the "フルインストール" (Full Install) list
ums.tar.gz
omegaj-w32.tar.gz
ttf2pt1-w32.tar.bz2
utf.tar.gz -- not sure if it's needed
uptex-w32.tar.bz2 -- not sure if it's needed
7. Download and install ghostscript ftp://akagi.ms.u-tokyo.ac.jp/pub/TeX/win32-gs/gs863w32full-gpl.zip
A. Check the "Use Windows TrueType fonts for Chinese, Japanese and Korean" option and Install into C:\w32tex\gs
8. Download and install IPA fonts from http://lx1.avasys.jp/OpenPrintingProject/openprinting-jp-0.1.3.tar.gz
A. Drag and drop the *.ttf files found in the archive to the Windows/Fonts directory.
- this will install the fonts on the pc
9. Run the following command:
texinst757.exe C:\w32tex\archivedpackages
NOTE: This will take some time
10. Add the following to your system path:
C:\w32tex\bin
C:\w32tex\gs\gs8.63\bin
C:\w32tex\gs\gs8.63\lib
11. Download ftp://cam.ctan.org/tex-archive/macros/latex/contrib/titlesec.zip, unzip and copy the titlesec folder to C:\w32tex\share\texmf\latex\
12. Run the following command (You may need to restart your console in order to take the new path settings into effect)
- This command will search and update fonts/styles (*i think*) that were added in step 11.
texhash
Installation is now Done!
Converting Sphinx *.tex output to PDF
========================================
Now that you have w32tex installed, you still need to adjust some of your process in order to create a pdf properly.
Note: I'm using sphinx 0.6.1
1. In your conf.py add/uncomment the latex_elements and update to look like this:
latex_elements = {
'preamble': '\usepackage{ums}\input jpdftextounicode\pdfgentounicode=1',
'inputenc': '',
'fontenc': '',
'fontpkg': '',
}
2. Build your *.tex file using sphinx.
- My source files are utf8, and I believe sphinx outputs the *.tex to utf8.
3. Convert the output text to cp932 encoding
- Ideally, topdftex.exe/pdflatex.exe support utf8, but I haven't figured this out, so this is currently a workaround step
import codecs
utf8_f = codecs.open('sphinx_output.tex', 'rb', 'utf8')
cp932_f = codecs.open('sphinx_output.cp932.tex', 'wb', 'cp932')
cp932_f.write(utf8_f.read())
utf8_f.close()
cp932_f.close()
4. Run topdftex.exe on the converted output, renaming to the orignal *.tex name.
topdftex.exe sphinx_output.cp932.tex sphinx_output.tex
5. Run pdflatex.exe on the final output, sphinx_output.tex.
I hope this helps.
monkut // April 22, 2009 // 3:46 a.m. // 2 Commentsリスト([])があって、それをループすると同時にインデックスが欲しいです。
よくあるパーターンですね。
今まではこのパーターンでループしていました:
x = ['a', 'b', 'c']
idx = 0
for i in x:
print idx, i
idx += 1
この間、enumerate()を見つけました。
これを使うとこうなります:
for idx, i in enumerate(x):
print idx, i
I use winxp at work, and several applications crash often.
Mainly, "Microsoft Office Communicator 2005", and "Windows Explorer".
(I don't mean InternetExplorer, that would be better, I mean the task bar and all file windows.)
This probably happens about once a week or once every other week.
However, when it happens it can happen multiple times a day.
I don't mind reloading MOC2005, since you just need to restart the app, but when Windows Explorer dies your kind of stuck. About half of the time it will auto-recover not requiring me to logout/login, but sometimes it dies and stays dead.
In both of these applications a "X has encountered a problem and needs to Close" dialog will appear asking to "Send Error Report".
I've noticed recently that if I don't click "Send Error Report" or "Don't Send", and just leave the dialog open the application appears to function normally. So now I just hide the dialog off to the side and ignore it.
Why does the application want close if it still functions fine?
monkut // March 26, 2009 // 12:57 a.m. // 1 CommentsJust heard good things about this video editing software:
http://cinelerra.org/
Something to check out.
monkut // March 3, 2009 // 7:09 p.m. // 0 Comments