OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) gzip: stdin: not in gzip format

  • This topic is empty.
Viewing 21 posts - 1 through 21 (of 21 total)
  • Author
    Posts
  • #22522

    kkpwrh2o
    Member

    Still working to get up an running…

    Decided to start all over and re-install ospi as I wasn’t sure it was running or I had the latest file.

    I get the following when I try to unpack the ospi.tar.gz file in my pi directory

    pi@raspberrypi ~ $ ls
    Desktop git indiecity ocr_pi.png opensprinkler ospi.tar.gz python_games
    pi@raspberrypi ~ $ tar -xvf ospi.tar.gz

    gzip: stdin: not in gzip format
    tar: Child returned status 1
    tar: Error is not recoverable: exiting now
    pi@raspberrypi ~ $

    All help appreciated.

    Thanks,
    Kevin

    #24752

    Samer
    Keymaster

    You need to download the RAW file from Github. Use this link for example:

    https://github.com/rayshobby/opensprinkler/blob/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz?raw=true

    *** This is becoming a re-occurring issue and needs to be addressed in the Wiki or the documentation for the interval program on your blog Ray ***

    #24753

    Andrew
    Participant

    Would the best solution until we have a deb package be to not host the tgz file in github but rather just the files?

    #24754

    kkpwrh2o
    Member

    Samer,

    Tried that (a couple of time before posting) as I found your advice on another post. Still have the same issue.

    Perhaps it is the way I am saving it. When I click the link, a dialog box comes up with save, save as, etc. I select save as, and save it to the pi directory.

    Is that the correct way to save it, or is there a better way?

    #24755

    Samer
    Keymaster

    Try:

    wget https://github.com/rayshobby/opensprinkler/blob/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz?raw=true

    Directly on your Pi

    #24756

    kkpwrh2o
    Member

    Now we are cookin….

    pi@raspberrypi ~ $ wget https://github.com/rayshobby/opensprinkler/blob/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz?raw=true
    –2013-07-11 00:07:37– https://github.com/rayshobby/opensprinkler/blob/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz?raw=true
    Resolving github.com (github.com)… 204.232.175.90
    Connecting to github.com (github.com)|204.232.175.90|:443… connected.
    HTTP request sent, awaiting response… 302 Found
    Location: https://github.com/rayshobby/opensprinkler/raw/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz [following]
    –2013-07-11 00:07:44– https://github.com/rayshobby/opensprinkler/raw/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz
    Reusing existing connection to github.com:443.
    HTTP request sent, awaiting response… 302 Found
    Location: https://raw.github.com/rayshobby/opensprinkler/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz [following]
    –2013-07-11 00:07:49– https://raw.github.com/rayshobby/opensprinkler/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz
    Resolving raw.github.com (raw.github.com)… 199.27.74.133
    Connecting to raw.github.com (raw.github.com)|199.27.74.133|:443… connected.
    HTTP request sent, awaiting response… 200 OK
    Length: 286597 (280K) [application/x-gzip]
    Saving to: `ospi.tar.gz?raw=true’

    100%[============================>] 286,597 922K/s in 0.3s

    2013-07-11 00:07:55 (922 KB/s) – `ospi.tar.gz?raw=true’ saved [286597/286597]

    pi@raspberrypi ~ $

    #24757

    Samer
    Keymaster

    Extract that now:

    tar xvzf ospi.tar.*
    #24758

    kkpwrh2o
    Member

    Next item…

    When I go to this link, http://rayshobby.net/apps/sprinklers

    (which I visited a couple of day ago and was able to enter some information and resulted in a dark blank screen with a revolving arrow graphic.)

    I am back to the dark, blank screen with revolving arrow graphic.

    Not sure where to go from here.

    #24759

    Samer
    Keymaster

    Okay, is the port forwarded for your interval program? If not, navigate to your router’s administration page/application and open the port. The port is the one used by your interval application (default: 8080). The IP is the Raspberry Pi’s IP.

    #24760

    kkpwrh2o
    Member

    i’m thinking the port is forwarded ok. I have my other port forwarded device working fine on port 81.

    I can see it on CYSM successfully using ths same IP addr as port 80 that the RPi is using. Port 80 is visible on CYSM as well.

    Is there a way to tell if ospi is running? Perhaps in Task manager?

    I made the changes to the 4 lines of code required to to so, but i can’t convince my self it is running.

    I ran this again

    hostname -I
    ps -ef | grep -i ospi

    with the following result

    pi@raspberrypi ~ $ hostname -I
    10.0.1.21
    pi@raspberrypi ~ $ ps -ef | grep -i ospi
    pi 2602 2585 0 01:18 pts/0 00:00:00 grep --color=auto -i ospi
    pi@raspberrypi ~ $

    Based on the last time we went through this, it does not look like the interval timer is running.

    #24761

    Samer
    Keymaster

    You are correct, it’s not running. I personally background mine for testing but have never needed/wanted it to start on boot but maybe a ghetto way of doing it is adding a crontab line:

    @reboot    cd ~/OSPi; nohup python ospi.py &

    I haven’t tried that but I think it should work. I might be confusing you in which case just follow Dan’s instructions which is a more reliable auto launcher.

    #24762

    kkpwrh2o
    Member

    I went to the OSPi dir and started ospi.py with the following results

    pi@raspberrypi ~/OSPi $ sudo python ospi.py
    Starting main loop

    http://0.0.0.0:8080/

    That pretty much confirms it wasn’t running (I think)

    Ran this again

    hostname -I
    ps -ef | grep -i ospi

    No result was displayed, Just a cursor on a blank line.

    #24763

    JBinkley
    Member

    If you are running it on startup, you should be seeing something like this:

    root@raspberrypi-sprinkler:~# ps -ef | grep python
    root 2303 2096 0 Jul09 ? 00:06:29 /usr/bin/python ospi.py 192.168.1.60:8080
    root 16020 16011 0 18:36 pts/1 00:00:00 grep python
    root@raspberrypi-sprinkler:~#

    In my case, I start it in /etc/rc.local, which should look something like this:

    #!/bin/sh -e
    #
    # rc.local
    #
    # This script is executed at the end of each multiuser runlevel.
    # Make sure that the script will "exit 0" on success or any other
    # value on error.
    #
    # In order to enable or disable this script just change the execution
    # bits.
    #
    # By default this script does nothing.
    echo "[$(date)] rc.local executing" >> /tmp/rc.local.debug
    sleep 30
    host=$(hostname -I | sed 's/ *$//g')
    port=:8080
    cd /home/pi/OSPi/
    echo "[$(date)] rc.local starting ospi.py $host$port" >> /tmp/rc.local.debug
    /usr/bin/python ospi.py $host$port

    exit 0

    I added the “sleep 30” because it did not always seem to start properly. After I added that, it seems to start without issue.

    I don’t think there would be any issue, by the way, if you just left out the host and port stuff and started with “/usr/bin/python ospi.py 8080”

    /joe

    #24764

    kkpwrh2o
    Member

    went back and checked this code to make sure I had it in correctly. I copied and pasted the exact text from the readme file just to make sure I had it right.

    # Print the IP address
    _IP=$(hostname -I) || true
    if [ "$_IP" ]; then
    printf "My IP address is %sn" "$_IP"
    fi
    host=$(hostname -I | sed 's/ *$//g')
    port=:80
    cd /home/pi/OSPi
    ## If you aren't sure that the path to python on your Pi is /usr/bin/, use whereis python to determine the location /usr/bin/python ospi.p$
    exit 0

    I notice “fi” just before host=$(hostname -i….. line. Is that correct? Or is It is supposed to be “if” and I fat fingered it somehow?

    #24765

    Samer
    Keymaster

    Your code is bad…it has the execution line commented out. Anyways, I would use what @JBinkley provided above. Looks like a fantastic script.

    By the way the fi is the end if in a shell script so that’s fine.

    #24766

    JBinkley
    Member

    The “fi” is ok, that’s just the close for the “if”.

    I believe it is there in the default rc.local, because sometimes “hostname -I” may fail because the network connection is not yet stable at the time the script runs and so the _IP would not exist and the printf would fail and the script would abort. Note that the “|| true” on the line before the if is there as an override in the case that “hostname -I” fails. If it were not there, the script would abort at that point.

    The next line has the potential of failing for the same reason.

    host=$(hostname -I | sed 's/ *$//g')

    That’s why I added the “sleep 30” in my script. It gives the PI 30 seconds to get the network figured out before it tries to get the IP address and start the ospi.py program.

    But, as I look at your script, I think your biggest issue is that you are missing the last line that actually starts the ospi.py program:

    /usr/bin/python ospi.py $host$port

    But, you want to make sure that is before the

    exit 0

    /joe

    #24767

    kkpwrh2o
    Member

    Thanks Joe. Thanks Samer. Much appreciated. Still no joy after loading Joe’s rc.local file.

    Out of patience for tonight. Will give it another crack in a day or so.

    Regards,
    Kevin

    #24768

    Samer
    Keymaster

    Just run this command from the Raspberry Pi:

    /usr/bin/python /home/pi/OSPi/ospi.py

    Should at least get the code up. Then you can deal with auto starting?

    Update: If it does work just add a crontab line with the following:

    @reboot    /usr/bin/python /home/pi/OSPi/ospi.py

    Update 2: Just to be clear, this method isn’t as robust as a rc.local configuration. But this should at least get you running.

    #24769

    kkpwrh2o
    Member

    Will give it a try this evening when I get home.

    Thanks for all of your help.

    Regards,
    Kevin

    #24770

    andrew
    Participant

    If anyone prefers to use init.d scripts over rc.local, you can put the following into /etc/init.d/ospi.py

    You’ll need to have start-stop-daemon installed (which, at least, comes installed on RPi and likely other systems as well).

    Be sure to change the variable $DAEMON_ARGS to your desired settings, and change $DIR to the location of ospi.py

    #! /bin/sh
    ### BEGIN INIT INFO
    # Provides: OSPi
    # Required-Start: $remote_fs $syslog
    # Required-Stop: $remote_fs $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: OSPi Interval
    # Description: Runs the OSPi Interval program as a service
    ### END INIT INFO

    # Do NOT "set -e"

    # PATH should only include /usr/* if it runs after the mountnfs.sh script
    PATH=/sbin:/usr/sbin:/bin:/usr/bin
    DESC="OSPi Interval Daemon"
    NAME=ospi.py
    DIR=/home/pi/OSPi
    DAEMON="$DIR/$NAME"
    DAEMON_ARGS="127.0.0.1:8000"
    PIDFILE=/var/run/$NAME.pid
    SCRIPTNAME=/etc/init.d/$NAME

    # Exit if the package is not installed
    [ -x "$DAEMON" ] || exit 0

    # Read configuration variable file if it is present
    [ -r /etc/default/$NAME ] && . /etc/default/$NAME

    # Load the VERBOSE setting and other rcS variables
    . /lib/init/vars.sh

    # Define LSB log_* functions.
    # Depend on lsb-base (>= 3.2-14) to ensure that this file is present
    # and status_of_proc is working.
    . /lib/lsb/init-functions

    #
    # Function that starts the daemon/service
    #
    do_start()
    {
    # Return
    # 0 if daemon has been started
    # 1 if daemon was already running
    # 2 if daemon could not be started
    start-stop-daemon --start --quiet --pidfile $PIDFILE --exec "$DAEMON" --test > /dev/null
    || return 1
    start-stop-daemon --make-pidfile --background --start --quiet --pidfile $PIDFILE -d $DIR --exec "$DAEMON" --
    $DAEMON_ARGS
    || return 2
    # Add code here, if necessary, that waits for the process to be ready
    # to handle requests from services started subsequently which depend
    # on this one. As a last resort, sleep for some time.
    sleep 2
    }

    #
    # Function that stops the daemon/service
    #
    do_stop()
    {
    # Return
    # 0 if daemon has been stopped
    # 1 if daemon was already stopped
    # 2 if daemon could not be stopped
    # other if a failure occurred
    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
    RETVAL="$?"
    [ "$RETVAL" = 2 ] && return 2
    # Wait for children to finish too if this is a daemon that forks
    # and if the daemon is only ever run from this initscript.
    # If the above conditions are not satisfied then add some other code
    # that waits for the process to drop all resources that could be
    # needed by services started subsequently. A last resort is to
    # sleep for some time.
    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec "$DAEMON"
    [ "$?" = 2 ] && return 2
    # Many daemons don't delete their pidfiles when they exit.
    rm -f $PIDFILE
    return "$RETVAL"
    }

    #
    # Function that sends a SIGHUP to the daemon/service
    #
    do_reload() {
    #
    # If the daemon can reload its configuration without
    # restarting (for example, when it is sent a SIGHUP),
    # then implement that here.
    #
    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
    return 0
    }

    case "$1" in
    start)
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
    do_start
    case "$?" in
    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
    stop)
    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
    do_stop
    case "$?" in
    0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
    2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
    esac
    ;;
    status)
    status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
    ;;
    #reload|force-reload)
    #
    # If do_reload() is not implemented then leave this commented out
    # and leave 'force-reload' as an alias for 'restart'.
    #
    #log_daemon_msg "Reloading $DESC" "$NAME"
    #do_reload
    #log_end_msg $?
    #;;
    restart|force-reload)
    #
    # If the "reload" option is implemented then remove the
    # 'force-reload' alias
    #
    log_daemon_msg "Restarting $DESC" "$NAME"
    do_stop
    case "$?" in
    0|1)
    do_start
    case "$?" in
    0) log_end_msg 0 ;;
    1) log_end_msg 1 ;; # Old process is still running
    *) log_end_msg 1 ;; # Failed to start
    esac
    ;;
    *)
    # Failed to stop
    log_end_msg 1
    ;;
    esac
    ;;
    *)
    #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
    echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
    exit 3
    ;;
    esac
    #24771

    ITDawg
    Member

    This is what I use to get updates directly to my Pi. I SSH to the Pi, then issue the following wget command so it writes it to the correct file name:

    wget -O ospi.tar.gz https://github.com/rayshobby/opensprinkler/blob/master/OpenSprinkler%20Pi/software/demos/interval_program/ospi.tar.gz?raw=true

    The “-O” (UPPERCASE, not lowercase!!!) tells wget to write the file to ospi.tar.gz file.

    I also copy my config files to a temp directory so I can just copy them back after the update:

    cp OSPi/data/* ospi.current.config/data/

    Then I unzip/untar with:

    tar -xvf ospi.tar.gz
Viewing 21 posts - 1 through 21 (of 21 total)
  • You must be logged in to reply to this topic.

OpenSprinkler Forums Hardware Questions OpenSprinkler Pi (OSPi) gzip: stdin: not in gzip format