瀏覽代碼

Make twitter post optional

tags/v1.0
Nico Rey 4 年之前
父節點
當前提交
f5ce63493f
共有 5 個文件被更改,包括 38 次插入16 次删除
  1. +13
    -1
      install.sh
  2. +5
    -4
      post.py
  3. +9
    -7
      receive.sh
  4. +7
    -4
      receive_meteor.sh
  5. +4
    -0
      templates/tweepy.conf

+ 13
- 1
install.sh 查看文件

@@ -116,6 +116,13 @@ else
log_done "$HOME/.wxtoimgrc installed"
fi

if [ -e "$HOME/.tweepy.conf" ]; then
log_done "$HOME/.tweepy.conf already exists"
else
cp "templates/tweepy.conf" "$HOME/.tweepy.conf"
log_done "$HOME/.tweepy.conf installed"
fi

### Install meteor_demod
if [ -e /usr/bin/meteor_demod ]; then
log_done "meteor_demod was already installed"
@@ -179,7 +186,7 @@ sudo mount -a
set -e
sudo chmod 777 /var/ramfs

success "Install (almost) done! Let's do some configuration"
success "Install (almost) done!"
echo "
It's time to configure your ground station
You'll be asked for your latitude and longitude
@@ -199,3 +206,8 @@ sed -i -e "s/change_latitude/${lat}/g;s/change_longitude/${lon}/g" "sun.py"


success "Install done! Double check your $HOME/.noaa.conf settings"

echo "
If you want to post your images to Twitter, please setup
your Twitter credentials on $HOME/.tweepy.conf
"

+ 5
- 4
post.py 查看文件

@@ -1,12 +1,13 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import os
import sys
import tweepy

CONSUMER_KEY = ''
CONSUMER_SECRET = ''
ACCESS_TOKEN_KEY = ''
ACCESS_TOKEN_SECRET = ''
CONSUMER_KEY = os.environ['CONSUMER_KEY']
CONSUMER_SECRET = os.environ['CONSUMER_SECRET']
ACCESS_TOKEN_KEY = os.environ['ACCESS_TOKEN_KEY']
ACCESS_TOKEN_SECRET = os.environ['ACCESS_TOKEN_SECRET']

auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
auth.set_access_token(ACCESS_TOKEN_KEY, ACCESS_TOKEN_SECRET)


+ 9
- 7
receive.sh 查看文件

@@ -2,8 +2,9 @@


## import common lib
. ~/.noaa.conf
. "${NOAA_HOME}"/common.sh
. "$HOME/.noaa.conf"
. "$HOME/.tweepy.conf"
. "$NOAA_HOME/common.sh"


## pass start timestamp and sun elevation
@@ -41,11 +42,12 @@ for i in $ENHANCEMENTS; do
/usr/local/bin/wxtoimg -o -m "${NOAA_HOME}/map/${3}-map.png" -e "$i" "${NOAA_AUDIO}/audio/${3}.wav" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.jpg"
/usr/bin/convert -quality 90 -format jpg "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.jpg" -undercolor black -fill yellow -pointsize 18 -annotate +20+20 "${1} $i ${START_DATE}" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-$i.jpg"
done

if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MSA-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVC-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVCT-precip.jpg"
else
python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR.jpg"
if [ -n "$CONSUMER_KEY" ]; then
if [ "${SUN_ELEV}" -gt "${SUN_MIN_ELEV}" ]; then
python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MSA-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVC-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-HVCT-precip.jpg"
else
python3 "${NOAA_HOME}/post.py" "$1 ${START_DATE}" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR-precip.jpg" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/$3-MCIR.jpg"
fi
fi

rm "${NOAA_AUDIO}/audio/${3}.wav"

+ 7
- 4
receive_meteor.sh 查看文件

@@ -1,8 +1,9 @@
#!/bin/bash

## import common lib
. ~/.noaa.conf
. "${NOAA_HOME}"/common.sh
. "$HOME/.noaa.conf"
. "$HOME/.tweepy.conf"
. "$NOAA_HOME/common.sh"

## pass start timestamp and sun elevation
PASS_START=$(expr "$5" + 90)
@@ -53,8 +54,10 @@ if [ -f "${METEOR_OUTPUT}/${3}.dec" ]; then
python3 "${NOAA_HOME}/rectify.py" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122.jpg"
rm "${METEOR_OUTPUT}/${3}-122.bmp"
rm "${METEOR_OUTPUT}/${3}.bmp"
log "Posting to Twitter" "INFO"
python3 "${NOAA_HOME}/post.py" "$1 EXPERIMENTAL ${START_DATE} Resolución completa: http://weather.reyni.co/image/${FOLDER_DATE}/${3}-122-rectified.jpg" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg"
if [ -n "$CONSUMER_KEY" ]; then
log "Posting to Twitter" "INFO"
python3 "${NOAA_HOME}/post.py" "$1 EXPERIMENTAL ${START_DATE} Resolución completa: http://weather.reyni.co/image/${FOLDER_DATE}/${3}-122-rectified.jpg" "$7" "${NOAA_OUTPUT}/image/${FOLDER_DATE}/${3}-122-rectified.jpg"
fi
else
log "Decoding failed, either a bad pass/low SNR or a software problem" "ERROR"
fi

+ 4
- 0
templates/tweepy.conf 查看文件

@@ -0,0 +1,4 @@
export CONSUMER_KEY=""
export CONSUMER_SECRET=""
export ACCESS_TOKEN_KEY=""
export ACCESS_TOKEN_SECRET=""

Loading…
取消
儲存