-
Archives
- March 2013
- December 2012
- May 2011
- November 2010
- October 2010
- September 2010
- July 2010
- June 2010
- March 2010
- February 2010
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- February 2009
- January 2009
- December 2008
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- December 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
- May 2006
- April 2006
- March 2006
- February 2006
- January 2006
- December 2005
- November 2005
- October 2005
- September 2005
- August 2005
- July 2005
- June 2005
- May 2005
- April 2005
-
Meta
Search Results for: python
daily system check and send mail
真的太懶了…XDD,基本上當系統多到一定程度的時候,就因該進化到異常管理與通知…. 人在怎麼勤快,一定會有懶散的時候… 這時候就是想想辦法讓電腦幫我們檢查個個系統的狀態與回報的時候, 前提:你已經裝好Nagios….:P 因Nagios…沒有report的功能…所以我就用python做了一個把網頁轉寄出去的功能…以應付老闆XDD #!/usr/bin/env python #-*- coding: utf-8 -*- ”’ ===== Check Spam Report Script ===== Log: 2009/12/20 10:42 ver 0.1 Create Script “The mail system daily check” 2009/12/20 15:40 ver 0.5 add css in the daily report … Continue reading
Check Spam Report
今天寫了一個script來協助daily check… 沒用到太高級的方法,只是把事情搞定而已…. python,真是一個好物啊…:D #!/usr/bin/env python #-*- coding: utf-8 -*- ”’ ===== Check Spam Report Script ===== Log: 2009/12/09 21:58 ver 1.0 Create Script 2009/12/10 13:30 ver 1.1 add localtime 2009/12/11 ver 1.5 add if spam reboot count is equal … Continue reading
Python compile
#!/usr/bin/python import py_compile import sys file=raw_input(“Please enter your file name”) py_compile.compile(file) sys.exit()
Backup_SVN.py
#!/usr/bin/env python #-*- coding: utf-8 -*- ”’ ============================================ LOG Date:2009/09/24 Add Threading Process Date:2009/11/10 Add Check PATH, if you forget enter ‘/’ ============================================ ”’ import threading import Queue import os import sys import time __author__ = “AllenWang” __copyright__ = “Copyright … Continue reading
rsync.py
#!/usr/bin/env python #-*- coding: utf-8 -*- from subprocess import call import sys import time import commands source = “xxx@10.181.59.137:~/sysbackup/” target = “~/sysbackup/relay/” rsync = “/usr/local/bin/rsync” arguments = “-avuzb –delete -e” ssh = “‘ssh -i /home/xxx/.ssh/id_dsa’” cmd = “%s %s %s … Continue reading
automount.py
只是為了偷懶,所以隨手寫了一個script… #!/usr/bin/env python #-*- coding: utf-8 -*- import os import commands def usbdisk(): S_usb = commands.getoutput(‘df |grep /mnt/bkusb’) if ‘/mnt/bkusb’ in S_usb: print ‘usb disk relly to use’ return True else: if os.path.exists(‘/dev/da0s1′): S_Musb = commands.getoutput(‘sudo mount_ntfs /dev/da0s1 /mnt/bkusb/’) print … Continue reading
admintools.py
#!/usr/bin/env python #-*- coding: utf-8 -*- #System Admin tools library #ver 0.1 by AllenWang 2009/06/29 import socket import sys import time import commands class ConnectedTest(): def CoTest(self, address, port): s = socket.socket() try: s.connect((address,port)) print “Connected to %s on port … Continue reading
Connected_Test.py for OOP
#!/usr/bin/env python #-*- coding: utf-8 -*- import socket import sys class Connected_Test(): def CoTest(self, address, port): s = socket.socket() try: s.connect((address,port)) print “Connected to %s on port %s Successful” % (address, port) return True except socket.error: print “Connect Error” return … Continue reading
Vim setting with python
.vimrc set shiftwidth=4 set tabstop=4 set expandtab 說明: shiftwidth: 使用 [>>] , [< <] , cindent 時填入的空白數 tabstop:一個 tab 其長度相當於多少個空白 expandtab:將 tab 轉成空白
Mail to Mysql
#!/usr/bin/env python #-*- coding: utf-8 -*- import MySQLdb import mailbox dbhost=”127.0.0.1″ database=”xxxx” sqluser=”xxxx” sqlpassword=”xxxx” db = MySQLdb.connect(host=dbhost, user=sqluser, passwd=sqlpassword, db=database , charset=”utf8″) cursor = db.cursor() param = [] sql = “insert into `maildate`.`mail` (`id`, `to`, `from`, `subject`, `received`, `date`, `message`) … Continue reading