Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
VAServerLauncher
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LuFG VR VIS
VR-Group
VAServerLauncher
Commits
81f8c60f
Commit
81f8c60f
authored
Oct 15, 2021
by
vr-group
Browse files
Options
Downloads
Plain Diff
Merge branch 'feature/LauncherScriptFileReceiving'
parents
69cf8338
b76d1102
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
LaunchScript/VirtualAcousticsStarterServer.py
+196
-142
196 additions, 142 deletions
LaunchScript/VirtualAcousticsStarterServer.py
with
196 additions
and
142 deletions
LaunchScript/VirtualAcousticsStarterServer.py
+
196
−
142
View file @
81f8c60f
...
@@ -147,9 +147,63 @@ try:
...
@@ -147,9 +147,63 @@ try:
while
bContinue
:
while
bContinue
:
try
:
try
:
sResult
=
oConnection
.
recv
(
128
)
sResult
=
oConnection
.
recv
(
128
)
if
sResult
!=
""
:
print
(
"
Received quit event
"
)
if
sResult
!=
''
:
#check whether we are about to reveive a file
sMessage
=
sResult
.
decode
(
"
utf-8
"
)
if
sMessage
.
startswith
(
"
file
"
):
aMessageParts
=
sMessage
.
split
(
"
:
"
)
iBytesToReceive
=
int
(
aMessageParts
[
2
])
Path
,
Filename
=
os
.
path
.
split
(
aMessageParts
[
1
])
ProjectName
=
aMessageParts
[
3
]
Fullpath
=
os
.
path
.
join
(
sCurrentScriptsDirectory
,
"
..
"
,
"
tmp
"
,
ProjectName
,
Path
,
""
)
print
(
"
Should receive file:
"
+
Filename
+
"
in path
"
+
Fullpath
+
"
with
"
+
str
(
iBytesToReceive
)
+
"
bytes
"
)
#check whether the file with this exact size already exists
if
os
.
path
.
isfile
(
Fullpath
+
Filename
)
and
os
.
stat
(
Fullpath
+
Filename
).
st_size
==
iBytesToReceive
:
oConnection
.
send
(
b
'
exists
'
)
print
(
"
File already exists with this size, so no need for resending
"
)
else
:
#file need to be received
#create dir if it does not exist
if
not
os
.
path
.
exists
(
Fullpath
):
os
.
makedirs
(
Fullpath
)
#send acceptance
oConnection
.
send
(
b
'
ack
'
)
#print("Send ack")
#receive file
iBytesReceived
=
0
with
open
(
Fullpath
+
Filename
,
"
wb
"
)
as
f
:
bReceivingFile
=
True
while
bReceivingFile
:
# read 1024 bytes from the socket (receive)
bytes_read
=
oConnection
.
recv
(
1024
)
#print("Read 1024 bytes")
if
not
bytes_read
:
# nothing is received
# file transmitting is done
bReceivingFile
=
False
else
:
# write to the file the bytes we just received
f
.
write
(
bytes_read
)
iBytesReceived
+=
len
(
bytes_read
)
if
iBytesReceived
==
iBytesToReceive
:
bReceivingFile
=
False
f
.
close
()
#check whether received file seems ok
if
iBytesReceived
==
iBytesToReceive
:
oConnection
.
send
(
b
'
ack
'
)
#send acceptance
print
(
"
File received successfully
"
)
else
:
oConnection
.
send
(
b
'
fail
'
)
#send failure
print
(
"
File receive failed
"
)
else
:
#NOT sMessage.startswith("file")
print
(
"
Received quit event:
"
+
sMessage
)
bContinue
=
False
bContinue
=
False
except
socket
.
timeout
:
except
socket
.
timeout
:
bContinue
=
True
# timeouts are okay
bContinue
=
True
# timeouts are okay
except
socket
.
error
:
except
socket
.
error
:
...
...
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