bookmark_borderMoinMoin in DreamHost

I have tested using moin-1.9.3.tar.gz in DreamHost.
You have to enable Passenger in your domain.

Download  MoinMoin from:
http://moinmo.in/

Documentation (specially check the Server Installation part):
http://master19.moinmo.in/InstallDocs

1. ssh to your server, and download moin using wget.

2. Extract it:

tar -zxvf moin-1.9.3.tar.gz

3. Run setup script

cd moin-1.9.3
python setup.py –quiet install –prefix=$HOME –record=install.log

4. Check the install.log using emacs or nano for the python version it is using.

emacs install.log 
/home/youraccount/lib/python2.5/site-packages/…

5. Edit the moin.cgi (it would be easy, if you start another ssh shell in the server)

find -name moin.cgi     //if you want to find it yourself.
$HOME/share/moin/server/moin.cgi
emacs $HOME/share/moin/server/moin.cgi

Make the following changes

# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with –prefix=PREFIX or you didn’t use setup.py.
#sys.path.insert(0, ‘PREFIX/lib/python2.3/site-packages’)
# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/… for some sample config files.
#sys.path.insert(0, ‘/path/to/wikiconfigdir’)
===================================================

# a1) Path of the directory where the MoinMoin code package is located.
#     Needed if you installed with –prefix=PREFIX or you didn’t use setup.py.
sys.path.insert(0, ‘/home/youraccount/lib/python2.5/site-packages’)

# a2) Path of the directory where wikiconfig.py / farmconfig.py is located.
#     See wiki/config/… for some sample config files.
sys.path.insert(0, ‘/home/youraccount/moin/config’)

you can verify this location using another shell while editing.

6. This example is designed for single wiki
create this directory $HOME/moin/config/

cd $HOME/moin/config
cp $HOME/share/moin/config/wikiconfig.py .
cp -r $HOME/share/moin/data/ .
cp -r $HOME/share/moin/underlay/ .

7. Edit wikiconfig.py in $HOME/moin/config/

emacs wikiconfig.py

maka the following changes

# If that’s not true, feel free to just set instance_dir to the real path
# where data/ and underlay/ is located:
#instance_dir = ‘/where/ever/your/instance/is’
instance_dir = wikiconfig_dir
# If that’s not true, feel free to just set instance_dir to the real path
# where data/ and underlay/ is located:
instance_dir = ‘/home/youraccount/moin/config’
#instance_dir = wikiconfig_dir

Change the sitename if you want to change your wiki name.

8. Copy /home/youraccount/share/moin/server/moin.cgi to your public folder, and rename it to wiki.cgi
or
create a file wiki.cgi in your public folder. Softlink did not work for me, so lets call the moin.cgi using another python script.

#!/usr/bin/python
import os
os.system(‘python /home/youraccount/share/moin/server/moin.cgi’)

9. now you need to link the htdocs for css and images.

cd $HOME
find -name htdocs   //if you want to find it yourself
(I have found in the following location.)
./lib/python2.5/site-packages/MoinMoin/web/static/htdocs

change directory to your public folder.
create a symbolic link of htdocs in your public folder.

ln -s $HOME/lib/python2.5/site-packages/MoinMoin/web/static/htdocs .
mv htdocs moin_static193  //change the softlink name. This is important

You can always use your custom directory names, but in that case you have to edit the configuration file. This example is written for a simple installation of MoinMoin.

Using a browser open:
http://yourdomain.com/wiki.cgi

If you can see the wiki, you have successfully setup the MoinMoin.
Now, start customizing it by editing the config files.

To avoid the *.cgi you may add the following lines in your .htaccess file

ReWriteEngine on
ReWriteRule ^wiki$ wiki/
ReWriteRule ^wiki(/.*) wiki.cgi$1
RequestHeader set X-Moin-Location /wiki

Now use it as:
http://yourdomain.com/wiki/

10. Optional mail configuration:

emacs $HOME/moin/config/wikiconfig.py

# Mail ————————————————————–

    mail_smarthost = “mail.yourdomain.com”
    mail_from = u”Your Wiki <noreplay@yourdomain.com>”
    mail_login = “auth-email@yourdomain.com email-pass”

optionally you may add noreplay@yourdomain.com as “Garbage Email” from dreamhost panel. It will delete mail without bounce.

src:
http://wiki.dreamhost.com/MoinMoin
http://mitch.contlafamily.com/wiki/HOWTO/Install_MoinMoin_On_Dreamhost

bookmark_borderGet system load using Python Script

I have written a simple python script that collect system load information and store in a XML file.

#!/usr/bin/env python

import os
import commands
import time
from time import gmtime, strftime

while 0 < 10:
 
 file_name = strftime("%Y_%m_%d_%H_%M", gmtime()) 

 data =  commands.getoutput("w | grep load")
 xml_data = ""+ data + ""
 
 print xml_data
 
 
 if os.path.isfile(file_name + ".xml"):
  x=0
 else:

  f_prev=open(file_name + ".xml", 'a')
  f_prev.write("")
  f_prev.close

  f=open(file_name + ".xml", 'w')
  f.write("nn")
  f.close()

 
 f=open(file_name + ".xml", 'a')

 f.write(xml_data+"n")

 f.close()
 time.sleep(3)

We will get XML file like this.

<?xml version=’1.0′ encoding=’utf-8′?>
<data>
<load> 01:40:38 up 6:27, 3 users, load average: 0.07, 0.07, 0.03</load>
<load> 01:40:48 up 6:27, 3 users, load average: 0.06, 0.07, 0.03</load>
<load> 01:40:58 up 6:27, 3 users, load average: 0.05, 0.07, 0.03</load>
</data>