Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Yori Fournier
myplotlib
Commits
26ee0ed1
Commit
26ee0ed1
authored
Aug 28, 2017
by
Yori Fournier
Browse files
Some minor changes
parent
9f42d865
Changes
2
Hide whitespace changes
Inline
Side-by-side
config-server.py
View file @
26ee0ed1
...
...
@@ -4,7 +4,7 @@ from .myData import MyData
D_VERSION
=
'v5'
D_HIERARCHY
=
'SERVER'
D_HOST
=
'localhost'
D_PORT
=
50
228
D_PORT
=
50
803
# FORM -----------------------------------------------------------------
INFO
=
" > info-: "
...
...
server.py
View file @
26ee0ed1
from
.
import
socket
,
AF_INET
,
SOCK_STREAM
from
.
import
D_HOST
from
.
import
D_PORT
from
.
import
INFO
,
DBUG
,
WARN
,
SEVR
,
SPCE
class
Server
():
...
...
@@ -8,10 +9,11 @@ class Server():
def
__init__
(
self
):
self
.
soc
=
socket
(
AF_INET
,
SOCK_STREAM
)
# self.soc.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) # requires some extra import
self
.
host
=
D_HOST
self
.
port
=
D_PORT
self
.
answer
=
Non
e
#
self.answer =
Fals
e
def
init
(
self
):
...
...
@@ -20,25 +22,27 @@ class Server():
def
run
(
self
):
answer
=
False
while
True
:
if
not
self
.
answer
:
if
not
answer
:
conn
,
addr
=
self
.
soc
.
accept
()
print
(
INFO
+
'Connected by '
+
str
(
addr
))
self
.
answer
=
conn
.
recv
(
1024
)
answer
=
conn
.
recv
(
1024
)
if
self
.
answer
in
(
'KILL'
,
'kill'
,
'Kill'
):
if
answer
in
(
'KILL'
,
'kill'
,
'Kill'
):
print
(
INFO
+
"Recieved 'Kill' signal."
)
conn
.
close
()
break
else
:
self
.
treatAnswer
()
self
.
treatAnswer
(
answer
)
def
treatAnswer
(
self
):
def
treatAnswer
(
self
,
answer
):
try
:
exec
(
str
(
self
.
answer
))
exec
(
str
(
answer
))
except
:
print
(
INFO
+
"I could not execute the command"
)
print
(
INFO
+
'Received: '
+
str
(
self
.
answer
))
print
(
INFO
+
'Received: '
+
str
(
answer
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment