[kforge-dev] windows problem creating database

Nikolas Bowe nbowe at infinite-interactive.com
Fri Aug 11 08:05:46 UTC 2006


Hi again.


Sorry if this isnt threaded properly; Im on a different machine.

Id *like* to run this on linux. 
But my work doesnt have anyone else who is comfortable in it.
So Im actually converting our current source control from a linux machine that I maintain to windows.
And while I was at it I thought kforge looked like a simple interface to managing the projects.


Creating the db by hand works
  C:\django\kforge>createdb -h localhost -U kforge kforge
  Password:
  CREATE DATABASE

but initing it prints an error.
  C:\django\kforge>python \Python24\Scripts\kforge-admin db init
  Command failed. Details: 'Permission' object has no attribute 'protectionObject'

some records go in but it is very sparse. i attached the dump from pg_dump
really not sure on this one. any ideas?


  C:\django\kforge>python \Python24\Scripts\kforge-admin www build
works fine (no output)
but in the generated httpd.conf it has this line a lot
            SetEnv PYTHONPATH 
is that meant to point to python path or is it correct as it is? 
On windows python doesnt set the PYTHONPATH environment variable. rather (annoyingly) it keeps it in the registry.
On my setup it is "C:\Python24\Lib;C:\Python24\DLLs;C:\Python24\Lib\lib-tk"
I just added it to my system environment variables manually. then rebuilt the httpd.conf. looks ok.
could probably do with a mention in the INSTALL file.
Apparently under mac os x this variable is also not set by default. so a mention is probably a good idea. I dont have OS X though so I cant confirm this.


Regarding the \ escape problem
It can happen on other platforms even though they use different seperators because they use the \ to escape strange characters.
For example:
I have a folder called "my/files". If a person wants the slash to be treated as part of the folder name then they escape it with \
"/usr/share/my\/files"
most languages (im not sure on python.) will output this as "/usr/share/my/files", thus treating "files" as a subdir of "my".
sure its an unlikely name. but it can happen :)


It turns out that the commands module is unix specific.
http://docs.python.org/lib/unix.html
I searched the .py files for these modules and commands is the only one used.

the following files all use commands.getstatusoutput (i only check .py files. there may be more)
Find all "commands.getstatusoutput", Find Results 1, All Open Documents
C:\django\kforge-0.11\src\kforge\apache\apacheconfig.py(53):            errorStatus, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\src\kforge\test\kforge-admin_script_test.py(19):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\src\kforge\test\install_test.py(31):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\src\kforge\utils\db.py(40):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\build\lib\kforge\apache\apacheconfig.py(53):            errorStatus, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\build\lib\kforge\test\kforge-admin_script_test.py(19):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\build\lib\kforge\test\install_test.py(31):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\build\lib\kforge\utils\db.py(40):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\src\kforge\plugin\trac\command.py(66):        status, output = commands.getstatusoutput(cmd)
C:\django\kforge-0.11\build\lib\kforge\plugin\trac\command.py(66):        status, output = commands.getstatusoutput(cmd)
Total found: 10    Matching files: 367    Total files searched: 428

rather than alter all those files I added a short snippet to detect the problem and redirect the function.
but eventually Id recommend kforge using its own getstatusoutput.
as an interim approach I did the following

in my C:\Python24\Lib\site-packages\kforge\__init__.py
(before a kforge install it would be here in source tree kforge-0.11/src/kforge/core/ioc)
I added the following to the end

# patch(hack) to make commands.getstatusoutput work on winxp
def mygetstatusoutput(cmd):
    """Return (status, output) of executing cmd in a shell."""
    import os
    pipe = os.popen(cmd + ' 2>&1', 'r')
    text = pipe.read()
    sts = pipe.close()
    if sts is None: sts = 0
    if text[-1:] == '\n': text = text[:-1]
    return sts, text
import os
if (os.name == 'nt'):
    import commands
    commands.getstatusoutput = mygetstatusoutput

then it (almost) works:
  C:\django\kforge>python \Python24\Scripts\kforge-admin db rebuild
  Command dropdb requires 'kforge' user authentication:
  Password: 
  Command createdb requires 'kforge' user authentication:
  Password: 
  Command failed. Details: 'Permission' object has no attribute 'protectionObject'


Also it would be really nice if all the python scripts used .py as their extension if possible. (eg kforge-admin)
is there any reason against this?
it would mean that windows machines (that have .py associated with python) could execute kforge-admin without all th junk that I have to go through at the moment

Is a valid way to get apache to reload its config files to restart apache?
ie reload_apache = "C:\Program Files\Apache Group\Apache2\bin\apache" -k restart


The INSTALL file doesnt mention running kforge-admin db init, it only mentions create.
Create doesnt init the db even though rebuild does
but im not using the cvs version so its probably fixed in that.



Cheers
Nikolas Bowe
Infinite Interactive
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.okfn.org/pipermail/kforge-dev/attachments/20060811/10acde88/attachment.html>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: kforgedb.sql
URL: <http://lists.okfn.org/pipermail/kforge-dev/attachments/20060811/10acde88/attachment.ksh>


More information about the kforge-dev mailing list