@@ -0,0 +1,1389 @@
+#!/usr/bin/env python%0A%0Aimport rethinkdb as r%0Afrom optparse import OptionParser%0Aimport sys%0A%0A%0Aclass Access(object):%0A    def __init__(self, user_id, project_id, project_name):%0A        self.user_id = user_id%0A        self.project_id = project_id%0A        self.project_name = project_name%0A        self.dataset = %22%22%0A        self.permissions = %22%22%0A        self.status = %22%22%0A        self.birthtime = r.now()%0A        self.mtime = self.birthtime%0A%0A%0Aif __name__ == '__main__':%0A%0A    parser = OptionParser()%0A    parser.add_option(%22-P%22, %22--port%22, dest=%22port%22, type=%22int%22,%0A                      help=%22rethinkdb port%22, default=30815)%0A    parser.add_option(%22-u%22, %22--user%22, dest=%22user%22,%0A                      help=%22user id%22, type=%22string%22)%0A    parser.add_option(%22-p%22, %22--project%22, dest=%22project%22, help=%22project id%22, type=%22string%22)%0A    (options, args) = parser.parse_args()%0A%0A    conn = r.connect('localhost', options.port, db='materialscommons')%0A    if options.user is None:%0A        print %22You must specify a user id%22%0A        sys.exit(1)%0A%0A    if options.project is None:%0A        print %22You must specify a project%22%0A        sys.exit(1)%0A%0A    proj = r.table('projects').get(options.project).run(conn)%0A    if proj is None:%0A        print %22No such project%22%0A        sys.exit(1)%0A%0A    a = Access(options.user, options.project, proj.name)%0A    r.table('access').insert(a.__dict__).run(conn)%0A    print %22User added to project%22%0A

Add script to add a user to a project