def test(self): if self.cb1.get() == "" or self.cb2.get() == "" or self.textbox.get( ) == "": showinfo("", "ALL field are Mandatory ") elif self.cb1.get() != "": query = "select * from rates where Vehicletype='" + self.cb1.get( ) + "'and Parkingtype='" + self.cb2.get() + "'" db = connection() cr = db.conn.cursor() cr.execute(query) p = cr.fetchone() if p == None: query = "insert into rates values('null','" + self.cb1.get( ) + "','" + self.cb2.get() + "','" + self.textbox.get() + "')" db = connection() cr = db.conn.cursor() cr.execute(query) db.conn.commit() showinfo("", "parking Added Sucessfully") else: showinfo("", "Parking booked")
def interfacePsPppoe(host, netconfport, user, password): total = 0 terminal = "show interface ps*" terminal2 = "show interface ps*.0 terse" result = (connection(host, netconfport, user, password, terminal)) result2 = (connection(host, netconfport, user, password, terminal2)) #size = len(result.xpath('interface-information/physical-interface/name')) interfaces = result.xpath('interface-information/physical-interface/name') descriptions = result.xpath('interface-information/physical-interface/logical-interface/description') interfaceAdmin = result2.xpath('interface-information/logical-interface/admin-status') interfaceOper = result2.xpath('interface-information/logical-interface/oper-status') for i in range(len(interfaces)): #check if interface is up intAdminUp = (interfaceAdmin[i].text).strip() intUperUp = (interfaceOper[i].text).strip() if intAdminUp == "up" and intUperUp == "up": interface = (interfaces[i].text).strip() description = (descriptions[i].text).strip() terminal2 = ('show subscribers summary physical-interface '+str(interface)) result2 = (connection(host, netconfport, user, password, terminal2)) numSubscriber = result2.xpath('subscribers-summary-information/counters/session-type-pppoe') if numSubscriber: totalSubscriber = (numSubscriber[0].text).strip() print ('Interface = '+interface+' '+description+' pppoe = '+totalSubscriber) total = total+int(totalSubscriber) else: totalSubscriber = '0' #print ('Interface = '+interface+' '+description+' pppoe = '+totalSubscriber) print ("Total Subiscribers = "+str(total))
def __init__(self): scrapy_db = connection('db_key') self.cursor = scrapy_db[0] self.conn = scrapy_db[1] scrapy_logs = connection('log_key') self.cursor_logs = scrapy_logs[0] self.conn_logs = scrapy_logs[1]
def main(): palinsestoId ='*****@*****.**' OnAirId='*****@*****.**' pathReg= "xxxxx" pal = updatePalinsesto() if pal.updateSchedule(): lis = pal.build_calendar_events() #apro la connessione con google api con = connection() con.IdCalendar=palinsestoId credentials = con.get_credentials() http = credentials.authorize(httplib2.Http()) service = discovery.build('calendar', 'v3', http=http) con.clearCalendar(service,palinsestoId)#cancello tutti gli eventi nel calendario con.insert_calendar_events(lis, service)#aggiorno il calendario print'Palinsesto: Aggionameto' else : print 'Palinsesto: Aggionameto non necessario' onair= updateOnAir() onair.path= pathReg onair.readFilename() onair.build_calendar_events() if len(onair.event_list)>0: #apro la connessione con google api con = connection() con.IdCalendar=OnAirId credentials = con.get_credentials() http = credentials.authorize(httplib2.Http()) service = discovery.build('calendar', 'v3', http=http) #con.clearCalendar(service)#cancello tutti gli eventi nel calendario con.insert_calendar_events(onair.event_list, service)#aggiorno il calendario print'Calendario OnAir aggiornato' else : print'Calendario OnAir non aggiornato'
def establish_connections(self): if self.is_client: cc = connection(self.out_socket, (self.emulator_ip, self.emulator_port)) self.init_handshake(cc) # to emulator elif self.is_emulator: cc = connection(self.out_socket, (self.server_ip, self.server_port)) sc = connection(self.in_socket, (self.client_ip, self.client_port)) self.init_handshake(cc) # to server self.await_handshake(sc) # from client elif self.is_server: sc = connection(self.in_socket, (self.client_ip, self.client_port)) self.await_handshake(sc) # from emulator
def insert(self): if self.vnumber.get() == "" or self.cbvechicle.get( ) == "" or self.cbparking.get( ) == "" or self.price == "" or self.parking_location == "" or self.parking_location.get( ) == "" or self.mobile.get() == "": showerror("", "All Fields are mandatory") else: dr = connection() query = "insert into booking value (null, '" + self.vnumber.get( ) + "','" + self.cbvechicle.get() + "','" + self.cbparking.get( ) + "'," + self.price.get() + ",'" + self.dateofentry.get( ) + "','" + self.timeofentry.get( ) + "','" + self.parking_location.get() + "','" + self.mobile.get( ) + "',null,null)" cr = dr.conn.cursor() cr.execute(query) dr.conn.commit() conn = http.client.HTTPConnection("server1.vmm.education") textmessage = "Your Vehicle no " + self.vnumber.get( ) + " is Parked at row " + self.parking_location.get( ) + " and parking Date and Time respectively " + self.currentdate + "," + self.currenttime + "Your friend Aftab" textmessage = textmessage.replace(" ", "%20") conn.request( 'GET', "/VMMCloudMessaging/AWS_SMS_Sender?username=dhk_py&password=GNEP0QCE&message=" + textmessage + "&phone_numbers=" + self.mobile.get()) response = conn.getresponse() print(response.read()) showinfo("", "booking sucess") print(query)
def parking1(self): self.win = Tk() self.win.title("parking1") global bt_list for i in range(1, 11): for j in range(1, 11): s = str(i) + "-" + str(j) bt_list.append(s) dr = connection() query = "select * from booking where parkingplace='" + s + "' and dateofexit is null" cr = dr.conn.cursor() cr.execute(query) p = cr.fetchall() if len(p) > 0: bt_dict[bt_list[-1]] = ttk.Button(self.win, text="O", width="5", state="disabled") else: bt_dict[bt_list[-1]] = ttk.Button( self.win, width=5, text=s) #,bg="green",fg="yellow") bt_dict[bt_list[-1]][ "command"] = lambda x=i, y=j: self.park1(x, y) bt_dict[bt_list[-1]].grid(row=i, column=j, padx=5, pady=3) self.win.mainloop()
def parking2(self): self.rk = Tk() self.rk.title("Parking2") global bt_list for i in range(101, 111): for j in range(101, 111): s = str(i) + "-" + str(j) bt_list.append(s) dr = connection() query = "select * from parking_ticket where parking_location='" + s + "' and dateofexit is null" cr = dr.conn.cursor() cr.execute(query) p = cr.fetchall() if len(p) > 0: bt_dict[bt_list[-1]] = Button(self.rk, text="O", font="bold", width="5", bg="red", state="disabled") else: bt_dict[bt_list[-1]] = Button(self.rk, width=7, text=s, bg="green", fg="yellow") bt_dict[bt_list[-1]][ "command"] = lambda x=i, y=j: self.park1(x, y) bt_dict[bt_list[-1]].grid(row=i, column=j, padx=5, pady=3) self.rk.mainloop()
def date(self): dr = connection() query = "select * from booking where Vehicle_number='" + self.vnumber.get( ) + "'" # print(query) cr = dr.conn.cursor() cr.execute(query) p = cr.fetchall() for i in range(0, len(p)): self.tree.insert("", value=p[i], index=i) query1 = "SELECT price from booking where Vehicle_number='" + self.vnumber.get( ) + "'" cd = dr.conn.cursor() cd.execute(query1) q = cd.fetchall() s = 0 for i in q: for j in range(0, 1): s = s + int(i[j]) self.total.insert(0, s) self.total.config(state="readonly")
def check_login(request, session, flash): error = '' c, conn = connection() print(1) if request.method == "POST": x = c.execute("SELECT * FROM user WHERE username = (%s)", thwart(request.form['username'])) if int(x) == 0: error = "Invalid credentials, try again." c.close() return 1, error data_password = c.fetchone()[6] if sha256_crypt.verify(request.form['password'], data_password): session['logged_in'] = True session['username'] = request.form['username'] flash("Welcome " + session['username']) c.close() return 0, '' else: error = "Invalid credentials, try again." c.close() return 2, error else: return 3, error
def __init__(self): self.root=Tk() self.root.configure(background="skyblue") self.root.resizable(0,0) lb=Label(self.root,text="VIEW RATE",font=("arial",20,"bold"),fg="blue",bg="skyblue") lb.grid(row=0,column=0) tree=ttk.Treeview(self.root, column=("rateid","vechicle","type","price")) tree.heading("rateid",text="Rate_id") tree.heading("vechicle",text="Vechicle_Type") tree.heading("type",text="parking_type") tree.heading("price",text="Price") dr=connection() query = "Select * from rate" cr=dr.conn.cursor() cr.execute(query) p = cr.fetchall() for i in range(0, len(p)): tree.insert("", value=p[i], index=i) tree.grid(row=1,column=0) tree.column("#0",width=0) tree.column("price",width=100) self.root.mainloop()
def update(self): if self.vnumber.get() == "" or self.cbvechicle.get( ) == "" or self.cbparking.get( ) == "" or self.price == "" or self.parking_location == "" or self.parking_location.get( ) == "" or self.mobile.get() == "": showerror("", "All Fields are mandatory") else: dr = connection() query = "UPDATE `parking_ticket` SET `dateofexit`='" + self.dateofexit.get( ) + "',`timeofexit`='" + self.timeofexit.get( ) + "' WHERE vehicle_number='" + self.vnumber.get() + "'" cr = dr.conn.cursor() cr.execute(query) dr.conn.commit() showinfo("", "exit") self.dateofentry.delete(0, END) self.price.delete(0, END) self.parking_location.delete(0, END) self.mobile.delete(0, END) self.vnumber.delete(0, END) self.timeofexit.delete(0, END) self.dateofexit.delete(0, END) self.cbparking.set('') self.cbvechicle.set('') self.timeofentry.delete(0, END)
def __init__(self): self.root = Tk() self.root.title("Parking admin") self.root.config(bg='light gray') self.lb_heading = Label(self.root, text="RATES") labelfont = ('Arial', 20, 'bold') self.lb_heading.configure(foreground='brown', background='light gray', font=labelfont) self.lb_heading.pack() self.t = Treeview(self.root, columns=("Rateid", "Vehicletype", "Parkingtype", "Price")) self.t.heading("Rateid", text="Rate ID") self.t.heading("Vehicletype", text="Different vehicle") self.t.heading("Parkingtype", text="Parking ") self.t.heading("Price", text="Price") query = "select * from rates" db = connection() cr = db.conn.cursor() cr.execute(query) p = cr.fetchall() for i in range(0, len(p)): self.t.insert("", values=p[i], index=i) self.t.pack() self.root.mainloop() #----------------------------------------------------------------- #x=view()
def __init__(self): self.root = Tk() self.root.title("view admin") self.root.config(bg='light gray') self.lb_heading=Label(self.root,text="view admin") labelfont=('Arial',20,'bold') self.lb_heading.configure(foreground='brown',background='light gray',font=labelfont) self.lb_heading.pack() self.t = Treeview(self.root,columns=("email", "password", "mobile","type")) self.t.heading("email", text="Emailid") self.t.heading("password", text="Password") self.t.heading("mobile", text="Mobile number") self.t.heading("type", text="type") query = "select * from admin" db = connection() cr = db.conn.cursor() cr.execute(query) p = cr.fetchall() for i in range(0, len(p)): self.t.insert("", values=p[i], index=i) self.t.pack() self.root.mainloop()
def save(self): query3 ="update booking set dateofexit='"+self.dateofexit.get()+"',timeofexit='"+self.timeofexit.get()+"'where Vehicle_number='"+self.vnumber.get()+"'" db = connection() cr = db.conn.cursor() cr.execute(query3) db.conn.commit() showinfo("", "Exit Successfully")
def test(self): self.x = int(self.tb_email.get().count("@")) self.d = int(self.tb_email.get().count(".")) if self.tb_roll.get() == "" or self.tb_sname.get( ) == "" or self.cb_course.get() == "" or self.cb_gen.get( ) == "" or self.cb_sem.get() == "" or self.tb_mobile.get( ) == "" or self.tb_pmobile.get() == "" or self.tb_fname.get( ) == "" or self.cb_sem.get() == "" or self.tb_email.get( ) == "" or self.tb_address.get() == "" or self.tb_paddress.get() == "": showerror("", "Cannot Leave any field blank", parent=self.root) elif self.tb_mobile.get().isalpha() == True: showerror("", "Mobile number not valid") elif self.tb_pmobile.get().isalpha() == True: showerror("", "Mobile number not valid") elif self.x != 1 or self.tb_email.get() == "" or self.d != 1: showerror("", "Wrong Email", parent=self.root) else: db = connection() cr = db.conn.cursor() query = "insert into student values(null,'" + self.tb_roll.get( ) + "','" + self.tb_sname.get() + "','" + self.tb_fname.get( ) + "','" + self.cb_gen.get() + "','" + self.cb_course.get( ) + "','" + self.cb_sem.get() + "','" + self.tb_mobile.get( ) + "','" + self.tb_address.get() + "','" + self.tb_email.get( ) + "','" + self.tb_pmobile.get() + "','" + self.tb_paddress.get( ) + "')" cr.execute(query) db.conn.commit() showinfo("Success", "Student added successfully")
def __init__(self): self.root = Tk() self.root.title("View Details") self.root.configure(background='sky blue') self.lb_heading = Label(self.root, text="DEPARTMENT DETAILS") Labelfont = ('Arial', 20, 'bold') self.lb_heading.configure(foreground="black", background='sky blue', font=Labelfont) self.lb_heading.grid(row=0, column=0) self.t = Treeview(self.root, columns=("Depart", "HOD", "Desc")) self.t.heading("Depart", text="Department Name") self.t.heading("HOD", text="HOD Name") self.t.heading("Desc", text="Description") cb = connection() query = "select deptname,hodname,description from department" cr = cb.conn.cursor() cr.execute(query) self.p = cr.fetchall() for i in range(0, len(self.p)): self.t.insert("", values=self.p[i], index=i) self.t.column("#0", width=0) self.t.column("HOD", width=170) self.t.grid(row=1, column=0) self.root.mainloop()
def delete(self): if self.tb_studentid.get() == "" or self.tb_roll.get( ) == "" or self.tb_sname.get() == "" or self.cb_course.get( ) == "" or self.cb_gen.get() == "" or self.cb_sem.get( ) == "" or self.tb_mobile.get() == "" or self.tb_pmobile.get( ) == "" or self.tb_fname.get() == "" or self.cb_sem.get( ) == "" or self.tb_email.get() == "" or self.tb_address.get( ) == "" or self.tb_paddress.get() == "": showerror("", "All fields are mandatory", parent=self.root) else: db = connection() query = "delete from student where studentid='" + self.tb_studentid.get( ) + "'" cr = db.conn.cursor() cr.execute(query) db.conn.commit() showinfo("", "Subject Deleted Successfully") self.tb_roll.delete(0, END) self.tb_sname.delete(0, END) self.cb_course.delete(0, END) self.cb_gen.delete(0, END) self.tb_fname.delete(0, END) self.tb_mobile.delete(0, END) self.tb_pmobile.delete(0, END) self.tb_address.delete(0, END) self.tb_paddress.delete(0, END) self.tb_email.delete(0, END) self.cb_sem.delete(0, END)
def save(self): query3 = "update admin set password ='******',mobile='"+self.textbox3.get()+"',type='"+self.cb1.get()+"' where email='"+self.textbox1.get()+"'" db = connection() cr = db.conn.cursor() cr.execute(query3) showinfo("","Admin update Successfully")
def __init__(self): self.gladefile = "client.glade" self.wTree = gtk.glade.XML(self.gladefile) # pobieramy główne okno self.window = self.wTree.get_widget("window1") self.window.show() #wyświetlamy głowne okno if (self.window): self.window.connect('delete-event', self.icohide) mainh=self.window.get_size()[1] self.window.resize(300 ,mainh) self.window.set_default_size(300, mainh) self.window.move(int(gtk.gdk.screen_width()*0.7),int(gtk.gdk.screen_height( )*0.2)) #po zamknięciu okna - kończymy program self.window.set_title("Pybber") #pobranie obiektow z glade i przypisywanie ich do zmiennych: self.messages={} self.recipent="" assignwidgets(self) createstatusicon(self) self.connection=connection(self) self.list.set_reorderable(True) self.statusentry.hide() self.statusbar.hide() self.hidden=False self.posx,self.posy=self.window.get_position() pynotify.init("Pybber") self.archivewindow.hide()
def remove(self): query2="delete from admin where email='"+self.textbox1.get()+"'" db = connection() cr = db.conn.cursor() cr.execute(query2) db.conn.commit() showinfo("","Admin Delete Successfully")
def make_blood_request(request, flash, session): notification = thwart(request.form.get('notification', None)) user_list = request.form.get('user_list', None) subject = thwart(request.form.get('Subject', None)) print(notification) print(user_list) strs = user_list.replace('(', '').replace(')', '') list = strs.split(',') print(strs) print(list) print(list[5::6]) c, conn = connection() # for i in list[5::6]: # c.execute("INSERT INTO Notifications_data (notification, user_id) values ('''{0}''', '{1}')".format(notification,int(i))) # conn.commit() c.execute("select uid from user where username='******'".format( thwart(session['username']))) user_id = c.fetchone() c.execute( "INSERT INTO Notification_data (notification, created_by, subject) VALUES ('''{0}''', '{1}', '''{2}''')" .format(notification, user_id[0], subject)) c.execute("SELECT @last := LAST_INSERT_ID()") for i in list[5::6]: c.execute( "INSERT INTO Notification_users (notification_id, to_user) VALUES (@last,'{0}')" .format(int(i))) conn.commit() c.close() flash( 'Your request has been successsfully sent, wait until the respective user confirms' ) return 0
def __init__(self): self.root=Tk() self.root.title("View Details") self.root.configure(background='sky blue') self.lb_heading = Label(self.root, text="ADMIN DETAILS") Labelfont = ('Arial', 20, 'bold') self.lb_heading.configure(foreground="black",background='sky blue',font=Labelfont) self.lb_heading.grid(row=0, column=0) self.t=Treeview(self.root,columns=("E-mail","Mobile","Type")) self.t.heading("E-mail",text="E-mail") self.t.heading("Mobile",text="Mobile") self.t.heading("Type",text="Type") cb=connection() query="select email,mobile,type from admins" cr=cb.conn.cursor() cr.execute(query) self.p=cr.fetchall() for i in range(0,len(self.p)): self.t.insert("",values=self.p[i],index=i) self.t.column("#0",width=0) self.t.column("Type",width=130) self.t.grid(row=1,column=0) self.root.mainloop()
def get_name(uid): c,conn = connection() c.execute("select firstname, lastname from user where uid = '{0}'".format(uid)) name = c.fetchone() name = name[0]+ ' ' + name[1] c.close() return name
def run_client(): # allocate client network resources client_socket = socket(AF_INET, SOCK_DGRAM) client_socket.bind((config["client_ip"], config["client_port"])) command_connection = connection( client_socket, (config["emulator_ip"], config["emulator_port"])) # attempt connection to server if not command_connection.connect_to_remote(): print(" Client failed main connection in client") return None print("Client state:", command_connection.get_state()) # # allocate data transfer network resources # data_socket = socket(AF_INET, SOCK_DGRAM) # data_socket.bind((config["client_ip"], 0)) # data_connection = connection(socket=data_socket) # # tell remote to connect to data_connection # if not command_connection.send_command("GET", data_connection.local_port): # print("Client command_connection Failed to send command") # # await connection # if not data_connection.accept_connection(): # print("failed data connection in client") # return None # print("Client data_connection state:", data_connection.get_state()) # data_connection.recv_file(file_name="./recv/file.dat") # clear resources # data_socket.close() client_socket.close() # del data_connection del command_connection
def read_data_from_db(): query = " select * from city " # no params params = [] conn = connection(conn_string=conn_string,query=query, params=params) city_data = conn.fetch_query() return city_data
def __init__(self): #-=================================================================================== self.root=Tk() self.root.resizable(0,0) self.root.title("Data Table") self.root.configure(background="skyblue") #-===================================================================================== lb=Label(self.root,text="VIEW ADMIN",font=("arial",20,"bold"),fg="brown",bg="skyblue") lb.pack() #-====================================================================================== self.t=tkinter.ttk.Treeview(self.root, column=("email","Mobile","type")) self.t.heading("email", text="Email") self.t.heading("Mobile", text="Mobile") self.t.heading("type", text="Type") query= "Select email, mobile,type from admin" db = connection() cr = db.conn.cursor() cr.execute(query) p = cr.fetchall() for i in range(0,len(p)): self.t.insert("", value=p[i], index=i) self.t.pack() self.t.column("#0", width=0) self.t.column("type",width=130) self.t.column("Mobile",width=130) self.root.mainloop()
def __init__(self): self.choice = connection() self.name = None self.firstname = None self.pseudo = None self.email = None self.age = None self.password = None
def numSubscriberForVlanCount(host, netconfport, user, password, vlan): terminal = ('show subscribers vlan-id '+str(vlan)) result2 = (connection(host, netconfport, user, password, terminal)) #subscribers-information/subscriber/user-name size = len(result2.xpath('subscribers-information/subscriber/ip-address')) return vlan, size
def numSubscriberForVlan(host, netconfport, user, password, vlan): terminal = ('show subscribers vlan-id '+str(vlan)) result = (connection(host, netconfport, user, password, terminal)) #subscribers-information/subscriber/user-name size = len(result.xpath('subscribers-information/subscriber/ip-address')) print ('Total Subscribers on vlan '+str(vlan)+' = '+str(size))
def terminate_server_gracefully(config, ev=Event()): time.sleep(5) ev.set() try: client = connection(config['client']['ip'], config['client']['port'], ev) client.connect(config['server']['ip'], config['server']['port']) except socket.error: lg.info('caught bad file descriptor exception') client.close()
def delete(self): if self.tb_dept.get()=="" or self.tb_hod.get()=="" or self.tb_desc.get(0.1,END)=="": showerror("","All fields are mandatory",parent=self.root) else: db=connection() query="delete from department where deptname='"+self.tb_dept.get()+"'" cr=db.conn.cursor() cr.execute(query) db.conn.commit() showinfo("","department Deleted Successfully")
def getrates(self): db = connection() cr = db.conn.cursor() s = "select rateid from rate order by rateid" cr.execute(s) p = cr.fetchall() lst = [] for i in range(0, len(p)): lst.append(p[i][0]) self.cbseries.config(values=tuple(lst))
def AcceptConnections(self): log.success("Server", "Server started accepting connections") while self._ServerOn == True: c, addr = self.s.accept() log.info("New connection", "We have a new connection!!") c.settimeout(self._timeout) conn = connection(c, addr, self) new_thread = threading.Thread(target = conn.CheckForData ) new_thread.start() self._connections.append(conn) return
def createNewconnection(self, wherex, wherey, screenCoordinates = 1): self.fromClass = None self.toClass = None # try the global constraints... res = self.ASGroot.preCondition(ASG.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return new_semantic_obj = connection(self) res = new_semantic_obj.preCondition ( ASGNode.CREATE ) if res: return self.constraintViolation(res) new_semantic_obj.preAction ( ASGNode.CREATE ) ne = len(self.ASGroot.listNodes["connection"]) if new_semantic_obj.keyword_: new_semantic_obj.keyword_.setValue(new_semantic_obj.keyword_.toString()+str(ne)) if screenCoordinates: new_obj = graph_connection(self.UMLmodel.canvasx(wherex), self.UMLmodel.canvasy(wherey), new_semantic_obj) else: # already in canvas coordinates new_obj = graph_connection(wherex, wherey, new_semantic_obj) new_obj.DrawObject(self.UMLmodel, self.editGGLabel) self.UMLmodel.addtag_withtag("connection", new_obj.tag) new_semantic_obj.graphObject_ = new_obj self.ASGroot.addNode(new_semantic_obj) res = self.ASGroot.postCondition(ASG.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return res = new_semantic_obj.postCondition(ASGNode.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return new_semantic_obj.postAction(ASGNode.CREATE) self.mode=self.IDLEMODE if self.editGGLabel : self.statusbar.event(StatusBar.TRANSFORMATION, StatusBar.CREATE) else: self.statusbar.event(StatusBar.MODEL, StatusBar.CREATE) return new_semantic_obj
#!/usr/bin/env python from connection import * import logging as lg from multiprocessing import Event if __name__ == '__main__': shouldRun = Event() shouldRun.set() client = connection('192.168.189.129', 5555, shouldRun) client.connect('192.168.189.129', 6666) lg.basicConfig(leve=lg.DEBUG) while True: try: client.send({'message':raw_input('send message > ')}) except KeyboardInterrupt: shouldRun.clear() lg.info('ending') break
time.sleep(5) ev.set() try: client = connection(config['client']['ip'], config['client']['port'], ev) client.connect(config['server']['ip'], config['server']['port']) except socket.error: lg.info('caught bad file descriptor exception') client.close() if __name__ == '__main__': if sys.argv[2:]: shouldRun = Event() shouldRun.set() with open(sys.argv[1], 'r') as cf: config = json.loads(cf.read())['vlc_client'] client = connection(config['client']['ip'], config['client']['port'], shouldRun) client.connect(config['server']['ip'], config['server']['port']) lg.basicConfig(level=lg.DEBUG) msg = {'message':sys.argv[2].strip()} lg.info(msg) time.sleep(1) client.send(msg) client.close() if msg.get('message')=='terminate': terminate_server_gracefully(config) ''' while True: try: client.send(msg) except KeyboardInterrupt: shouldRun.clear()
def connectmenu(self): connect = connectdialog(self.tkframe) self.tkframe.wait_window(connect.top) if connect.connected == True: self.connection = connection(connect.server, connect.port, self.preferences.nick, self.preferences.name)
__author__ = 'Erick Almeida' import code import connection if __name__ == '__main__': db = connection() code.interact(local=locals())
def __init__(self, size, port=None): Thread.__init__(self) self.recvbuffer = "" self.c = connection() self.c.bind(1111) self.size = size