Tuesday, July 29, 2014

PYTHON CLIENT SERVER PROGRAMS

#This is the Client
import socket
s=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect(("localhost",8001))
s.send("Ping")
result=s.recv(256)
print result

s.close()
#This is a python Server program
#!/usr/bin/env python
import socket
server=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
server.bind(("localhost",8001))
server.listen(3)
while True:
    (client,address)=server.accept()
    msg=client.recv(100)
    print "received", msg
    client.send("pong")

Tuesday, July 22, 2014

CLIENT / SERVER Program written in python

I found a You tube tutorial on server/client programing, and it actually works too.

Thursday, July 17, 2014

MY DEED ORGANIZER PROGRAM

#Written by Steve Atchison for shawnee County March 26 2014
#I use this program alot to help me Organize owners on Deeds.


import sqlite3
from Tkinter import *

def addData():
    conn=sqlite3.connect('deedinfo.db')
    cur=conn.cursor()
    cur.execute("create table if not exists deedsort(bkpage text,grantor text,grantee text,pin text)")

    #Get data from GUI
    bookpage=(thebookpage.get())
    seller=(theseller.get())
    buyer=(thegrantee.get())
    pin=(thepin.get())

    clearGUI()

    #Inserts data into table. Make sure and use a list to insert values! very important!
    cur.execute("insert into deedsort values (?,?,?,?)",([bookpage,seller,buyer,pin]))

    conn.commit() #Saves the data
      
def listData():
    clearGUI()
    conn=sqlite3.connect('deedinfo.db')
    cur=conn.cursor()

    myrows=cur.execute("select * from deedsort")
    for row in myrows:
        txtwin.insert("50.0", row[0]+"\n"+"GRANTOR: "+row[1]+"\n"+"GRANTEE: "+row[2]+"\n"+"pin = "+row[3]+"\n-------------------------------------------------\n")

def finddeed():
    con=sqlite3.connect("deedinfo.db")
    cur=con.cursor()
    deedbookpage = thebookpage.get()
    clearGUI()
    cur.execute("select * from deedsort")
    rows = cur.fetchall()
    for row in rows:
        if row[0]== str(deedbookpage):
            print "\nBook and Page: ", row[0]
            print "Grantor: ",row[1]
            print "Grantee: ",row[2]
           

def clearGUI():
    thebookpage.delete(0,END)
    theseller.delete(0,END)
    thegrantee.delete(0,END)
    thepin.delete(0,END)
    
    txtwin.delete("1.0",END)

def listgrantor():
    clearGUI()
    conn=sqlite3.connect('deedinfo.db')
    cur=conn.cursor()

    myrows=cur.execute("select * from deedsort")
    for row in myrows:
        txtwin.insert("50.0","GRANTOR :"+ row[1]+"\n-----------------------------------------------------------\n")

def listgrantee():
    clearGUI()
    conn=sqlite3.connect('deedinfo.db')
    cur=conn.cursor()

    myrows=cur.execute("select * from deedsort")
    for row in myrows:
        txtwin.insert("50.0","GRANTEE :"+ row[2]+"\n-----------------------------------------------------------\n")
def droptable():
    conn=sqlite3.connect('deedinfo.db')
    cur=conn.cursor()
    cur.execute("DROP TABLE deedsort")
def saveit():
    alist = txtwin.get("1.0",END)
    f = open("minilog.txt", "w")
    clearGUI()
    txtwin.insert("1.0","list saved in minlog.txt")
    f.write(str(alist))
        f.close()
                         
root=Tk()
root.title('Deed organizer ')
root.config(bg='yellow')
root.geometry('800x750')
              
btn=Button(root,text="List table",command=listData)
btn.pack()

btn2=Button(root,text="Add to table",command=addData)
btn2.pack()

btn4=Button(root,text="List Grantors",command=listgrantor)
btn4.pack()

grantbtn=Button(root,text="List Grantees",command=listgrantee)
grantbtn.pack()

labl=Label(root,text="DEED NUMBER").pack()

thebookpage = Entry()
thebookpage.pack()

labl2=Label(root,text="GRANTOR").pack()
theseller = Entry(root, width = 90)
theseller.pack()

labl3=Label(root,text="GRANTEE").pack()
thegrantee=Entry(root, width=90)
thegrantee.pack()

lab4=Label(root,text="PIN").pack()
thepin =Entry(root,width =40)
thepin.pack()

txtwin=Text(root,width='800',height=26,background='white')
txtwin.pack(padx=5, pady=5)

droptablebtn=Button(root,text="Delete Table",command=droptable)
droptablebtn.pack()

savebtn=Button(root,text="Save to text file",command=saveit)
savebtn.pack()

root.mainloop()

Followers

Blog Archive

About Me

My photo
Biking helps me to cope with life.