def check_server(): t = connect() if not t: print 'ERROR: Unable to connect. A running server is required to do the tests.\r\n' raise unittest.SkipTest # this doesn't actually work as intended # remove players possibly left over from an old run remove_list = ['testplayer', 'testtwo', 'admintwo', 'testobs'] t.write('admin\n') t.write('%s\n' % admin_passwd) for r in remove_list: t.write('remplayer %s\n' % r) t.write('aclearhist admin\n') t.close()
def on_ok_button(self): '''self.host = self.dialog.host_tb.toPlainText() self.db_name = self.dialog.db_name_tb.toPlainText() self.login = self.dialog.login_tb.toPlainText() self.password = self.dialog.password_tb.toPlainText()''' self.host = "localhost" self.db_name = "hospital_test" self.login = "******" self.password = "******" self.connection = test.connect(self.host, self.db_name, self.login, self.password) self.window = DaBestApp() self.window.setupUi(self.window) self.window.query1_button.clicked.connect(self.query1) self.window.query2_button.clicked.connect(self.query2) self.window.query3_button.clicked.connect(self.query3) self.window.query4_button.clicked.connect(self.query4) self.window.query5_button.clicked.connect(self.query5) self.window.clear_button.clicked.connect(self.clear_view) self.window.show() self.dialog.close()
from test import connect from socket import socket, gethostname def makeclient(): s = socket() s.connect((gethostname(), 12345)) return s if __name__ == '__main__': s = makeclient() connect(s)
from test import connect from socket import socket, gethostname def makeserver(): s = socket() s.bind((gethostname(), 12345)) s.listen(5) while True: yield s.accept() if __name__ == '__main__': for c, a in makeserver(): connect(c)