RRD是Round Robin Database的意思,RRDTool是用来管理RRD的一个工具。RRDTool的主页在这里,Wikipedia的页面在这里。RRD其实就是一个时序数据库,使用一个固定大小的环型buffer,适用于存储一些统计性的信息,如CPU负载呀,气温变化呀。我为什么要说这个东西呢,因为XenServer里的性能统计是用的RRD,你可以访问诸如http://xenserver-host/rrd_updates?cf=AVERAGE&interval=5&start=123131321形式的网址来获取统计信息。XenServer将返回一个XML文件,这个XML文件其实就是用rrdtool里的export工具导出的。 好,下载完成了这个文件以后,我们假设文件名是data.xml,你可以使用rrdtool restore data.xml data.rrd的方式将数据重新恢复成rrd的格式,然后就可以使用rrdtool进行一系列操作。rrdtool的操作可以写十篇博客,这不是我今天想说的重点。 我今天想说的是,当我把rrdtool跟Python集成的时候,发现Python提供了若干封装的工具,比如Python-PyRRD,Python-rrd,Python-rrdtool,我想没几个人能搞明白这几者之间的关系吧。我来说一下。 Python-rrdtool,这个就是rrdtool的一个Python封装,调用方式与rrdtool里命令的格式是一致的。 Python-rrd,这个据说应该是rrdtool的前 ......
谢了一个自动下载指定人的博客的脚本
这个脚本是用来下载csdn博客的
同样的方法可以下载一般其他网站的博客,如sina
有时页面访问会被拒绝,重新运行即可
这种程序是在分析了指定网站,我在这儿是csdn,之后编写出的
会牵涉到网页的编码问题,有时程序运行会因此终止
我自己的博客已经下载忘了
只是下载网页
使用网页分析后可以整理出文章,那样更实用
#
#blogdownloader_csdn.py
# @Author:onezeros@yahoo.cn ||Zhijie Lee
# I didnot realize the image_download function
# but it's not very difficult,so that you can do it by yourself
#cmd usage:blogdownloader_csdn.py blogname "full directory path"
#further extension :classify the articles to
# "原创""转载" etc.according to csdn
import os
import sys
import unicodedata
import urllib.request
#globle var
username=sys.argv[1]
#username='onezeros'
#total number of pages
total_num=0
dst_urls=[]
#use data as the file name
dst_title=[]
###########################################
#function to find urls of articals
#it's neccessory to verify wheth ......
import random def windex(lst):
'''an attempt to make a random.choose() function that makes weighted choices
accepts a list of tuples with the item and probability as a pair'''
wtotal = sum([x[1] for x in lst])
n = random.uniform(0, wtotal)
for item, weight in lst:
if n < weight:
break
n = n - weight
return item ......
python应用领域介绍
Python作为一种功能强大且通用的编程语言而广受好评,它具有非常清晰的语法特点,适用于多种操作系统,目前在国际上非常流行,正在得到越来越多的应用。
下面就让我们一起来看看它的强大功能:
Python(派森),它是一个简单的、解释型的、交互式的、可移植的、面向对象的超高级语言。这就是对Python语言的最简单的描述。
Python有一个交互式的开发环境,因为Python是解释运行,这大大节省了每次编译的时间。Python语法简单,且内置有几种高级数据结构,如字 典、列表等,使得使用起来特别简单,程序员一个下午就可学会,一般人员一周内也可掌握。Python具有大部分面向对象语言的特征,可完全进行面向对象编 程。它可以在MS-DOS、Windows、Windows NT、Linux、Soloris、Amiga、BeOS、OS/2、VMS、QNX等多种OS上运行。
编程语言
Python语言可以用来作为批处理语言,写一些简单工具,处理些数据,作为其他软件的接口调试等。Python语言可以用来作为函数语言,进行人工智能 程序的开发,具有Lisp语言的大部分功能。Python语言可以用来作为过程语言,进行我们常见的应用程序开发,可以和VB等语言一样应用。 Python语 ......
'''gen_python_api.py generates a python.api file for SciTE
The generated api file includes
*) all Python keywords
*) all builtin functions
*) all module attributes
Module functions are represented by their docstring if available,
otherwise by the function definition from the source file.
Classes are represented by their constructor if available.
Usage:
Edit the list of modules which should be excluded. This list is located
some lines below. Look for excludemodulelist = [...]
Specify the modules whose contents should be added as global names
(i.e. from parrot import *). Look for addasgloballist = [...]
Start the script by typing 'python gen_python_api.py' in the shell.
Don't start it from within SciTE on Win32 systems, because some
modules need a TTY when they are imported.
Copy the generated python.api file into your SciTE directory and
add the following lines to your SciTEUser.properties file:
api.*.py=$(SciteDefaultHome)/python.api
api.*.pyw=$(SciteDefault ......
writeblog.csdn.net writeblog.csdn.net/PostEdit.aspx
这个程序很早以前就写过了,而且是参考的别人的写,具体谁的发在哪里我都忘记了。这里就算是半原创了,如有侵权请及时通知改正。
因为从今天1月1号开始,Google上订阅的天气预报服务已经取消了,估计是Google被施加压力了。反正是收不到天气预报了。正好重拾以前的那个脚本,自己设置抓取信息并发到手机就行了。
之前的脚本是用Python写的,抓的是新浪天气预报页面的信息,使用cocobear提供的PyFetion发送到自己手机上。上周拿来一运行,报error...
原来是飞信平台升级了,PyFetion也跟着升级了,而且新浪天气预报的页面也改版了。好嘛。。。
换用ip138提取的天气信息,重新改写如下
# -*- coding:utf-8 -*-
# file:weather.py
# by Lee, 2010-1-11
"""
抓取天气预报信息,并通过pyfetion发送短信通知
"""
import os
import re
import urllib
import sys
import time
from PyFetion import *
def GetWeather():
try:
# 获取网页源文件
sock = urllib.urlopen("http://qq.ip138.com/weather/guangdong/DongGuan.htm")
strhtml = sock.read()
strhtm ......