Created
April 22, 2016 15:42
-
-
Save b4ldr/d78ff0f6e064f98aaf2e41b95b46085b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import gitlab | |
| import psycopg2 | |
| from pwd import getpwnam | |
| def get_auth_token(): | |
| os.setuid(getpwnam('gitlab-psql').pw_uid) | |
| conn = psycopg2.connect( | |
| host='/var/opt/gitlab/postgresql', | |
| database='gitlabhq_production') | |
| cur = conn.cursor() | |
| cur.execute('select authentication_token from users where admin = %s limit 1', 't') | |
| key = cur.fetchone()[0] | |
| conn.close() | |
| return key | |
| g = gitlab.Gitlab('http://127.0.0.1:8181', get_auth_token(), ssl_verify=False) | |
| g.auth() | |
| g..projects.all() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment