树莓派显示天气信息RARP

在此介绍一个国外网友的树莓派项目RARP,Weather According to Raspberry Pi 顾名思义,Weather According to Raspberry Pi是一个有关天气信息的项目,该项目通过采集Raspberry Pi和Sense HAT的数据,来显示相关的天气信息,比如温度、湿度、压力等 项目地址http://coded2.herokuapp.com/weather/ 代码国内下载地址</res/warp_final.zip> 下载后解压,得到main.py和gauge2.html两个文件,其中main.py需要Python3运行,gauge2.html是最终的显示文件 安装相关软件 sudo apt-get install python3 sudo apt-get install python3-pip pip3 install flask 打开Sense HAT仿真器,在程序菜单中,打开后如下图示: 下来,运行下载的python脚本 python3 main.py 正常情况下,会提示一个端口为5000的web服务正在运行 在浏览器中浏览localhost:5000或者127.0.0.1:5000,最终的浏览如下图 三个图表分别显示温度、压力和湿度,这三者的信息均来自Sense HAT 模拟器而不是真正的Sense HAT硬件。 如果需要采集Sense HAT扩展板的数据,需要将Sense HAT附加板和Raspberry Pi相连,具体信息参考官网 https://www.raspberrypi.org/products/sense-hat/ 然后修改代码,打开main.py文件,找到如下行 from sense_emu import SenseHat 修改为 from sense_hat import SenseHat 保存后,重新运行python3 main.py,此时采集的数据就来自真实的SenseHAT硬件。

2017年5月25日 · bbq

在Citrix应用中使用本地输入法

进入到Citrix安装目录C:\Program Files (x86)\Citrix\ICA Client 启用本地输入法 wfica32.exe /localime:on 禁用本地输入法 wfica32.exe /localime:off 以上输入完后会有弹窗提示是否成功。 除了通过运行命令行程序来更改,也可以通过修改注册表来实现 HKLM配置位置 HKEY_LOCAL_MACHINE\SOFTWARE\Citrix\ICA Client\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Keyboard HKCU配置位置 HKEY_CURRENT_USER\Software\Citrix\ICA Client\Engine\Lockdown Profiles\All Regions\Lockdown\Virtual Channels\Keyboard #设置LocalIME = 1 or 0 #disable=0, enable=1,留空使用其他位置的设置 注意HKLM和HKCU必须同时修改,64位操作系统注册表键值在WOW64节点下

2017年5月16日 · bbq

理解Linux中Shell初始化文件和用户Profiles文件

Linux是一个多用户、实时共享的操作系统,意味着不止一个用户可以登录同一个系统。系统管理员通过任务管理来分配不同用户的权限,比如安装、升级、卸载应用程序,运行编译程序,文件查看、编辑等等。 Linux允许通过两种主要方式来创建用户环境:系统级(全局)和用户级(个人)。一般情况下,Linux系统都会运行基本shell程序,当用户登录成功后shell会在初始化时根据某些文件开创建环境。 Linux中的Shell初始化 当Shell被调用时,会有一些初始化/启动文件被启用,它们的主要作用是为shell本身或用户设定运行环境,包含一些函数、 变量、别名等等。 Shell可以读取以下两种初始化文件: 系统级启动文件 – 包含一些应用于户所有用户的全局配置,一般存在于**/etc目录中,如 /etc/profiles 、/etc/bashrc** 或者 /etc/bash.bashrc。 用户级启动文件 – 包含一些应用于单用户的配置文件,一般存放在各个用户目录,这些配置可以覆盖系统级全局配置,如**.profiles**、 .bash_profile、 .bashrc 和 .bash_login. Shell存在三种调用模式: 1. 交互式登录Shell 当用户成功登录系统后调用该Shell,使用**/bin/login登录,随后读取/etc/passwd**文件。 当启动交互式shell后,将读取**/etc/profile文件以及特定的用户文件~/.bash_profile** login as: pi pi@pi.raspi.in's password: The programs included with the Debian GNU/Linux system are free software; the exact distribution terms for each program are described in the individual files in /usr/share/doc/*/copyright. Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent permitted by applicable law. Last login: Tue Apr 25 10:43:53 2017 from 211.137.135.200 pi@raspi:~ $ 2. 非登录交互式Shell 当使用如**$/bin/bash** or $/bin/zsh的命令行时,将会系统非登录交互式shell。他也可以通过**/bin/su**命令来运行。 ...

2017年4月25日 · jqx

python-pip安装实例

Python-pip 是一个现代的,通用的 Python包管理工具。提供了对 Python 包的查找、下载、安装、卸载的功能。 以下为多个操作系统平台下Python-pip安装方法 通用方法 通过get-pip.py文件来安装,建议Windows用户使用,前提是你必须首先安装Python。 版本要求Python 2 >=2.7.9 或Python 3 >=3.4,可从官网下载http://www.python.org/ 然后下载get-pip.py 下载地址 https://bootstrap.pypa.io/get-pip.py 通过python get-pip.py命令来进行安装。 Linux下通过软件管理工具来安装Python-pip Fedora21 Python2 sudo yum upgrade python-setuptools sudo yum install python-pip python-wheel Python3 sudo yum install python3 python3-wheel Fedora22 Python2 sudo dnf upgrade python-setuptools sudo dnf install python-pip python-wheel Python3 sudo dnf install python3 python3-wheel CentOS/RHEL 首先得启用EPEL repository,可参考此文 EPEL 6/EPEL 7 sudo yum install python-pip EPEL 7 sudo yum install python-wheel OpenSUSE Python 2: ...

2017年4月20日 · jqx

树莓派动态IP更新器

这是一个python3的脚本,每隔10分钟监控一次IP地址,如果发生变化则会通过AutoRemote消息通知你。 关于AutoRemote的使用可参考这里 这里推荐使用ipgetter来获取外网IP,地址为https://github.com/phoemur/ipgetter 安装ipgetter sudo apt-get install python3 pip sudo pip3 install ipgetter 你可以从以下地址获取每个通知设备的AutoRemote所需google key ​ http://autoremotejoaomgcd.appspot.com/?key=[it’s the part that is here] 以下为python3脚本: import ipgetter import urllib.request import requests currentIP = ipgetter.myip() #AutoRemote function to send a notification YOUR_KEY goes here def sendAR(x): AR_key = 'YOUR_KEY' AR_url = 'http://autoremotejoaomgcd.appspot.com/sendmessage?key='+ AR_key +'&message=IP%20' message = AR_url + x response = urllib.request.urlopen(message).read() print(x) #check the internet and check if previous file is present try: requests.get('http://www.google.com') print('Internet present') IPfile = open('ipfile.txt', 'r') lastIP = IPfile.read() if lastIP == currentIP: print('No changes last IP: ' + lastIP + ' current IP: ' + currentIP) else: with open('ipfile.txt', 'w+') as f: f.write(currentIP) f.close() sendAR(currentIP) print('IP updated') #handle no file except IOError: #print(IOError) with open('ipfile.txt', 'w+') as f: IPfile = ipgetter.myip() f.write(IPfile) f.close() print('created file with current IP') sendAR(currentIP) quit() #Handle no internet except requests.ConnectionError: quit() 运行脚本后,会监视ip变化,如果发生变化则通知最新ip,如果未发生变化则不通知。 ...

2017年4月19日 · jqx