wunderground.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:weatherlink-python 作者: beamerblvd 项目源码 文件源码
def _send_update(self, url, attribute_map, attribute_calculations, record):
        d = record.date.replace(tzinfo=self.station_time_zone).astimezone(pytz.UTC).replace(tzinfo=None)

        url = '%s&ID=%s&PASSWORD=%s&dateutc=%s' % (
            url,
            self.station_id,
            url_quote(self.password, safe=''),
            url_quote(d.strftime('%Y-%m-%d %H:%M:%S'), safe=''),
        )

        for parameter, field in attribute_map or []:
            if field and record[field] is not None:
                url += '&%s=%s' % (parameter, url_quote(record[field], safe=''), )

        for parameter, function in attribute_calculations or []:
            if function:
                value = function(self, record)
                if value is not None:
                    url += '&%s=%s' % (parameter, url_quote(value, safe=''), )

        response = self._session.get(url)

        assert 200 <= response.status_code < 300, 'Status code %s unexpected' % response.status_code

        assert response.text == 'success', 'Response "%s" unexpected' % response.text
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号