Visar inlägg med etikett python. Visa alla inlägg
Visar inlägg med etikett python. Visa alla inlägg

onsdag 25 januari 2012

Gitosis

Adapted from http://blog.agdunn.net/?p=277


pacman -S git-core setuptools
useradd --home-dir=/media/STORAGE/git --create-home --system git
su -l git

git clone git://eagain.net/gitosis.git
cd ~/gitosis
patch gitosis/ssh.py <<EOF
37c37
<     TEMPLATE=('command="gitosis-serve %(user)s",no-port-forwarding,'
---
>     TEMPLATE=('command=".local/bin/gitosis-serve %(user)s",no-port-forwarding,'
EOF
patch gitosis/templates/admin/hooks/post-update <<EOF
3c3
< gitosis-run-hook post-update
---
> ~/.local/bin/gitosis-run-hook post-update
EOF
git commit -a -m 'Adapt Gitosis for being installed with python setup.py install --user' --author 'Lars Rasmusson <Lars.Rasmusson@gmail.com>'
python2.7 setup.py install --user

~/.local/bin/gitosis-init  
[ paste your public ssh key and press CTRL-D ]

chmod u+x ~/repositories/gitosis-admin.git/hooks/post-update

Now you can clone the repository gitosis-admin.git from the server using

git clone git@servername:gitosis-admin.git


To add a user with pubkey file username.pub


cp username.pub gitosis-admin/keydir/
(cd gitosis-admin; git commit keydir -m 'added user'; git push)

To give the user access to a repository, add him to a group
(or create a new group for him), and add the repository name
to the ‘writable’ list for that group in gitosis-admin/gitosis.conf



måndag 7 februari 2011

Python virtualenv

Virtualenv http://pypi.python.org/pypi/virtualenv is very useful.  It creates a new file environment into which you can install python software without screwing up your already installed system python.

To create a virtual environment, if you already have  virtualenv installed, do

  • python -m virtualenv myEnv

otherwise,
  • download virtualenv-1.5.1.tar.gz
  • unpack it: tar xfz virtualenv-*-gz
  • create the environment:  python virtualenv-1.5.1/virtualenv.py myEnv
  • once the environment (myEnv) has been created,  you can remove the virtualenv-1.5.1 directory.
Example:
curl -s http://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.5.1.tar.gz | tar zxvf -
python virtualenv-1.5.1/virtualenv.py myEnv

Now you can use myEnv/bin/python or myEnv/bin/pip to install packages

(pip can download and install python packages very neatly).


måndag 5 april 2010

Writing to pastebin via python API

The parameters are listed here: http://pastebin.com/api.php

This example's pastes only live 10 minutes. Only the paste_code parameter is required.

text="""
print "Hello World!\\n"
"""
# send text to pastebin, use syntax highlighting
from urllib import urlopen, urlencode
url="http://pastebin.com/api_public.php"
args={"paste_code": text, 
    "paste_private":1, 
    "paste_expire_date":"10M",
    "paste_format":"python"}
print urlopen(url,urlencode(args)).read()