2017年4月19日 星期三

2017年3月21日 星期二

ThingSpeak created_at to Python datetime

created_at is ISO 8601 format.


import dateutil.parser
yourdate = dateutil.parser.parse(datestring)




import datetime
datetime.datetime.strptime( "2007-03-04T21:08:12Z", "%Y-%m-%dT%H:%M:%SZ" )





References :
How do I translate a ISO 8601 datetime string into a Python datetime object? - Stack Overflow
pythingspeak/thingspeak.py at master · ninjawil/pythingspeak

2017年3月16日 星期四

InfluxDB enable Web UI

# vi influxdb/etc/config.sample.toml
[admin]
    enabled = true

Use environment variable:
INFLUXDB_ADMIN_ENABLED=true

$ vi docker-compose.yml
influxdb:
  image: influxdb:latest
  container_name: influxdb
  ports:
    - "8083:8083"
    - "8086:8086"
  environment:
    - INFLUXDB_ADMIN_ENABLED=true
  volumes:
    - ./influxdb:/var/lib/influxdb




References :
influxdb/config.sample.toml at master · influxdata/influxdb
docker-influxdb-grafana/docker-compose.yml at master · nicolargo/docker-influxdb-grafana

2017年1月2日 星期一

Supervisord on OpenWrt



# pip install supervisor


sample configuration file
# cp /usr/lib/python2.7/site-packages/supervisor/skel/sample.conf /etc/supervisord.conf

# vi /etc/init.d/supervisor
#!/bin/sh /etc/rc.common
#
# AUTHOR: Takumi Sueda
#
# Start/stop/restart supervisor in OpenWrt. START=91 USE_PROCD=0
PROG=/usr/bin/supervisord DAEMON=${PROG} # Location of the pid file
PIDFILE=/tmp/supervisord.pid # Config of supervisor
CONFIG=/etc/supervisord.conf start_service()
{
# $DAEMON -c $CONFIG -j $PIDFILE
procd_open_instance
procd_set_param command $PROG -c $CONFIG -j $PIDFILE
procd_set_param respawn
procd_close_instance
touch $CONFIG
} stop_service()
{
kill $(cat $PIDFILE)
}
# chmod u+x /etc/init.d/supervisor
# /etc/init.d/supervisor start

開機自動啓動
# cd /etc/rc.d
# ln -s ../init.d/supervisor S99supervisor

fatal error: libxml/xmlversion.h: No such file or directory

# apt-get install libxml2-dev libxslt1-dev