Search posterous

Search all posts and users. Type a name, type a favorite song title, whatever! See what comes up.
  

More posterous blogs











More recommended blogs »

Here are posterous posts filed under trac...

ulfklose says...

Leider haben sowohl Posterous als auch Blogger mich dazu gezwungen, das Dokument nur im PDF-Format anbieten zu können, da sich beide System entweder an der Länge und/oder den Sonderzeichen im Text verschluckt haben.

Fragen und Kommentare bitte trotzdem in die Kommentare.

(download)

Filed under: trac

niels says...

A little while ago I was tasked with migrating about hundred Trac instances from SQLite to MySQL. Unfortunately SQLites schema definitions is not compatible with MySQL. So I had to write some scripts to handle it. After a little bit of experimenting everything worked perfectly.

The Strategy I employed was like this:

  1. Make a dump of a default MySQL Trac db schema.
  2. Make a dump of the Trac SQLite database
  3. Remove db schema definitions from the SQLite dump
  4. Concatenate the MySQL and SQLite dumps
  5. Load data into MySQL
  6. Edit Trac's database settings to use MySQL
  7. Do a trac-admin upgrade

Here is the shell script I made:



MYSQL_USER=username
MYSQL_PSWD=password

SQLITECMD=sqlite3
TRACBASE=/path/to/tracreps


# loop through all trac instances in tracreps
for d in $( ls $TRACBASE )
do
if [ -d "$TRACBASE/$d" ]; then
echo $d
TRACNAME=$d

# create database in mysql
echo "creating database for $TRACNAME..."
mysqladmin --user $MYSQL_USER -p$MYSQL_PSWD create $TRACNAME

# dump sqlite db structure + data
echo "dumping data from sqlite..."
$SQLITECMD $TRACBASE/$TRACNAME/db/trac.db .dump > trac.sqlite.sql

# remove database definitions from dump using a custom python script
echo "cleaning database definition from dump..."
`./cleansql.py < trac.sqlite.sql > trac.sqlite.sql.dataonly`

# concatenate mysql database definitions and sqlite data
cat trac.mysql.sql trac.sqlite.sql.dataonly > trac.sql

echo "loading data into mysql..."
mysql --user $MYSQL_USER -p$MYSQL_PSWD --default_character_set utf8 $TRACNAME < trac.sql

# edit database connection string in trac.ini
sed -i "s?sqlite:db/trac.db?mysql://$MYSQL_USER:$MYSQL_PSWD@localhost:3306/$TRACNAME?" $TRACBASE/$TRACNAME/conf/trac.ini

echo "upgrading mysql database..."
trac-admin $TRACBASE/$TRACNAME upgrade --no-backup


To remove schema definitions from the sqlite dump and fix some incompatibilities I made this python script referenced above as cleansql.py:



#!/usr/bin/env python

import sys
import re

file = sys.stdin.read()
file = re.sub(r'(CREATE (TABLE|INDEX)[^;]*|COMMIT|BEGIN TRANSACTION);', '', file)
file = re.sub(r'INSERT INTO "([^"]+)"', lambda m: 'INSERT INTO `%s`' % m.groups(1), file)
# fix sql for reports
file = re.sub(r'CAST\((.+) AS int\)', lambda m: 'CAST(%s AS signed)' % m.groups(1), file)

sys.stdout.write(file)


And that's it. I hope this will benefit someone tasked with the same job.

Filed under: trac

Brian says...

I just released version 1.2 of my Textmate Trac bundle.  It includes an awesome new Preview command contributed by Tudor Marghidanu.  While editing a Trac wiki page, just hit command-option-control-p (same as Markdown, etc.) to pop up an HTML formatted preview of the page.  Seriously useful.  Thanks Tudor!

The command requires the Text::Trac perl module, which you can install from CPAN by running the following in Terminal:

sudo perl -MCPAN -e 'install Text::Trac'

If this is the first time you've used CPAN, it will probably ask you a few questions, and accepting the defaults usually works out well.

Enjoy.

Filed under: trac

ulfklose says...

It took me around two hours to figure out, why Trac was always throwing the following error, when launched using tracd:

Warning: Can't synchronize with the repository (Unsupported version control system "git":
Can't find an appropriate component, maybe the corresponding plugin was not
enabled? ). Look in the Trac log for more information.

