home


Some Questions on Path in Python

1. PYTHONPATH V.S. sys.path

export PYTHONPATH=”/root/Public/egg_test”

then you will find this path will appear in the sys.path

>>> print sys.path
['',
'/usr/lib64/python2.6/site-packages/xattr-0.6.2-py2.6-linux-x86_64.egg',
'/usr/lib/python2.6/site-packages/boto-2.1.1-py2.6.egg',
'/usr/lib/python2.6/site-packages/python_gflags-1.3-py2.6.egg',
'/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg',
'/usr/lib/python2.6/site-packages/prettytable-0.5-py2.6.egg',
'/usr/lib/python2.6/site-packages/argparse-1.2.1-py2.6.egg',
'/usr/lib/python2.6/site-packages/httplib2-0.7.2-py2.6.egg',
'/usr/lib/python2.6/site-packages/euca2ools-1.2-py2.6.egg',
'/usr/lib/python2.6/site-packages/python_novaclient-2.6.6-py2.6.egg',
'/usr/lib/python2.6/site-packages/eventlet-0.9.16-py2.6.egg',
'/usr/lib/python2.6/site-packages/greenlet-0.3.2-py2.6-linux-x86_64.egg',
'/usr/lib/python2.6/site-packages/WebOb-1.2b2-py2.6.egg',
'/usr/lib/python2.6/site-packages/glance-2011.3-py2.6.egg',
'/usr/lib/python2.6/site-packages/SQLAlchemy-0.6.9dev-py2.6.egg',
'/usr/lib/python2.6/site-packages/kombu-1.5.1-py2.6.egg',
'/usr/lib/python2.6/site-packages/amqplib-1.0.2-py2.6.egg',
'/usr/lib/python2.6/site-packages/anyjson-0.3.1-py2.6.egg',
'/usr/lib/python2.6/site-packages/docutils-0.9-py2.6.egg',
'/root/Public/egg_test',
'/usr/lib64/python26.zip',
'/usr/lib64/python2.6',
'/usr/lib64/python2.6/plat-linux2',
'/usr/lib64/python2.6/lib-tk',
'/usr/lib64/python2.6/lib-old',
'/usr/lib64/python2.6/lib-dynload',
'/usr/lib64/python2.6/site-packages',
'/usr/lib64/python2.6/site-packages/gtk-2.0',
'/usr/lib/python2.6/site-packages',
'/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info']

Read the rest of this entry »


夏夜无题

我从夏夜里的公司大门走出,那是太阳落山后余温散尽的时候

因为这里是郊区的偏僻,有着上海夜里细密的湿

在车站等车超过20分钟的时候,路尽头的十字路口转来一路车

话不多说刷卡上车,拉开ipad准备看一看这一天数量破表的RSS

却发现已经路过庙门,自觉乘错了车

匆忙间下车,寻的士不得,只好步入庙门

常言道,庙门一入深似海

也道,如今还俗之日在望,却又不舍

一路冷清,路边的河水衬着楼栋与灯光的身影

我在何年何月料到会有这样的场景

但我在某年某月绝对又回想起这样的场景

致远湖的水漪漪清浪,娇柳倩影

god, 我还真喜欢交大

一时间留着脑袋里的重重俗务也涤清不少

惟愿有时,能坐在湖边的台阶上,清谈或冥思

当然,必定要是夏夜


How to import libs in two versions under Python

的确这是一个奇怪的需求

但是假设在一个project里需要调用的函数正好在一个库的两个不同版本里,因为版本change的关系,有些函数不再支持。

这样看来这种需求就是合理的。更重要的是,希望弄清楚Python的命名空间以及import寻址问题。

目前看到的一个方法是:

mkdir lib_v1

mkdir lib_v2

然后将一个module的不同版本各自扔进去,在添加path

而后使用的时候这样:

import lib_v1.module

import lib_v2.module


USB2.0 NIC on linux 2.6.22 above

To install ASIX AX88xxx Based USB 2.0 Ethernet Adapters on linux 2.6.39 RHEL6.1, first I tried to build an older kernel 2.6.26 as the ReadMe file in the driver package, but it seems the current OS is on EXT4 disk format, so 2.6.26 supports EXT4 badly, which caused the installation pause. So the NIC driver could not be maked.

Actually the linux kernel above 2.6.22 has already been added into the kernel, so just insmod the asix mode, the NIC will be available.

Detailed information comes from http://cateee.net/lkddb/web-lkddb/USB_NET_AX8817X.html

 


Story of version name

The paragraph below is quoted from http://packages.python.org/distribute/setuptools.html

A version consists of an alternating series of release numbers and pre-release or post-release tags. A release number is a series of digits punctuated by dots, such as 2.4 or 0.5. Each series of digits is treated numerically, so releases 2.1 and 2.1.0 are different ways to spell the same release number, denoting the first subrelease of release 2. But 2.10 is the tenth subrelease of release 2, and so is a different and newer release from 2.1 or 2.1.0. Leading zeros within a series of digits are also ignored, so 2.01 is the same as 2.1, and different from 2.0.1.

Following a release number, you can have either a pre-release or post-release tag. Pre-release tags make a version be considered older than the version they are appended to. So, revision 2.4 is newerthan revision 2.4c1, which in turn is newer than 2.4b1 or 2.4a1. Postrelease tags make a version be considered newer than the version they are appended to. So, revisions like 2.4-1 and 2.4pl3 are newer than 2.4, but are older than 2.4.1 (which has a higher release number).

A pre-release tag is a series of letters that are alphabetically before “final”. Some examples of prerelease tags would include alphabetaacdev, and so on. You do not have to place a dot before the prerelease tag if it’s immediately after a number, but it’s okay to do so if you prefer. Thus, 2.4c1 and 2.4.c1 both represent release candidate 1 of version 2.4, and are treated as identical by setuptools.

In addition, there are three special prerelease tags that are treated as if they were the letter cprepreview, and rc. So, version 2.4rc12.4pre1 and 2.4preview1 are all the exact same version as 2.4c1, and are treated as identical by setuptools.

A post-release tag is either a series of letters that are alphabetically greater than or equal to “final”, or a dash (-). Post-release tags are generally used to separate patch numbers, port numbers, build numbers, revision numbers, or date stamps from the release number. For example, the version 2.4-r1263 might denote Subversion revision 1263 of a post-release patch of version 2.4. Or you might use2.4-20051127 to denote a date-stamped post-release.

Notice that after each pre or post-release tag, you are free to place another release number, followed again by more pre- or post-release tags. For example, 0.6a9.dev-r41475 could denote Subversion revision 41475 of the in- development version of the ninth alpha of release 0.6. Notice that dev is a pre-release tag, so this version is a lower version number than 0.6a9, which would be the actual ninth alpha of release 0.6. But the -r41475 is a post-release tag, so this version is newer than 0.6a9.dev.

 


Understand LVM

[Terminology]

Physical Volume:

the partition of physical disk, like /dev/sda1, /dev/hd2. But PV contains the information of LVM, such asVolume Group the PV belongs to.

Volume Group:

We get PVs from physical hard disk, and there PVs can be formed into a VG, this VG can be treated as an whole disk.

Logical Volume:

On the VG we create, we could create Logical Volumes, which are just like the physical partition on hard disk.

[example]

1. create a VG

vgcreate fileserver /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde1

2. create LV

lvcreate –name share –size 40G fileserver

 

 

for more detailed tutorial on LVM, please click http://www.howtoforge.com/linux_lvm

Examples of this post also comes from the tutorial above.


OpenStack VLAN

VLAN网络模式

OpenStack Compute的默认模式。在这个模式里面,Compute为每个项目创建了VLAN和网桥。为了实现多台机器的安装,VLAN网络模式需要一个支持VLAN标签(IEEE 802.1Q)的路由器。每个项目获得一些只能从VLAN内部访问的私有IP地址。为了实现用户获得项目的实例,需要创建一个特殊的VPN实例(代码名为cloudpipe)。Compute为用户生成了证明书和key,使得用户可以访问VPN,同时Compute自动启动VPN。它为每个项目的所有实例提供一个私有网络段,这个私有网络段都是可以通过因特网的VPN访问的。在这个模式里面,每个项目获得它自己的VLAN,Linux网桥还有子网。被网络管理员所指定的子网都会在需要的时候动态地分配给一个项目。DHCP服务器为所有的VLAN所启动,从被分配到项目的子网中获取IP地址并传输到虚拟机实例。所有属于某个项目的实例都会连接到同一个VLAN。OpenStack Compute在必要的时候会创建Linux网桥和VLAN。

Read the rest of this entry »


西安西安

多数的城市正在把自己的历史消亡,以现代化为借口泯灭自己的成长。所幸的是,西安成长的骨架仍依旧栖伏在城市的最中心,以清晰的东南西北,青龙白虎朱雀玄武镶嵌在整个城市成长的方向里
城墙下依旧有老人扎堆弹唱古曲,路边的公园里还有老头挑来担子为客人修剪头发
街头熙熙攘攘,人物面目确实比南方粗犷,笑声亦爽朗
面馆面条竟也粗细不一,牛肉劲道十足
来到和离开的时候都去了西交南门的老赵烤肉大快朵颐,至今想起也要吞咽口水
在西安成里的公交车上,我们一伙高中同学,遇到几个高中生,与她们一起谈笑,竟忘了自己已经是大学快毕业的人
晚上照样看不见天上的星星,但是想想口中烤牛筋的余味,却觉得地上有美味已经很醉人
在这样的年代,不知自由为何物,所以只好找个空闲去别处寻找
每个城市都有自己的味道,趁着还没有完全被消磨殆尽,应该去多走走 Read the rest of this entry »


Java存储

1. 寄存器(register) 。这是最快的存储区,因为它位于不同于其他存储区的地方——处理器内部。但是寄存器的数量极其有限,所以寄存器由编译器根据需求进行分配。你不能直接控制,也不能在程序中感觉到寄存器存在的任何迹象。
2. 堆栈(stack) 。位于通用 RAM(random-access memory,随机访问存储器)中,但通过它的“堆栈指针”可以从处理器那里获得直接支持。堆栈指针若向下移动,则分配新的内存;若向上移动,则释放那些内存。这是一种快速有效的分配存储方法,仅次于寄存器。创建程序时,Java 编译器必须知道存储在堆栈内所有数据的确切大小和生命周期,因为它必须生成相应的代码,以便上下移动堆栈指针。这一约束限制了程序的灵活性,所以虽然某些 Java 数据存储于堆栈中——特别是对象引用,但是 Java 对象并不存储于其中。 Read the rest of this entry »


无觅相关文章插件,快速提升流量