1. Goeie Jongens
  2. django-environments

Commits

Vincent Hillenbrink  committed ad1c995

Fixed issue with the export of the new removeorphanpyc (process subsitution not available in POSIX mode), renamed djbrowse to djvirtualbrowse and added new djbrowse command

  • Participants
  • Parent commits dfa1461
  • Branches default

Comments (0)

Files changed (1)

File bin/djenvlib

View file
 # PROJECT_ROOT is the path to the root of the entire project, i.e.
 # the directory containing the one or more 'Django projects'.
 #
-# PROJECT_ROOT=/Users/joe/projects/myproject
+# PROJECT_ROOT=/Users/spanky/projects/myproject
 
 # Not to be called directly, see djenv below
 function _djenv_init() {
     removeorphanpycs
 }
 
-# Remove .pyc files without a corresponding .py
+# Remove .pyc files without a corresponding .py the fast way
 function removeorphanpycs() {
     [ -z "$PROJECT_ROOT" ] && echo "No \$PROJECT_ROOT" 1>&2 && return 1;
-    diff --old-line-format= --new-line-format=%l --unchanged-group-format= \
+    # Pipe through bash because this implementation uses process substitution,
+    # and you don't want to export functions using that since /bin/sh will choke
+    # on them with a syntax error because process substitution is not available in
+    # POSIX mode
+    echo "diff --old-line-format= --new-line-format=%l --unchanged-group-format= \
         <(find -H $PROJECT_ROOT -name \*.py | sort) \
         <(find -H $PROJECT_ROOT -name \*.pyc | sed 's/c$//' | sort) | \
-        sed 's/$/c/' | xargs rm -v
+        sed 's/$/c/' | xargs rm -v" | bash
 }
 
 # Change directory to Django project
     open $1
 }
 
-# Points the browser to the named virtual host for the current
-# settings. Assumes Apache is running as reverse proxy; see
-# create_apache_vhoste_conf.sh for more information.
+# Points the browser to server running the current settings:
+# http://localhost:<settings.LOCAL_SERVER_PORT>/$1
 function djbrowse() {
     [ -z "$PROJECT_ROOT" ] && echo "No \$PROJECT_ROOT" 1>&2 && return 1
     [ -z "$DJANGO_PROJECT" ] && echo "No \$DJANGO_PROJECT" 1>&2 && return 1
 
-    domain=local
+    local port=`get_django_setting LOCAL_SERVER_PORT 8000`
+    open_url http://localhost:$port/$1
+}
+
+# Points the browser to the named virtual host for the current
+# settings. Assumes Apache is running as reverse proxy; see
+# create_apache_vhoste_conf.sh for more information.
+function djvirtualbrowse() {
+    [ -z "$PROJECT_ROOT" ] && echo "No \$PROJECT_ROOT" 1>&2 && return 1
+    [ -z "$DJANGO_PROJECT" ] && echo "No \$DJANGO_PROJECT" 1>&2 && return 1
+
+    local domain=local
     [ ! -z "$DOMAIN" ] && domain=$DOMAIN
-    local port=`get_django_setting LOCAL_SERVER_PORT 8000`
     local django_settings_id=`echo $DJANGO_SETTINGS_MODULE | sed "s#.*\\.##"`
 
-    open_url http://$django_settings_id.$DJANGO_PROJECT.$domain:$port/$1
+    open_url http://$django_settings_id.$DJANGO_PROJECT.$domain/$1
 }
 
 # Export functions that are not solely intended for interactive use