#!/usr/bin/env python import struct import smbus import sys import time
defreadVoltage(bus):
"This function returns as float the voltage from the Raspi UPS Hat via the provided SMBus object" address = 0x36 read = bus.read_word_data(address, 2) swapped = struct.unpack("<H", struct.pack(">H", read))[0] voltage = swapped * 1.25 /1000/16 return voltage
defreadCapacity(bus): "This function returns as a float the remaining capacity of the battery connected to the Raspi UPS Hat via the provided SMBus object" address = 0x36 read = bus.read_word_data(address, 4) swapped = struct.unpack("<H", struct.pack(">H", read))[0] capacity = swapped/256 return capacity
用户打开富文本编辑器,这可能是新建的或是对已有的内容进行编辑,我们可以初始化一个数组let uploads = [],如果是编辑操作,我们先通过querySelectorAll('[src]')得到文件相应的 dom 数组,后面进行遍历,将每一项的src值push到uploads数组里,这样我们就得到了以前上传并使用中的文件列表;在后续的上传操作中,每次上传我们都会将文件地址push到uploads数组里;当用户进行提交操作时,我们可以遍历出内容中所有的file并push到 let files = []数组中。
MongoDB shell version: 2.4.14 connecting to: test Wed Jul 17 22:40:55.765 Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:145 exception: connect failed
sudo service mongodb stop sudo chown -R mongodb:mongodb /var/lib/mongodb sudo service mongodb start
修改目录权限后再次执行 mongo 命令,显示连接成功
MongoDB shell version: 2.4.14 connecting to: test Welcome to the MongoDB shell. For interactive help, type "help". For more comprehensive documentation, see http://docs.mongodb.org/ Questions? Try the support group http://groups.google.com/group/mongodb-user Server has startup warnings: Wed Jul 17 22:50:05.612 [initandlisten] Wed Jul 17 22:50:05.612 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary. Wed Jul 17 22:50:05.612 [initandlisten] ** 32 bit builds are limited to less than 2GB of data (or less with --journal). Wed Jul 17 22:50:05.612 [initandlisten] ** See http://dochub.mongodb.org/core/32bit Wed Jul 17 22:50:05.612 [initandlisten] >