@@ -0,0 +1,1303 @@
+#!/usr/bin/python%0A%0A# This is a small helper script to create a CATMAID user.%0A%0A# You may need to install psycopg2, e.g. with:%0A#   sudo apt-get install python-psycopg2%0A%0A# Requires the file .catmaid-db to be present in your%0A# home directory, with the following format:%0A#%0A# host: localhost%0A# database: catmaid%0A# username: catmaid_user%0A# password: password_of_your_catmaid_user%0A%0Aimport sys%0Aimport os%0Afrom common import db_connection%0Afrom subprocess import check_call%0Aimport getpass%0Afrom psycopg2 import IntegrityError%0A%0Aif len(sys.argv) != 3:%0A    print %3E%3E sys.stderr, %22Usage: create-project.py %3CUSERNAME%3E %3CLONG-NAME%3E%22%0A    sys.exit(1)%0A%0Ausername = sys.argv%5B1%5D%0Afull_name = sys.argv%5B2%5D%0A%0A# Now get a password from the user:%0Ap1 = getpass.getpass()%0Ap2 = getpass.getpass(%22Confirm passsword: %22)%0A%0Aif p1 != p2:%0A    print %3E%3E sys.stderr, %22The passwords didn't match.%22%0A    sys.exit(2)%0A%0Ac = db_connection.cursor()%0A%0Atry:%0A    c.execute('INSERT INTO %22user%22 (name, pwd, longname) VALUES (%25s, md5(%25s), %25s) RETURNING id',%0A              (username, p1, full_name))%0Aexcept IntegrityError, e:%0A    print %3E%3E sys.stderr, %22There is already a user called '%25s'%22 %25 (username,)%0A    sys.exit(3)%0A%0Auser_id = c.fetchone()%5B0%5D%0A%0Aprint %22Created the user '%25s' with ID: %25d%22 %25 (username, user_id)%0A%0Adb_connection.commit()%0Ac.close()%0Adb_connection.close()%0A

Add a script for creating a new user