Git Product home page Git Product logo

pyolite's Introduction

pyolite Build Status Coverage Status

Welcome to pyolite

pyolite is a Python wrapper for gitolite.

Easy and simple to use, just type pip install pyolite.

Using an intuitive API, pyolite helps you to easily create users and repos using gitolite.

pyolite was developed by the awesome engineering team at Presslabs, a Managed WordPress Hosting provider.

For more open-source projects, check Presslabs Code.

Gitolite Setup Prerequisites

Using Pyolite is very easy, but it requires some initial setup. First, your gitolite-admin repo must contain a directory called repos, and all .conf files in this directory should be included in your gitolite.conf file. For example, your gitolite-admin repo might have the following structure:

├── gitolite.conf
└── repos
    └── [ empty ]

And your gitolite.conf file might look like this:

repo gitolite-admin
    RW+     =   admin

repo testing
    RW+     =   @all

include	    "repos/*.conf"

This is required because Pyolite makes changes to files only inside the repos directory.

Repository API

First, we need to initialize a pyolite object with the path to gitolite's repository.

from pyolite import Pyolite

# initial olite object
admin_repository = '/home/absolute/path/to/gitolite/repo/'
olite = Pyolite(admin_repository=admin_repository)

After that, we can create and get a repo using create and get methods.

# create a repo
repo = olite.repos.create('my_repo')
# get a repo
repo = olite.repos.get('my_repo')
# get or create a repo
repo = olite.repos.get_or_create('second_repo')

Every repo has an users object, in order to facilitate basic operations: adding, editing and removing users from a repository.

print "Repo's users: %s" % repo.users

user = olite.users.create(name='bob', key_path="~/.ssh/third_rsa.pub")

# add a new user
repo.users.add(olite.users.get('admin'), permission='W+')
repo.users.add('bob', permission='R')

# change user's permissions
repo.users.edit(olite.users.get('admin'), permission='WR+')
repo.users.edit('bob', permission='RCW')

# remove user
repo.users.remove('admin')

Users API

You can easily manipulate users as well, using almost the same API.

from pyolite import Pyolite

# initial olite object
admin_repository = '/home/absolute/path/to/gitolite/repo/'
olite = Pyolite(admin_repository=admin_repository)

# create user object
vlad = olite.users.create(name='bob',
                          key_path='~/.ssh/second_rsa.pub')

# get user by name
vlad = olite.users.get(name='admin')

# get_or_create django style
vlad = olite.users.get_or_create('alice')

# add new key to user
vlad.keys.append('/path/to/key')
vlad.keys.append('just put the key here')

# check if user is admin or not
print vlad.is_admin

Config API

Gitolite allow users to add extra configurations

repo = olite.repos.get('my_repo')
repo.add_config(("gitolite.mirror.simple", "[email protected]:Presslabs/pyolite.git"))
repo.add_config({
    "gitolite.mirror.simple": "[email protected]:Presslabs/pyolite.git"
})

If you need any help with this module, write me [email protected]

pyolite's People

Contributors

aacaz avatar bogdanpetrea avatar calind avatar krodyrobi avatar morla10111 avatar spencatro avatar vtemian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyolite's Issues

Resolve user creation bug

When you create a user, you need to add again the key to it.

user = olite.users.create(name='bob', key_path="~/.ssh/third_rsa.pub")
user.keys.append("~/.ssh/third_rsa.pub")

Which is not fun :(

Can't create repo and users

Hi
I want to try use pyolite contral my gitolite's repos and users.and i follow the example but it's not sucess.

which path i shold drop in admin_repository ?
the gitolite_admin which i cloned from my gitolite or the repos path on the gitolite server?
i drop the first on but it tell me there is no repos dir in my gitolite repo dir.

Update docs

If we keep the current implementation, you need to create a repos directory in gitolite-admin/conf and to add to your gitolite.conf -> include "repos/*.conf"

Possibility to perform more than one action between commits

Feature request: add ability to make a few edits (for example, add a repository, then add a user to it) without performing a git commit and push for each one. This is for performance reasons, as each action convey's a significant delay currently.

Method to specify admin ssh key?

Currently, this module seems to work great when I manually use $ ssh-add before running the python script, but otherwise it just freezes. Perhaps there should be some way to specify the key file path?

Package does not install because of six version

Pyolite (v1.5.7) does not install on Arch Linux because of six, on a fresh install.
Arch Linux uses version 1.10.0, but Pyolite requires version 1.6.1.

It fails with

  Running setup.py install for spec ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-tzu08jgy/spec/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-1nuq9k4s-record/install-record.txt --single-version-externally-managed --compile:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/usr/lib/python3.6/site-packages/setuptools/__init__.py", line 10, in <module>
        from setuptools.extern.six.moves import filter, map
      File "/usr/lib/python3.6/site-packages/setuptools/extern/__init__.py", line 1, in <module>
        from pkg_resources.extern import VendorImporter
      File "/usr/lib/python3.6/site-packages/pkg_resources/__init__.py", line 49, in <module>
        from pkg_resources.extern.six.moves import urllib, map, filter
    ModuleNotFoundError: No module named 'pkg_resources.extern.six.moves'; 'pkg_resources.extern.six' is not a package

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.