Re: Create a repository via API? Alternatives?
Still can't get this to work: # load_rb_env.py import os, sys import reviewboard directory from site-packages # Append the main RB python directory. sys.path.append(reviewboard.__path__[0]) # Append the RB site directory. sys.path.append(/srv/reviews/test/conf) # Import the RB environment. os.environ['DJANGO_SETTINGS_MODULE'] = 'reviewboard.settings' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User python load_rb_env.py Traceback (most recent call last): File load_rb_env.py, line 14, in module project_directory = setup_environ(settings_local) File /usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/ core/management/__init__.py, line 343, in setup_environ project_module = import_module(project_name) File /usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/ utils/importlib.py, line 35, in import_module __import__(name) ImportError: No module named conf On Feb 26, 2:13 pm, Christian Hammond chip...@chipx86.com wrote: The settings module should just be 'reviewboard.settings'. The 'settings_local' is imported from that. That could be the problem you were hitting. I would advise going this route. Down the road, I'd like to have better support for users to write Django management commands that live in the site directory. So, you'd be able to write a script that is pre-bootstrapped and had full access to the database. Christian -- Christian Hammond - chip...@chipx86.com Review Board -http://www.reviewboard.org VMware, Inc. -http://www.vmware.com On Wed, Feb 24, 2010 at 8:52 AM, Stodge sto...@gmail.com wrote: For now I'm just directly modifying the DB, though that's kind of naughty! On Feb 24, 10:18 am, Stodge sto...@gmail.com wrote: Is there a way to create a repository in review board using the API? I can't see anything in the API docs. This is for a script I maintain that administers our development server - it automates creating Trac projects and now RB sites. Also I thought I could import the review board environment and access RB classes directly but I can't get that working. It's a trick I use in a Mercurial hook for Django: sys.path.append(/srv/reviews/support/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User But I get: ImportError: No module named conf Any suggestions? I also need to promote a user to admin/staff status from within a script or via the API. Thanks -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know athttp://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.comreviewboard%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en
Re: Create a repository via API? Alternatives?
Go figure; this seems to work: sys.path.append(/srv/reviews/test/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.contrib.auth.models import User users = User.objects.all() for user in users: print user.username On Mar 3, 1:17 pm, Stodge sto...@gmail.com wrote: Still can't get this to work: # load_rb_env.py import os, sys import reviewboard directory from site-packages # Append the main RB python directory. sys.path.append(reviewboard.__path__[0]) # Append the RB site directory. sys.path.append(/srv/reviews/test/conf) # Import the RB environment. os.environ['DJANGO_SETTINGS_MODULE'] = 'reviewboard.settings' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User python load_rb_env.py Traceback (most recent call last): File load_rb_env.py, line 14, in module project_directory = setup_environ(settings_local) File /usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/ core/management/__init__.py, line 343, in setup_environ project_module = import_module(project_name) File /usr/lib/python2.6/site-packages/Django-1.1.1-py2.6.egg/django/ utils/importlib.py, line 35, in import_module __import__(name) ImportError: No module named conf On Feb 26, 2:13 pm, Christian Hammond chip...@chipx86.com wrote: The settings module should just be 'reviewboard.settings'. The 'settings_local' is imported from that. That could be the problem you were hitting. I would advise going this route. Down the road, I'd like to have better support for users to write Django management commands that live in the site directory. So, you'd be able to write a script that is pre-bootstrapped and had full access to the database. Christian -- Christian Hammond - chip...@chipx86.com Review Board -http://www.reviewboard.org VMware, Inc. -http://www.vmware.com On Wed, Feb 24, 2010 at 8:52 AM, Stodge sto...@gmail.com wrote: For now I'm just directly modifying the DB, though that's kind of naughty! On Feb 24, 10:18 am, Stodge sto...@gmail.com wrote: Is there a way to create a repository in review board using the API? I can't see anything in the API docs. This is for a script I maintain that administers our development server - it automates creating Trac projects and now RB sites. Also I thought I could import the review board environment and access RB classes directly but I can't get that working. It's a trick I use in a Mercurial hook for Django: sys.path.append(/srv/reviews/support/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User But I get: ImportError: No module named conf Any suggestions? I also need to promote a user to admin/staff status from within a script or via the API. Thanks -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know athttp://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.comreviewboard%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en
Re: Create a repository via API? Alternatives?
The settings module should just be 'reviewboard.settings'. The 'settings_local' is imported from that. That could be the problem you were hitting. I would advise going this route. Down the road, I'd like to have better support for users to write Django management commands that live in the site directory. So, you'd be able to write a script that is pre-bootstrapped and had full access to the database. Christian -- Christian Hammond - chip...@chipx86.com Review Board - http://www.reviewboard.org VMware, Inc. - http://www.vmware.com On Wed, Feb 24, 2010 at 8:52 AM, Stodge sto...@gmail.com wrote: For now I'm just directly modifying the DB, though that's kind of naughty! On Feb 24, 10:18 am, Stodge sto...@gmail.com wrote: Is there a way to create a repository in review board using the API? I can't see anything in the API docs. This is for a script I maintain that administers our development server - it automates creating Trac projects and now RB sites. Also I thought I could import the review board environment and access RB classes directly but I can't get that working. It's a trick I use in a Mercurial hook for Django: sys.path.append(/srv/reviews/support/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User But I get: ImportError: No module named conf Any suggestions? I also need to promote a user to admin/staff status from within a script or via the API. Thanks -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.comreviewboard%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en
Re: Create a repository via API? Alternatives?
For now I'm just directly modifying the DB, though that's kind of naughty! On Feb 24, 10:18 am, Stodge sto...@gmail.com wrote: Is there a way to create a repository in review board using the API? I can't see anything in the API docs. This is for a script I maintain that administers our development server - it automates creating Trac projects and now RB sites. Also I thought I could import the review board environment and access RB classes directly but I can't get that working. It's a trick I use in a Mercurial hook for Django: sys.path.append(/srv/reviews/support/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User But I get: ImportError: No module named conf Any suggestions? I also need to promote a user to admin/staff status from within a script or via the API. Thanks -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en
Re: Create a repository via API? Alternatives?
Would you be willing to share your db scripts? I'm looking to do much the same thing for our deployment. It would be nice to have someplace to start. On 02/24/2010 11:52 AM, Stodge wrote: For now I'm just directly modifying the DB, though that's kind of naughty! On Feb 24, 10:18 am, Stodge sto...@gmail.com wrote: Is there a way to create a repository in review board using the API? I can't see anything in the API docs. This is for a script I maintain that administers our development server - it automates creating Trac projects and now RB sites. Also I thought I could import the review board environment and access RB classes directly but I can't get that working. It's a trick I use in a Mercurial hook for Django: sys.path.append(/srv/reviews/support/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User But I get: ImportError: No module named conf Any suggestions? I also need to promote a user to admin/staff status from within a script or via the API. Thanks -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en
Re: Create a repository via API? Alternatives?
The old version is available here: http://trac-hacks.org/wiki/AdminToolkitScript The new version will be uploaded there once RB support is complete. However, the scripts assume they can take over the whole Centos server so I don't know how much use they will be for you. Also the scripts were written in a rush to get us up and running so don't expect anything like the quality of RB! I'm having issues getting RB support working so take all this with a grain of salt for now! Otherwise to promote a user to admin status: db_name = auth_user # Connect directly to the DB. db_name = %s_reviews%project # Replace this with your DB name. db = pg.connect(db_name, DB_HOST, user=DB_USER, passwd=DB_PASSWD) # Promote a user in review board. q = UPDATE %s SET IS_STAFF='TRUE', IS_SUPERUSER='TRUE' WHERE USERNAME='%s' % \ (auth_user, user) print(user.promote_user (%s) - %s % (db_name, q)) try: db.query(q) except pg.ProgrammingError, e: print(str(e)) Create a repository: # Create the default SVN repository in review board. db_name = %s_reviews%project # Replace this with your DB name. db = pg.connect(db_name, DB_HOST, user=DB_USER, passwd=DB_PASSWD) print db db_name = scmtools_repository q = INSERT INTO %s (name, path, mirror_path, username, password, tool_id, bug_tracker, encoding) VALUES ('%s','%s','%s','%s','%s', %d,'%s','%s') % \ ( db_name, Repository for + project, http://localhost/repos/; + project, , ADMIN_USERNAME, ADMIN_PASSWORD, 1, http://localhost/trac/; + project + /ticket/%s, ) try: db.query(q) except pg.ProgrammingError, e: print(str(e)) On Feb 24, 1:18 pm, Stephen Gallagher step...@gallagherhome.com wrote: Would you be willing to share your db scripts? I'm looking to do much the same thing for our deployment. It would be nice to have someplace to start. On 02/24/2010 11:52 AM, Stodge wrote: For now I'm just directly modifying the DB, though that's kind of naughty! On Feb 24, 10:18 am, Stodge sto...@gmail.com wrote: Is there a way to create a repository in review board using the API? I can't see anything in the API docs. This is for a script I maintain that administers our development server - it automates creating Trac projects and now RB sites. Also I thought I could import the review board environment and access RB classes directly but I can't get that working. It's a trick I use in a Mercurial hook for Django: sys.path.append(/srv/reviews/support/conf) os.environ['DJANGO_SETTINGS_MODULE'] = 'settings_local' from django.core.management import setup_environ import settings_local project_directory = setup_environ(settings_local) from django.contrib.auth.models import User But I get: ImportError: No module named conf Any suggestions? I also need to promote a user to admin/staff status from within a script or via the API. Thanks -- Want to help the Review Board project? Donate today at http://www.reviewboard.org/donate/ Happy user? Let us know at http://www.reviewboard.org/users/ -~--~~~~--~~--~--~--- To unsubscribe from this group, send email to reviewboard+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/reviewboard?hl=en