boby bob
This commit is contained in:
parent
8c08384eb2
commit
32e3b3567c
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
client/README.md
Normal file → Executable file
0
client/README.md
Normal file → Executable file
@ -1,29 +0,0 @@
|
||||
from socket import *
|
||||
|
||||
Host = "127.0.0.1"
|
||||
Port = 2222
|
||||
Addr = (Host,Port)
|
||||
|
||||
def Client():
|
||||
s = socket(AF_INET,SOCK_STREAM);
|
||||
s.connect(Addr);
|
||||
|
||||
while True :
|
||||
cmd = input("Entrez votre commande (help pour la liste des commandes et quit pour quitter) : ")
|
||||
if cmd.lower() == "quit":
|
||||
break
|
||||
try :
|
||||
s.send(cmd.encode())
|
||||
#data , addr = s.recvfrom(4096)
|
||||
#print(data.decode())
|
||||
except timeout :
|
||||
print("Erreur : Timeout. Le serveur ne repond pas.")
|
||||
|
||||
s.close();
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
Client()
|
||||
|
||||
|
||||
|
0
client/view/mainWindow.py
Normal file → Executable file
0
client/view/mainWindow.py
Normal file → Executable file
0
client/view/mainWindow.ui
Normal file → Executable file
0
client/view/mainWindow.ui
Normal file → Executable file
80
client/view/start.py
Normal file → Executable file
80
client/view/start.py
Normal file → Executable file
@ -1,7 +1,6 @@
|
||||
from mainWindow import Ui_Dialog
|
||||
from PyQt4 import QtGui, QtCore
|
||||
import datetime
|
||||
import time
|
||||
import time, threading, datetime
|
||||
from socket import *
|
||||
|
||||
Host = "127.0.0.1"
|
||||
@ -16,25 +15,23 @@ class start(QtGui.QDialog):
|
||||
|
||||
def getTimeStamp(self):
|
||||
return ('[%s] ' % str(datetime.datetime.fromtimestamp(int(time.time())).strftime('%H:%M')))
|
||||
|
||||
def htmlToText( self, html ):
|
||||
|
||||
html = html.replace('<', '<')
|
||||
html = html.replace('>', '>')
|
||||
|
||||
return html
|
||||
|
||||
|
||||
def ShowMessageAsText(self, txt):
|
||||
self.message_buffer += '<br><span style="color : red"> ' + self.getTimeStamp() + '</span>' + txt + ''
|
||||
|
||||
|
||||
def createWidgets(self):
|
||||
self.ui = Ui_Dialog()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.ui.lineEdit.setDisabled(True)
|
||||
self.ui.pushButton.setDisabled(True)
|
||||
self.ui.pushButton_3.setDisabled(True)
|
||||
self.message_buffer = ""
|
||||
self.connectActions()
|
||||
|
||||
|
||||
|
||||
# self.UpdateMainDisplay()
|
||||
self.message_buffer += '<br><span style="color : red"> ' + self.getTimeStamp() + '</span>' + self.htmlToText(txt) + ''
|
||||
|
||||
def UpdateChat(self, messgServeur) :
|
||||
self.ShowMessageAsText(messgServeur)
|
||||
self.ui.txtOutput.setText(self.message_buffer)
|
||||
sb = self.ui.txtOutput.verticalScrollBar()
|
||||
sb.setValue(sb.maximum())
|
||||
|
||||
def connectActions(self):
|
||||
self.ui.pushButton_2.clicked.connect(self.connecter)
|
||||
@ -48,6 +45,36 @@ class start(QtGui.QDialog):
|
||||
self.ui.pushButton.setDisabled(False)
|
||||
self.ui.pushButton_2.setDisabled(True)
|
||||
self.ui.pushButton_3.setDisabled(False)
|
||||
|
||||
#threading.Thread(target=self.ecoute).start()
|
||||
#for t in threading.enumerate():
|
||||
# if t != threading.main_thread(): t.join()
|
||||
|
||||
def deco(self):
|
||||
self.s.close()
|
||||
self.ui.lineEdit.setDisabled(True)
|
||||
self.ui.pushButton.setDisabled(True)
|
||||
self.ui.pushButton_2.setDisabled(False)
|
||||
|
||||
def ecoute(self):
|
||||
while 1 :
|
||||
data = self.s.recv(4096)
|
||||
if not data :
|
||||
break
|
||||
messgServeur = (data.decode())
|
||||
self.UpdateChat(messgServeur)
|
||||
|
||||
|
||||
def createWidgets(self):
|
||||
self.ui = Ui_Dialog()
|
||||
self.ui.setupUi(self)
|
||||
|
||||
self.ui.lineEdit.setDisabled(True)
|
||||
self.ui.pushButton.setDisabled(True)
|
||||
self.ui.pushButton_3.setDisabled(True)
|
||||
self.message_buffer = ""
|
||||
self.connectActions()
|
||||
|
||||
|
||||
|
||||
"""
|
||||
@ -65,34 +92,27 @@ class start(QtGui.QDialog):
|
||||
"""
|
||||
|
||||
|
||||
def deco(self):
|
||||
self.s.close()
|
||||
self.ui.lineEdit.setDisabled(True)
|
||||
self.ui.pushButton.setDisabled(True)
|
||||
self.ui.pushButton_2.setDisabled(False)
|
||||
|
||||
|
||||
def client(self):
|
||||
|
||||
cmd = self.ui.lineEdit.text()
|
||||
if cmd != "":
|
||||
self.ui.lineEdit.setText('')
|
||||
if cmd.lower() == "quit":
|
||||
exit(0)
|
||||
|
||||
try:
|
||||
self.s.send(cmd.encode())
|
||||
data = self.s.recv(4096)
|
||||
messgServeur = (data.decode())
|
||||
self.ShowMessageAsText(messgServeur)
|
||||
self.ui.txtOutput.setText(self.message_buffer)
|
||||
sb = self.ui.txtOutput.verticalScrollBar()
|
||||
sb.setValue(sb.maximum())
|
||||
self.UpdateChat(messgServeur)
|
||||
|
||||
|
||||
except timeout:
|
||||
print("Erreur : Timeout. Le serveur ne repond pas.")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
|
||||
app = QtGui.QApplication(sys.argv)
|
||||
myapp = start()
|
||||
myapp.show()
|
||||
|
27
log/activity.log
Normal file
27
log/activity.log
Normal file
@ -0,0 +1,27 @@
|
||||
2015-04-01 08:42:26,046 :: INFO :: [95m Configuration load Namespace(port=8000, usermax=None) [0m
|
||||
2015-04-01 08:42:26,046 :: INFO :: [95m Server start [0m
|
||||
2015-04-01 08:42:26,088 :: INFO :: [95m Server Listen on port 8000 [0m
|
||||
2015-04-01 08:43:10,939 :: INFO :: [95m Wait for threads ending [0m
|
||||
2015-04-01 08:43:10,940 :: INFO :: [95m Server shutdown [0m
|
||||
2015-04-01 08:43:21,055 :: INFO :: [95m Configuration load Namespace(port=2222, usermax=None) [0m
|
||||
2015-04-01 08:43:21,055 :: INFO :: [95m Server start [0m
|
||||
2015-04-01 08:43:21,058 :: INFO :: [95m Server Listen on port 2222 [0m
|
||||
2015-04-01 08:43:32,103 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 53851) [0m
|
||||
2015-04-01 08:43:39,933 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53851) bob [0m
|
||||
2015-04-01 08:43:45,900 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53851) super ! [0m
|
||||
2015-04-01 08:43:52,170 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53851) /name bob [0m
|
||||
2015-04-01 08:44:08,771 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 53852) [0m
|
||||
2015-04-01 08:44:12,601 :: INFO :: [95m Request from IP -> ('127.0.0.1', 53852) /quit [0m
|
||||
2015-04-01 08:44:45,278 :: INFO :: [95m Wait for threads ending [0m
|
||||
2015-04-01 08:44:45,278 :: INFO :: [95m Disconnection from IP -> ('127.0.0.1', 53851) [0m
|
||||
2015-04-01 14:01:21,465 :: INFO :: [95m Configuration load Namespace(port=8000, usermax=None) [0m
|
||||
2015-04-01 14:01:21,476 :: INFO :: [95m Server start [0m
|
||||
2015-04-01 14:01:21,508 :: INFO :: [95m Server Listen on port 8000 [0m
|
||||
2015-04-01 14:01:59,767 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 60151) [0m
|
||||
2015-04-01 14:02:04,760 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) coucou [0m
|
||||
2015-04-01 14:02:20,518 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /name bob [0m
|
||||
2015-04-01 14:03:35,380 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /newname bob [0m
|
||||
2015-04-01 14:03:38,491 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) coucou [0m
|
||||
2015-04-01 14:03:48,807 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /newname [0m
|
||||
2015-04-01 14:03:56,293 :: INFO :: [95m Request from IP -> ('127.0.0.1', 60151) /newname renan [0m
|
||||
2015-04-01 14:04:53,177 :: INFO :: [95m Connection from IP -> ('127.0.0.1', 60182) [0m
|
0
log/error.log
Normal file
0
log/error.log
Normal file
0
log/warning.log
Normal file
0
log/warning.log
Normal file
0
serveur/Log.py
Normal file → Executable file
0
serveur/Log.py
Normal file → Executable file
0
serveur/README.md
Normal file → Executable file
0
serveur/README.md
Normal file → Executable file
0
serveur/__init__.py
Normal file → Executable file
0
serveur/__init__.py
Normal file → Executable file
Reference in New Issue
Block a user