Commits

Ryan Wilcox committed 8667606

* added optional key in setup declaration: optional=true allows user to skip step in project and app setups
* changed declarations to support this
* new TODO item: install_python_module() function

  • Participants
  • Parent commits 891aecf

Comments (0)

Files changed (4)

             "django-annoying",
             "django-flash",
             "django-pagination",
-            "South"
+            "South",
+            "pip"
             ],
         paver_command_line="init",
         no_site_packages=True
     """Run the PROJECT setup steps declared, or use the second parameter to specify exactly which one """
     projectname = options["args"][0]
     # TODO: implement logic telling us which one to run
-    for info, our_callable in setups.project_setup_task_list:
-        our_callable( BASE_PATH, os.path.join(BASE_PATH, projectname) )
+    for info, our_callable, options in setups.project_setup_task_list:
+        call_it = True
+        if options.get("optional", False):
+            answer = raw_input(info + "? [yes]/no: ")
+            if (answer == "no"):
+                call_it = False
+        
+        if call_it:
+            print "DJANGO_BOOTSTRAP: RUNNING: " + info
+            our_callable( BASE_PATH, os.path.join(BASE_PATH, projectname) )
+        else:
+            print "DJANGO_BOOTSTRAP: SKIPPED: " + info
 
 @task
 @consume_args
     """Run the APPLICATION setup declared, or use the second parameter to specify exactly which one"""
     projectname = options["args"][0]
     appname = options["args"][1]
-    for info, our_callable in setups.app_setup_task_list:
-        our_callable( BASE_PATH, os.path.join(BASE_PATH, projectname, appname) )
+    for info, our_callable, options in setups.app_setup_task_list:
+        call_it = True
+        if options.get("optional", False):
+            answer = raw_input(info + " [yes] no: ")
+            if (answer == "") or (answer == "yes"):
+                call_it = True
+        
+        if call_it:
+            our_callable( BASE_PATH, os.path.join(BASE_PATH, projectname, appname) )
 
 @task
 def update_paver_with_git_support():
 
 def filecopy(src, dest):
     subprocess.call( ["/bin/cp", src, dest])
+
+def install_python_module(module_name):
+    """Install a Python module. This function should respect virtualenvs,
+        and install the specified packagein the currently active virtualenv"""
+    # TODO: implement me!
+    pass

setups/__init__.py

 from setups.project.django_html5 import setup_django_html5
 from setups.project.project_level_templates_folder import do_project_level_template_folder
 from setups.project.add_django_utils import add_project_level_django_utils
+from setups.project.add_hoptoad import add_django_hoptoad
 
-project_setup_task_list = [("setup project relative template paths", do_sane_template_path),
-        ("user database setup switch", do_user_setup_switch),
+project_setup_task_list = [( "setup project relative template paths", do_sane_template_path, dict(optional=False) ),
+        ( "user database setup switch", do_user_setup_switch, dict(optional=False) ),
         #("pull in html5 for django and set it up", setup_django_html5),
-        ("setup folder for project wide templates", do_project_level_template_folder),
-        ("add personal django utils", add_project_level_django_utils)
+        ( "setup folder for project wide templates", do_project_level_template_folder, dict(optional=False) ),
+        ( "add personal django utils", add_project_level_django_utils, dict(optional=False) ),
+        ( "Hoptoad for error reporting", add_django_hoptoad, dict(optional=True) )
 ]
 
 #from setups.app.

setups/project/django_html5.py

 import os
-from paver import git
-# might as well use things from paver here, because we're meant to be run inside
-# a paver task...
 
 def setup_django_html5(base_path, project_path):
+    from paver import git
+    # might as well use things from paver here, because we're meant to be run inside
+    # a paver task...
+    
+    # and we have to do this in the body of this function so it doesn't get
+    # evaluated until later. WD-rpw 12-23-2010
+    
     clone_to = os.path.join(base_path, "supporting", "django-html5boilerplate")
     git.clone("git://github.com/HowlingEverett/django-html5boilerplate.git", clone_to)