The Ubuntu package trac-git was perfectly installed and seemed to work fine. The real reason was that the Ubuntu package trac-git depends on python2.6, which obviously doesn't work with trac-git.

So I did an

aptitude install python2.5 && rm /usr/bin/python && ln -s /usr/bin/python2.5 /usr/bin/python

which did the trick. After that, tracd was able to use the trac plugin for Git.

If it still doesn't work make sure that you have at least the following lines in your project's trac.ini:

[components] 
# for plugin version 0.10
gitplugin.* = enabled

# for plugin version 0.11.0.1+
tracext.git.* = enabled

[git]
cached_repository = true
git_bin = /usr/bin/git
persistent_cache = true
shortrev_len = 7

[trac]
repository_dir = /path/to/git/repository.git
repository_type = git

If everything above is set a

tracd --port 8000 /var/trac/yourpath

should start tracd and make it available via port 8000 on your machine.

 

Filed under: trac

bAbymAn says...

Installing the trac (http://trac.edgewall.org/) project to manage bugs and possibly even features/specifications for your projects. First install the trac dependencies

apt-get install python python-central python-setuptools 
python-pysqlite2 python-subversion libjs-jquery python-genshi 
python-tz python-pygments

use easy_install to install the latest version of trac (we had issues with the apt-get version and attachments)

easy_install -n http://svn.edgewall.org/repos/trac/tags/trac-0.11.4

create the directories that will contain our trac project files

mkdir /opt/trac 
mkdir -p /opt/trac/.trac-base/egg-cache 
cd /opt/trac

create the trac project

trac-admin trac-example initenv

create a password file and setup initial users

htpasswd /opt/htpasswd

make sure apache owns the trac directories

chown -R www-data:www-data /opt/trac

configure apache to handle trac as the root site

vim /opt/apache2/sites-enabled/trac

<VirtualHost *:80>
        Alias /trac/ /usr/share/trac/htdocs 
 
        ErrorLog /var/log/apache2/error.trac.log 
        CustomLog /var/log/apache2/access.trac.log combined 
 
         <Location "/">
                SetHandler mod_python 
                PythonInterpreter main_interpreter 
                PythonHandler trac.web.modpython_frontend 
                PythonOption TracEnvParentDir /opt/trac/ 
                PythonOption TracUriRoot / 
                PythonOption PYTHON_EGG_CACHE /opt/trac/.trac-base/egg-cache 
         </Location>

        # use the following for one authorization for all projects 
        # (names containing "-" are not detected): 
         <Location "/">
            AuthType Basic 
            AuthName "trac" 
            AuthUserFile /opt/htpasswd 
            Require valid-user 

        </Location>

</VirtualHost>

restart apache

/etc/init.d/apache2 restart

check the system with your browser by navigating to http://localhost/

 

Filed under: trac

bAbymAn says...

svnsync can be used to synchronize a remote subversion repository into a local one, this can be useful as a backup mechanism or to allow a trac (http://trac.edgewall.org/) instance to access subversion when it is impractical to host both on the same computer.

Create the new subversion repository and initialize it
svnadmin create svn.example.com

Create the pre-revprop-change hook script required by svnsync

Initialize the repository 
svnsync init file://$PWD/svn.example.com https://svn.example.com/

Resynchronize the repository with the master
svnsync sync file://$PWD/svn.example.com

Setup crontab to perform this operation every 5 minutes
crontab -e
*/5 * * * * /usr/bin/svnsync sync --non-interactive file:///opt/svn.example.com

NOTE: svnsync creates a lock property and if it fails for some reason this lock will prevent any further synchronizations, to remove it use the following
svn proplist --revprop -r 0 file:///opt/svn.example.com/
svn propdel svn:sync-lock --revprop -r 0  file:///opt/svn.example.com/

Filed under: trac

hdknr says...

小さなスクリプトのためのリポジトリ探し

大抵のプログラマーは、気の利いた小さなスクリプトを書きためると思います。自分の手垢のついたコードはそれなりに有用です。

これまではこの手のスクリプトはパソコンを買い替えたりするとUSBメモリなんかにバックアップしたりCD-Rに焼いたりで必要な時に見つからず結構メンドクサイ思いをしてきました。

assembla-logo.gif

そんなわけで個人用サンプルコードもSubversionで管理したいなぁと思い探し当てたホスティングサービスがassemblaです。assemblaはなんと無料で利用できます。(ディスクスペースの上限は500MB)

Filed under: trac