Archive for the ‘python’ Category

9
Dec

httping

   Posted by: myururdurmaz Tags: , , ,

is a small for ping http servers. Here an example

$ httping google.com

Pinging :http://google.com

9324 bytes from http://google.com: seq=1 rep=[200/OK] time=11201 ms
9356 bytes from http://google.com: seq=2 rep=[200/OK] time=834 ms
9342 bytes from http://google.com: seq=3 rep=[200/OK] time=822 ms
9342 bytes from http://google.com: seq=4 rep=[200/OK] time=827 ms

Avg :3421 ms - 9341 bytes
Speed :2KB/second
Health :%100

Download httping

Bookmark and Share
Tags: , , ,
8
Apr

python ile basit bir kod wrapper örneği

   Posted by: İsmail ÇAKIR Tags: ,

import sys

pre = ‘out.println("‘ # satirbasi sql.append(" gibi
pst = ‘")‘            # satirsonu ") gibi
addslash = 1          # tirnaklara backslash

if len(sys.argv) == 1:
    print "kullanim: \n \t\t  wrapper.py giris.txt \n  \t\t  > cikis.txt gerekiyorsa"
    sys.exit(1)

f = open(sys.argv[1] ,’r‘)

for r in f:
    if (addslash == 1):
        r = r.replace(‘"‘,’\\"‘)
    r = r.rstrip()
    line =  "%s%s%s" % (pre , r, pst)
    print line

Bookmark and Share
Tags: ,
24
Feb

linux capslock notify

   Posted by: Muhammed YÜRÜRDURMAZ Tags: , , , ,

Eer benim gibi durumunu dizüstünüzde ışık olmadığından dolayı göremiyorsanız aşağıdaki script işinizi görebilir.

bu scripti capsnotify.py ismiyle bir yere kaydedin.

daha sonra kullandığınız masaüstü ortamının otomatik başlangıç bölümüne ayarlayın.


#!/usr/bin/
import pygtk
pygtk.require(’2.0′)
import pynotify
import sys
import gtk
import os
import time

__author__="xmaster"
__date__ ="$Feb 24, 2010 11:14:16 AM$"

def get_status():
    status = None
    p = os.popen("/usr/bin/xset q")
    while 1:
        line = p.readline()
        if not line: break
        if line.find("Caps") > -1:
            status = line[21:25].strip()
            break
    p.close()
    return status

def show_status(status):
    if status == "on":
        uri = "file:///usr/share/icons/gnome/scalable/devices/keyboard.svg"
        n = pynotify.Notification("Caps Lock On", "", uri)
    else:
        uri = "file:///usr/share/icons/gnome/scalable/devices/keyboard.svg"
        n = pynotify.Notification("Caps Lock Off", "", uri)

    n.set_timeout(500)
    if not n.show():
        print "Failed to send notification"
        sys.exit(1)

if __name__ == ‘__main__’:
    if not pynotify.init("Caps toggle"):
        print "Unable to initialize Python "
        sys.exit(1)
    old_status = None
    while 1:
        status = get_status()
        if old_status is None:
            old_status = status
        if status != old_status:
            show_status(status)
            old_status = status
        time.sleep(0.5)

Bookmark and Share
Tags: , , , ,


import sys
import 

tablename = ""
mhost = ""
muser = ""
mpasswd = ""
mdb= ""

def head():
    head = """
    <><head>
    <style>
    .minput {
        border: 1px solid #fdfcf7;
        font-family: "Times New Roman", Times, serif;
        font-style: bold;
        font-size: 14px;
        color: #454743;
    }

    .mlabel {
        font-family: "Times New Roman", Times, serif;
        font-style: bold;
        font-size: 13px;
        color: #e7363e;
    }
    </style></head><body>< action="" method="post">
    """
    return head

def sub():
    sub = """
        </form></body></html>
    
    """
    return sub

def insert():
    pass

def update():
    pass

def input(name, label = None):
    if not label:
        label = name
    return ‘<label style="mlabel">%s:</label><input style="minput" name="%s" type=text />’ % (label, name)

def clean(mrow):
    pass

def deneme():
    try:
        conn = MySQLdb.connect (host = mhost, user = muser, passwd = mpasswd, db = mdb)
        cursor = conn.cursor ()
        msql = ‘select column_name from information_schema.columns where table_name="%s"’ % tablename
        cursor.execute (msql)
    except MySQLdb.Error, e:
        print "Error %d: %s" % (e.args[0], e.args[1])
        sys.exit (1)

    row = cursor.fetchall ()
    print head()
    for  r in range(len(row)):
        print input("".join(row[r]))
    print sub()
    cursor.close ()
    conn.close ()

if __name__ == "__main__" :
    deneme()

Bookmark and Share
Tags: , , , , , , ,
19
Feb

zip ve jar dosyalar içinde arama

   Posted by: İsmail ÇAKIR Tags: , , , ,


import zipfile
import os

aranan = "deneme.class"

def yuru(param, dizin, dosyalar):
    global aranan
    for dosya in dosyalar:
        if dosya.endswith(".") or dosya.endswith("."):
            zp = zipfile.ZipFile(os.path.join(dizin, dosya), "r")
            for name in zp.namelist():
                if name.endswith(aranan):
                    print os.path.join(dizin, dosya), ":", name
        if dosya.endswith(aranan):
            print os.path.join(dizin, dosya)

os.path.walk(".", yuru, None)

Bookmark and Share
Tags: , , , ,

Switch to our mobile site