Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HCCPiCluster
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Caughlin Bohn
HCCPiCluster
Commits
805b7b7d
Commit
805b7b7d
authored
6 years ago
by
Caughlin Bohn
Browse files
Options
Downloads
Patches
Plain Diff
Updated WorkerNetwork to use websockets, speed of files without io wait
parent
7298bea5
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
DisplayNode/WorkerNetwork.py
+51
-66
51 additions, 66 deletions
DisplayNode/WorkerNetwork.py
with
51 additions
and
66 deletions
DisplayNode/WorkerNetwork.py
+
51
−
66
View file @
805b7b7d
...
@@ -3,8 +3,7 @@ import sys
...
@@ -3,8 +3,7 @@ import sys
from
neopixel
import
*
from
neopixel
import
*
import
argparse
import
argparse
from
random
import
randint
from
random
import
randint
import
os
,
stat
import
socket
import
subprocess
# LED strip configuration:
# LED strip configuration:
LED_COUNT
=
100
# Number of LED pixels.
LED_COUNT
=
100
# Number of LED pixels.
LED_PIN
=
18
# GPIO pin connected to the pixels (18 uses PWM!).
LED_PIN
=
18
# GPIO pin connected to the pixels (18 uses PWM!).
...
@@ -57,8 +56,8 @@ NetLights ={
...
@@ -57,8 +56,8 @@ NetLights ={
'
CB
'
:
[
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
],
'
CB
'
:
[
12
,
13
,
14
,
15
,
16
,
17
,
18
,
19
],
'
CD
'
:
[
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
],
'
CD
'
:
[
22
,
23
,
24
,
25
,
26
,
27
,
28
,
29
,
30
],
'
DC
'
:
[
30
,
29
,
28
,
27
,
26
,
25
,
24
,
23
,
22
],
'
DC
'
:
[
30
,
29
,
28
,
27
,
26
,
25
,
24
,
23
,
22
],
'
DE
'
:
[
31
,
50
,
51
],
'
DE
'
:
[
31
,
50
,
51
,
52
],
'
ED
'
:
[
51
,
50
,
31
],
'
ED
'
:
[
52
,
51
,
50
,
31
],
'
DG
'
:
[
31
,
32
,
33
],
'
DG
'
:
[
31
,
32
,
33
],
'
GD
'
:[
33
,
32
,
31
],
'
GD
'
:[
33
,
32
,
31
],
'
EM
'
:[
52
,
53
,
54
],
'
EM
'
:[
52
,
53
,
54
],
...
@@ -73,8 +72,8 @@ NetLights ={
...
@@ -73,8 +72,8 @@ NetLights ={
'
FP
'
:[
61
,
64
,
65
],
'
FP
'
:[
61
,
64
,
65
],
'
GH
'
:
[
39
,
40
,
41
,
42
],
'
GH
'
:
[
39
,
40
,
41
,
42
],
'
HG
'
:[
42
,
41
,
40
,
39
],
'
HG
'
:[
42
,
41
,
40
,
39
],
'
LG
'
:[
36
,
35
,
2
4
],
'
LG
'
:[
36
,
35
,
3
4
],
'
GL
'
:[
2
4
,
35
,
36
],
'
GL
'
:[
3
4
,
35
,
36
],
'
GK
'
:[
34
,
37
,
38
],
'
GK
'
:[
34
,
37
,
38
],
'
KG
'
:[
38
,
37
,
34
],
'
KG
'
:[
38
,
37
,
34
],
'
HI
'
:[
43
,
44
,
45
],
'
HI
'
:[
43
,
44
,
45
],
...
@@ -106,31 +105,25 @@ def find_path(graph, start, end, path=[]):
...
@@ -106,31 +105,25 @@ def find_path(graph, start, end, path=[]):
print
(
"
starting
"
)
print
(
"
starting
"
)
import
random
import
random
iter
=
0
iter
=
0
def
delFile
(
fileName
):
HOST
=
''
# Symbolic name meaning all available interfaces
PORT
=
50007
# Arbitrary non-privileged port
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
)
#sock = socket()
s
.
setsockopt
(
socket
.
SOL_SOCKET
,
socket
.
SO_REUSEADDR
,
1
)
s
.
bind
((
HOST
,
PORT
))
s
.
listen
(
1
)
#conn, addr = s.accept()
while
1
:
conn
,
addr
=
s
.
accept
()
data
=
conn
.
recv
(
1024
)
tempData
=
data
.
split
(
"
"
)
iter
=
0
while
iter
<
int
(
tempData
[
2
]):
pipe
=
os
.
popen
(
"
su pi
"
,
'
w
'
)
start
=
NodePath
[
tempData
[
0
]]
end
=
NodePath
[
tempData
[
1
]]
pipe
.
write
(
"
rm %s
"
%
fileName
)
while
True
:
try
:
files
=
[
filename
for
filename
in
os
.
listdir
(
'
/work/netLogs/
'
)
if
"
host
"
in
filename
]
filesTemp
=
[]
for
l
in
files
:
filesTemp
.
append
(
str
(
l
[
5
:]))
for
l
in
files
:
if
min
(
filesTemp
)
in
l
:
fi
=
l
fi
=
"
/work/netLogs/
"
+
fi
#fi = "/work/netLogs/"+os.listdir("/work/netLogs/")[0]
f
=
open
(
fi
,
'
r
'
)
data
=
f
.
readline
().
split
(
"
,
"
)
delFile
(
fi
)
print
(
data
)
iter
=
0
while
iter
<
int
(
data
[
2
]):
start
=
NodePath
[
data
[
0
]]
end
=
NodePath
[
data
[
1
]]
### To do random
### To do random
start_path
=
find_path
(
NetPath
,
start
,
end
)
start_path
=
find_path
(
NetPath
,
start
,
end
)
path
=
[]
path
=
[]
...
@@ -139,32 +132,24 @@ while True:
...
@@ -139,32 +132,24 @@ while True:
path
.
append
(
start_path
[
i
]
+
start_path
[
i
+
1
])
path
.
append
(
start_path
[
i
]
+
start_path
[
i
+
1
])
except
:
except
:
print
(
"
empty path
"
)
print
(
"
empty path
"
)
old
=
100
r
,
g
,
b
=
randint
(
0
,
255
),
randint
(
0
,
255
),
randint
(
0
,
255
)
r
,
g
,
b
=
255
,
255
,
255
try
:
try
:
for
a
in
path
:
for
a
in
path
:
data
=
128
data
=
128
for
i
in
NetLights
.
get
(
a
):
for
i
in
NetLights
.
get
(
a
):
r
,
g
,
b
=
255
,
0
,
0
strip
.
setPixelColor
(
i
,
Color
(
r
,
g
,
b
))
strip
.
setPixelColor
(
i
,
Color
(
r
,
g
,
b
))
strip
.
setPixelColor
(
old
,
Color
(
0
,
0
,
0
))
old
=
i
strip
.
show
()
strip
.
show
()
time
.
sleep
(
0.01
)
time
.
sleep
(
0.001
)
strip
.
setPixelColor
(
old
,
Color
(
0
,
0
,
0
))
for
i
in
range
(
0
,
100
):
for
i
in
range
(
0
,
100
):
strip
.
setPixelColor
(
i
,
Color
(
0
,
0
,
0
))
strip
.
setPixelColor
(
i
,
Color
(
0
,
0
,
0
))
strip
.
show
()
strip
.
show
()
#
time.sleep(0.05)
time
.
sleep
(
0.05
)
iter
+=
1
iter
+=
1
except
Exception
as
e
:
except
Exception
as
e
:
print
(
str
(
e
))
print
(
str
(
e
))
x
=
0
x
=
0
print
(
"
ERROR
"
)
print
(
"
ERROR
"
)
except
Exception
as
e
:
conn
.
close
()
pass
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment