Updata .rep output

This commit is contained in:
bigJIU 2022-11-08 17:22:21 +08:00
parent 2c07a85add
commit 302d32c9cd
6 changed files with 30 additions and 26 deletions

5
.gitignore vendored
View File

@ -1,3 +1,7 @@
#self design
/reps
/data
# Compiled class file # Compiled class file
*.class *.class
@ -22,4 +26,5 @@
hs_err_pid* hs_err_pid*
replay_pid* replay_pid*
*.xml *.xml
*.pyc
.idea/workspace.xml .idea/workspace.xml

17
.idea/workspace.xml generated
View File

@ -2,17 +2,11 @@
<project version="4"> <project version="4">
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment=""> <list default="true" id="c32bfd4e-6189-47f3-9d6c-c1825d3d7e5f" name="Changes" comment="">
<change beforePath="$PROJECT_DIR$/.gitignore" beforeDir="false" afterPath="$PROJECT_DIR$/.gitignore" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/annotation.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/annotation.csv" afterDir="false" /> <change beforePath="$PROJECT_DIR$/data/annotation.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/annotation.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/data/questionare.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/questionare.csv" afterDir="false" /> <change beforePath="$PROJECT_DIR$/data/questionare.csv" beforeDir="false" afterPath="$PROJECT_DIR$/data/questionare.csv" afterDir="false" />
<change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" /> <change beforePath="$PROJECT_DIR$/main.py" beforeDir="false" afterPath="$PROJECT_DIR$/main.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/reps/127.0.0.1lvl3066.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/reps/127.0.0.1lvl6866.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/reps/127.0.0.1lvl6966.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/reps/127.0.0.1lvl7966.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/reps/127.0.0.1lvl8366.txt" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameAnnotation.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameAnnotation.html" afterDir="false" />
<change beforePath="$PROJECT_DIR$/templates/GameQuestion.html" beforeDir="false" afterPath="$PROJECT_DIR$/templates/GameQuestion.html" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -122,7 +116,8 @@
<workItem from="1666752468427" duration="1563000" /> <workItem from="1666752468427" duration="1563000" />
<workItem from="1667205217155" duration="3357000" /> <workItem from="1667205217155" duration="3357000" />
<workItem from="1667357110859" duration="5735000" /> <workItem from="1667357110859" duration="5735000" />
<workItem from="1667456828218" duration="23547000" /> <workItem from="1667456828218" duration="24361000" />
<workItem from="1667898094682" duration="1203000" />
</task> </task>
<servers /> <servers />
</component> </component>
@ -145,18 +140,18 @@
<breakpoints> <breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url> <url>file://$PROJECT_DIR$/main.py</url>
<line>73</line> <line>76</line>
<option name="timeStamp" value="1" /> <option name="timeStamp" value="1" />
</line-breakpoint> </line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line"> <line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url> <url>file://$PROJECT_DIR$/main.py</url>
<line>82</line> <line>81</line>
<option name="timeStamp" value="3" /> <option name="timeStamp" value="3" />
</line-breakpoint> </line-breakpoint>
</breakpoints> </breakpoints>
</breakpoint-manager> </breakpoint-manager>
</component> </component>
<component name="com.intellij.coverage.CoverageDataManagerImpl"> <component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1667490705213" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" /> <SUITE FILE_PATH="coverage/MarioWeb$Flask__main_py_.coverage" NAME="Flask (main.py) Coverage Results" MODIFIED="1667898938796" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="" />
</component> </component>
</project> </project>

Binary file not shown.

View File

@ -8,3 +8,5 @@
127.0.0.1,14,26,B 127.0.0.1,14,26,B
10.16.33.201,85,88,E 10.16.33.201,85,88,E
10.16.33.201,28,73,A 10.16.33.201,28,73,A
10.27.169.251,160,10,N
10.27.169.251,143,173,N

1 127.0.0.1 a b anno
8 127.0.0.1 14 26 B
9 10.16.33.201 85 88 E
10 10.16.33.201 28 73 A
11 10.27.169.251 160 10 N
12 10.27.169.251 143 173 N

View File

@ -29,3 +29,6 @@ IP,Style,Frequency,Age,Gender
10.16.33.201,B,C,B,A, 10.16.33.201,B,C,B,A,
10.16.33.201,A,A,A,, 10.16.33.201,A,A,A,,
10.16.33.201,A,A,A,, 10.16.33.201,A,A,A,,
10.27.169.251,D,E,G,C,
127.0.0.1,,A,,,
127.0.0.1,A,A,A,B,

1 IP,Style,Frequency,Age,Gender
29 10.16.33.201,B,C,B,A,
30 10.16.33.201,A,A,A,,
31 10.16.33.201,A,A,A,,
32 10.27.169.251,D,E,G,C,
33 127.0.0.1,,A,,,
34 127.0.0.1,A,A,A,B,

23
main.py
View File

@ -1,5 +1,6 @@
import json import json
import os import os
import struct
from IDManager import idManager from IDManager import idManager
@ -41,10 +42,12 @@ def gamepreplay():
print(result.get("gamestyle")) print(result.get("gamestyle"))
return redirect(url_for('gameplay', id=ip)) return redirect(url_for('gameplay', id=ip))
@app.route('/again') @app.route('/again')
def gamepreplayAgain(): def gamepreplayAgain():
return redirect(url_for('gameplay', id=request.remote_addr)) return redirect(url_for('gameplay', id=request.remote_addr))
@app.route('/') @app.route('/')
def gamequestion(): def gamequestion():
return render_template('GameQuestion.html') return render_template('GameQuestion.html')
@ -71,16 +74,12 @@ def gameanno(id):
def getJSONData(id): def getJSONData(id):
if request.method == 'POST': if request.method == 'POST':
print("POST Game") print("POST Game")
print(request.form) # print(request.form)
print(list(request.form)) # print(list(request.form))
resultList = list(request.form)[0].split(",") resultList = list(request.form)[0].split(",")
for i,j in request.form.items():
print(i)
print(j)
# FIXME: SAVING IN TXT
# FIXME: NOT SAVING! saveFile(replayDataPath, id + resultList[0], resultList[1:])
saveFile(replayDataPath, id+resultList[0] , str(resultList[1:]))
return "get!" return "get!"
@ -99,11 +98,11 @@ def getRadioData():
def saveFile(path, filename, content): def saveFile(path, filename, content):
cp = list(map(int, content))
file_dir = os.path.join(os.getcwd(), path) file_dir = os.path.join(os.getcwd(), path)
file_path = os.path.join(file_dir, filename + ".txt") file_path = os.path.join(file_dir, filename + ".rep")
f = open(file_path, "w", encoding="utf8") with open(file_path, 'wb') as f:
f.write(content) f.write(b''.join(struct.pack('B', c) for c in cp))
f.close()
if __name__ == '__main__': if __name__ == '__main__':