Tag Archives: 技巧

Py2exe编译Pywinauto程序

话说Pywinauto真是好用阿,不过有些脚本想给同事用他们要安装Python就有点麻烦了,用Py2exe编译出的程序运行时总提示有错误。今天花了点时间,原来Py2exe的脚本里有很多选项可以用。先写这一点吧。

from distutils.core import setup
import py2exe

setup(console=['setup_vista32.py'],
options={
"py2exe":{
"packages":["pywinauto",
"pywinauto.findwindows",
"pywinauto.controls",
"pywinauto.tests"]
}
}

以后再慢慢优化把垃圾去出去。
PS:破Wordpress把我的缩进破坏了.

Posted in Programming, QA, 技术, 测试 | Also tagged , , | 1 Comment

给Squid添加密码验证

在Linux上配置代理服务squid也不止一次两次了,每次查文献怪麻烦的,在这里记录一下。

安装基本squid服务我就不说了,网上多得是。要加密码验证的话需要一个包,我安装Apache 2以后系统里就会有了。

建立一个新密码文件,然后确认一下它的属性。
touch /etc/squid/squid_passwd
chmod o+r /etc/squid/squid_passwd

然后建立一个新用户
sudo htpasswd /etc/squid/squid_passwd test

然后在/etc/squid.conf下加入:
auth_param basic program /usr/lib/squid/ncsa_auth /etc/squid/squid_passwd

在acl那堆配置里最后一行加入
acl ncsa_users proxy_auth REQUIRED

在http_access那堆里最上一行加入
http_access allow ncsa_users

Posted in Linux, Uncategorized, 技术 | Also tagged , , , , | Leave a comment

我现在最怕的事情就是pacman -Syu

Arch Linux更新快,好是好,就是很多时候造成不必要的麻烦。像是这个星期,星期五为了安装一个软件升级了一下,做了一次pacman -Syu,结果他给我安了Python2.6(好像是)。

首先是进了系统特别慢,然后Avant-window-navigator不工作了,stack plugin显示不出来,awn-manger不能运行。命令行下检查会发现是因为libpython2.5.so.1.o找不到了,这个倒是简单,我用一个蠢办法:

cd /usr/lib
sudo ln -s libpython2.6.so.1.0 libpython2.5.so.1.0

就混过去了。然后系统还是慢,时钟加载不成功,nautilus不停的重启。后来发现是scim-python惹的货, 只好把.xprofile重新命名,然后把scim -d从session里去掉。我认为应该把scim-python重新编译一下才能解决这个问题,结果yaourt就是不能用了,打完了命令就停在那里。在搜索的时候终于发现,原来是archlinux.org给掉了,不知道什么原因,所有archlinux.org结尾的网站,wiki,bbs都down了。怪不得yaourt不能用,主机都连不上,怎么更新。不过pacman用的是镜像所以没问题。反正我也是没法子,就索性不用中文了。结果今天archlinux好了还是不成,编译出现问题,把PKGBUILD里的python2.5改成python2.6,然后才编译成功。结果用起来还是不行,加载scim的时候显示
/usr/share/scim-python/engine/PinYin/ZhengJu.py:38: DeprecationWarning: the sets module is deprecated
from sets import Set as set
/usr/share/scim-python/engine/PinYin/ZhengJu.py:39: DeprecationWarning: The popen2 module is deprecated. Use the subprocess module.
import popen2

妈的,今天实在没时间搞这个了,只有改天再整了。刚刚看了一个Django上出现这个问题的相同解决方法。只好用python-pinyin了。

后记:scim python-pinyin是可以用的,就是我的fitx不能用了。

Posted in Linux | Also tagged , | 3 Comments

SCIM在Arch Linux下的正确设置方法

话说今天重新更新系统后,终于又进入了久违的桌面,但是发现以前一直正常的scim突然不能用了。检查了etc/gtk-2.0下得文件,还有用户目录下得.xinitrc,应该都没问题。在终端下输入export,发现.xinitrc里的东西根本没有被执行,怎么回事不知道。

后来看论坛和wiki上说gdm不会读.xinitrc,应该用.xprofile代替,抱着试试看的心理把.xinitrc里关于scim的东西移到.xprofile里。重启Gnome,居然成功了。

#SCIM
export LC_CTYPE="en_US.utf8"
export XIM="SCIM"
export XMODIFIERS=@im=SCIM
export GTK_IM_MODULE=scim
export QT_IM_MODULE=scim
scim-d

如果你也和我一样用gdm作为窗口管理器的话(其实kdm也是这样),试着把scim移到.xprofile里吧。

Posted in Linux, Tips | Also tagged , , | Leave a comment

Arch Linux的X11启动方案选择

现在每次关机都会有这个东西,很annoying

/var/run/gdm.pid doesn't exist, perhaps GDM isn't running

查了查,原来是我X11启动方法不对,我是照着Arch Linux Beginner Wiki搞得,其实上边有很多东西Out of date。按照上边的方法,gdm给放在etc/rc.conf的daemon里面了:

DAEMONS=(syslog-ng dbus !network cpufreq laptop-mode netfs crond alsa acpid !net-profiles hal fam networkmanager gdm dhcdbd vboxnet @sshd)

把它移走,现在我的rc.conf是:

#
# /etc/rc.conf - Main Configuration for Arch Linux
#

# -----------------------------------------------------------------------
# LOCALIZATION
# -----------------------------------------------------------------------
#
# LOCALE: available languages can be listed with the 'locale -a' command
# HARDWARECLOCK: set to "UTC" or "localtime"
# USEDIRECTISA: use direct I/O requests instead of /dev/rtc for hwclock
# TIMEZONE: timezones are found in /usr/share/zoneinfo
# KEYMAP: keymaps are found in /usr/share/kbd/keymaps
# CONSOLEFONT: found in /usr/share/kbd/consolefonts (only needed for non-US)
# CONSOLEMAP: found in /usr/share/kbd/consoletrans
# USECOLOR: use ANSI color sequences in startup messages
#
LOCALE="en_US.utf8"
HARDWARECLOCK="localtime"
USEDIRECTISA="no"
TIMEZONE="Europe/Stockholm"
KEYMAP="us"
CONSOLEFONT=
CONSOLEMAP=
USECOLOR="yes"

# -----------------------------------------------------------------------
# HARDWARE
# -----------------------------------------------------------------------
#
# MOD_AUTOLOAD: Allow autoloading of modules at boot and when needed
# MOD_BLACKLIST: Prevent udev from loading these modules
# MODULES: Modules to load at boot-up. Prefix with a ! to blacklist.
#
# NOTE: Use of 'MOD_BLACKLIST' is deprecated. Please use ! in the MODULES array.
#
MOD_AUTOLOAD="yes"
#MOD_BLACKLIST=() #deprecated
#MODULES=(e1000e iwl4965 snd-mixer-oss snd-pcm-oss snd-hwdep snd-page-alloc snd-pcm snd-timer snd snd-hda-intel soundcore)
MODULES=(acpi_cpufreq cpufreq_ondemand cpufreq_stats cpufreq_powersave cpufreq_conservative vboxdrv ac battery button dock processor thermal video wmi firmware_class hci_usb cdrom agpgart intel-agp nvram hid usbhid i2c-i801 i2c-core evdev ff-memless joydev pcspkr psmouse serio_raw led-class compat_ioctl32 uvcvideo v4l1-compat videodev thinkpad_acpi mmc_core ricoh_mmc sdhci pci_hotplug shpchp rtc-cmos rtc-core rtc-lib nvidia output snd-mixer-oss snd-pcm-oss snd-hwdep snd snd-page-alloc snd-pcm snd-timer snd-hda-intel soundcore pata_acpi ata_generic scsi_mod ahci ata_piix e1000e bluetooth mac80211 rfkill iwl4965 iwlcore cfg80211 pcmcia_core rsrc_nonstatic yenta_socket usbhid usbcore ehci-hcd uhci-hcd ieee1394 ohci1394 sd_mod sr_mod)

# Scan for LVM volume groups at startup, required if you use LVM
USELVM="no"

# -----------------------------------------------------------------------
# NETWORKING
# -----------------------------------------------------------------------
#
# HOSTNAME: Hostname of machine. Should also be put in /etc/hosts
#
HOSTNAME="t61"

# Use 'ifconfig -a' or 'ls /sys/class/net/' to see all available interfaces.
#
# Interfaces to start at boot-up (in this order)
# Declare each interface then list in INTERFACES
# - prefix an entry in INTERFACES with a ! to disable it
# - no hyphens in your interface names - Bash doesn't like it
#
# DHCP: Set your interface to "dhcp" (eth0="dhcp")
# Wireless: See network profiles below
#
eth0="dhcp"
#wlan_wlan0="wlan0 essid Buffalo"
#wlan0="dhcp"
#wlan_wlan0="wlan0 essid Buffalo key s:12345"
INTERFACES=(lo !eth0 !wlan0)

# Routes to start at boot-up (in this order)
# Declare each route then list in ROUTES
# - prefix an entry in ROUTES with a ! to disable it
#
gateway="default gw 192.168.5.1"
ROUTES=(!gateway)

# Enable these network profiles at boot-up. These are only useful
# if you happen to need multiple network configurations (ie, laptop users)
# - set to 'menu' to present a menu during boot-up (dialog package required)
# - prefix an entry with a ! to disable it
#
# Network profiles are found in /etc/network.d
#
# This now requires the netcfg package
#
#NETWORKS=(home)

# -----------------------------------------------------------------------
# DAEMONS
# -----------------------------------------------------------------------
#
# Daemons to start at boot-up (in this order)
# - prefix a daemon with a ! to disable it
# - prefix a daemon with a @ to start it up in the background
#
DAEMONS=(syslog-ng dbus !network cpufreq laptop-mode netfs crond alsa acpid !net-profiles hal fam networkmanager dhcdbd vboxnet @sshd)

然后改变etc/inittab里的启动进程,现在我的inittab是:

# /etc/inittab
#
# Runlevels:
# 0 Halt
# 1(S) Single-user
# 2 Not used
# 3 Multi-user
# 4 Not used
# 5 X11
# 6 Reboot

## Only one of the following two lines can be uncommented!
# Boot to console
#id:3:initdefault:
# Boot to X11
id:5:initdefault:

rc::sysinit:/etc/rc.sysinit
rs:S1:wait:/etc/rc.single
rm:2345:wait:/etc/rc.multi
rh:06:wait:/etc/rc.shutdown
su:S:wait:/sbin/sulogin -p

# -8 options fixes umlauts problem on login
c1:12345:respawn:/sbin/agetty -8 38400 vc/1 linux
c2:2345:respawn:/sbin/agetty -8 38400 vc/2 linux
c3:2345:respawn:/sbin/agetty -8 38400 vc/3 linux
c4:2345:respawn:/sbin/agetty -8 38400 vc/4 linux
c5:2345:respawn:/sbin/agetty -8 38400 vc/5 linux
c6:2345:respawn:/sbin/agetty -8 38400 vc/6 linux

ca::ctrlaltdel:/sbin/shutdown -t3 -r now

# Example lines for starting a login manager
#x:5:respawn:/usr/bin/xdm -nodaemon
x:5:respawn:/usr/sbin/gdm -nodaemon
#x:5:respawn:/opt/kde/bin/kdm -nodaemon
#x:5:respawn:/usr/bin/slim >& /dev/null

# End of file

非常neat。用了arch确实因为解决问题对linux了解更深了,看似很麻烦,但是由于网上社区很活跃,其实很多东西只要google一下就能解决。估计用gentoo能学到更多把,呵呵,不过我觉得arch已经很合适了。

Posted in Linux, Tips | Also tagged , | 9 Comments