Skip to contentSkip to conversation

toaster: bin/toaster Add help text for unrecognised command

PATCH In review Michael Wood 2 participants 6 messages Apr 20, 2016 – Apr 21, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 toaster: bin/toaster Add help text for unrecognised command

Add help text for unrecognised or missing command for toaster script Remove assumption that no command is 'start' as the default.

---
 bitbake/bin/toaster | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
bitbake/bin/toaster +15 -9
index 70c66d2..2d07255 100755
@@ -17,10 +17,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see http://www.gnu.org/licenses/.
 
-# Usage: source toaster [start|stop]
-#                       [webport=<port>] [noui] [noweb]
-
-# Helper function to kill a background toaster development server
+HELP="
+Usage: source toaster start|stop [webport=<address:port>] [noweb]
+    Optional arguments:
+        [noweb] Setup the environment for building with toaster but don't start the development server
+        [webport] Set the development server (default: localhost:8000)
+"
 
 webserverKillAll()
 {
@@ -193,6 +195,12 @@ for param in $*; do
     ;;
     webport=*)
             WEB_PORT="${param#*=}"
+    ;;
+    *)
+            echo "$HELP"
+            return 1
+    ;;
+
     esac
 done
 
@@ -226,11 +234,9 @@ if [ "$CMD" = "start" ] ; then
 	return 1
 fi
 elif [ "$CMD" = "" ]; then
-    if [ -z "$BBSERVER" ]; then
-        CMD="start"
-    else
-        CMD="stop"
-    fi
+    echo "No command specified"
+    echo "$HELP"
+    return 1
 fi
 
 echo "The system will $CMD."
Signature · 1 line
2.1.4
#1 lore raw

PATCH 2/3 toaster: bin/toaster Add ability to specify port and address to bind to

Allow binding to a specified address and port to start the django development server on.
Remove the assumption that you want to bind to 0.0.0.0 and set the default to localhost.
Add some additional help text after Toaster webserver has started

---
 bitbake/bin/toaster | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
bitbake/bin/toaster +13 -5
index 2d07255..d48a773 100755
@@ -69,7 +69,7 @@ webserverStartAll()
 
     echo "Starting webserver..."
 
-    $MANAGE runserver "0.0.0.0:$WEB_PORT" \
+    $MANAGE runserver "$ADDR_PORT" \
            </dev/null >>${BUILDDIR}/toaster_web.log 2>&1 \
            & echo $! >${BUILDDIR}/.toastermain.pid
 
@@ -79,7 +79,8 @@ webserverStartAll()
         retval=1
         rm "${BUILDDIR}/.toastermain.pid"
     else
-        echo "Webserver address:  http://0.0.0.0:$WEB_PORT/"
+        echo "Toaster development webserver started at http://$ADDR_PORT"
+        echo -e "\nYou can now run 'bitbake <target>' on the command line and monitor your build in Toaster, you can also use a Toaster project to configure and run a build.\n"
     fi
 
     return $retval
@@ -180,7 +181,7 @@ fi
 export TOASTER_DIR=`pwd`
 
 WEBSERVER=1
-WEB_PORT="8000"
+ADDR_PORT="localhost:8000"
 unset CMD
 for param in $*; do
     case $param in
@@ -194,7 +195,14 @@ for param in $*; do
             CMD=$param
     ;;
     webport=*)
-            WEB_PORT="${param#*=}"
+            ADDR_PORT="${param#*=}"
+            # Split the addr:port string
+            ADDR=`echo $ADDR_PORT | cut -f 1 -d ':'`
+            PORT=`echo $ADDR_PORT | cut -f 2 -d ':'`
+            # If only a port has been speified then set address to localhost.
+            if [ $ADDR = $PORT ] ; then
+                ADDR_PORT="localhost:$PORT"
+            fi
     ;;
     *)
             echo "$HELP"
@@ -247,7 +255,7 @@ case $CMD in
     start )
         # check if addr:port is not in use
         if [ "$CMD" == 'start' ]; then
-             $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1
+             $MANAGE checksocket "$ADDR_PORT" || return 1
         fi
 
         # kill Toaster web server if it's alive
Signature · 1 line
2.1.4
#2 lore raw

Re: [PATCH 2/3] toaster: bin/toaster Add ability to specify port and address to bind to

Added to toaster-next and submitted to bitbake-devel.

Elliot

Quoted 80 lines · Michael Wood

Allow binding to a specified address and port to start the django development server on.
Remove the assumption that you want to bind to 0.0.0.0 and set the default to localhost.
Add some additional help text after Toaster webserver has started

---
 bitbake/bin/toaster | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)
bitbake/bin/toaster +3 -2
index 2d07255..d48a773 100755
@@ -69,7 +69,7 @@ webserverStartAll()
 
     echo "Starting webserver..."
 
-    $MANAGE runserver "0.0.0.0:$WEB_PORT" \
+    $MANAGE runserver "$ADDR_PORT" \
            </dev/null >>${BUILDDIR}/toaster_web.log 2>&1 \
            & echo $! >${BUILDDIR}/.toastermain.pid
 
@@ -79,7 +79,8 @@ webserverStartAll()
         retval=1
         rm "${BUILDDIR}/.toastermain.pid"
     else
-        echo "Webserver address:  http://0.0.0.0:$WEB_PORT/"
+        echo "Toaster development webserver started at http://$ADDR_PORT"
+        echo -e "\nYou can now run 'bitbake <target>' on the command line

and monitor your build in Toaster, you can also use a Toaster project to configure and run a build.\n"
fi

return $retval

bitbake/bin/toaster +6 -2
@@ -180,7 +181,7 @@ fi
 export TOASTER_DIR=`pwd`
 
 WEBSERVER=1
-WEB_PORT="8000"
+ADDR_PORT="localhost:8000"
 unset CMD
 for param in $*; do
     case $param in
@@ -194,7 +195,14 @@ for param in $*; do
             CMD=$param
     ;;
     webport=*)
-            WEB_PORT="${param#*=}"
+            ADDR_PORT="${param#*=}"
+            # Split the addr:port string
+            ADDR=`echo $ADDR_PORT | cut -f 1 -d ':'`
+            PORT=`echo $ADDR_PORT | cut -f 2 -d ':'`
+            # If only a port has been speified then set address to

localhost.

bitbake/bin/toaster +4 -2
+            if [ $ADDR = $PORT ] ; then
+                ADDR_PORT="localhost:$PORT"
+            fi
     ;;
     *)
             echo "$HELP"
@@ -247,7 +255,7 @@ case $CMD in
     start )
         # check if addr:port is not in use
         if [ "$CMD" == 'start' ]; then
-             $MANAGE checksocket "0.0.0.0:$WEB_PORT" || return 1
+             $MANAGE checksocket "$ADDR_PORT" || return 1
         fi
 
         # kill Toaster web server if it's alive
--

2.1.4

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#3 lore raw

PATCH 3/3 toaster: bin/toaster Fix noweb command

In reply to Michael Wood

For the noweb command we don't need to check if a socket is in use or not as we're not starting the django development server. We're just setting up the environment and running the runbuilds scheduler.

---
 bitbake/bin/toaster | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
bitbake/bin/toaster +3 -1
index d48a773..8906db4 100755
@@ -255,7 +255,9 @@ case $CMD in
     start )
         # check if addr:port is not in use
         if [ "$CMD" == 'start' ]; then
-             $MANAGE checksocket "$ADDR_PORT" || return 1
+            if [ $WEBSERVER -gt 0 ]; then
+                $MANAGE checksocket "$ADDR_PORT" || return 1
+            fi
         fi
 
         # kill Toaster web server if it's alive
Signature · 1 line
2.1.4
#4 lore raw

Re: [PATCH 3/3] toaster: bin/toaster Fix noweb command

Added to toaster-next and submitted to bitbake-devel.

Elliot

Quoted 33 lines · Michael Wood

For the noweb command we don't need to check if a socket is in use or not as we're not starting the django development server. We're just setting up the environment and running the runbuilds scheduler.

---
 bitbake/bin/toaster | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
bitbake/bin/toaster +3 -2
index d48a773..8906db4 100755
@@ -255,7 +255,9 @@ case $CMD in
     start )
         # check if addr:port is not in use
         if [ "$CMD" == 'start' ]; then
-             $MANAGE checksocket "$ADDR_PORT" || return 1
+            if [ $WEBSERVER -gt 0 ]; then
+                $MANAGE checksocket "$ADDR_PORT" || return 1
+            fi
         fi
 
         # kill Toaster web server if it's alive
--

2.1.4

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre
#5 lore raw
In reply to Michael Wood

Added to toaster-next and submitted to bitbake-devel.

Elliot

Quoted 67 lines · Michael Wood

Add help text for unrecognised or missing command for toaster script Remove assumption that no command is 'start' as the default.

---
 bitbake/bin/toaster | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
bitbake/bin/toaster +4 -4
index 70c66d2..2d07255 100755
@@ -17,10 +17,12 @@
 # You should have received a copy of the GNU General Public License
 # along with this program. If not, see http://www.gnu.org/licenses/.
 
-# Usage: source toaster [start|stop]
-#                       [webport=<port>] [noui] [noweb]
-
-# Helper function to kill a background toaster development server
+HELP="
+Usage: source toaster start|stop [webport=<address:port>] [noweb]
+    Optional arguments:
+        [noweb] Setup the environment for building with toaster but don't

start the development server

bitbake/bin/toaster +11 -6
+        [webport] Set the development server (default: localhost:8000)
+"
 
 webserverKillAll()
 {
@@ -193,6 +195,12 @@ for param in $*; do
     ;;
     webport=*)
             WEB_PORT="${param#*=}"
+    ;;
+    *)
+            echo "$HELP"
+            return 1
+    ;;
+
     esac
 done
 
@@ -226,11 +234,9 @@ if [ "$CMD" = "start" ] ; then
        return 1
 fi
 elif [ "$CMD" = "" ]; then
-    if [ -z "$BBSERVER" ]; then
-        CMD="start"
-    else
-        CMD="stop"
-    fi
+    echo "No command specified"
+    echo "$HELP"
+    return 1
 fi
 
 echo "The system will $CMD."
--

2.1.4

--
_______________________________________________
toaster mailing list
[email protected]
https://lists.yoctoproject.org/listinfo/toaster

Signature · 3 lines
Elliot Smith
Software Engineer
Intel Open Source Technology Centre