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
*.class
@ -22,4 +26,5 @@
hs_err_pid*
replay_pid*
*.xml
*.pyc
.idea/workspace.xml

17
.idea/workspace.xml generated
View File

@ -2,17 +2,11 @@
<project version="4">
<component name="ChangeListManager">
<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$/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$/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>
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -122,7 +116,8 @@
<workItem from="1666752468427" duration="1563000" />
<workItem from="1667205217155" duration="3357000" />
<workItem from="1667357110859" duration="5735000" />
<workItem from="1667456828218" duration="23547000" />
<workItem from="1667456828218" duration="24361000" />
<workItem from="1667898094682" duration="1203000" />
</task>
<servers />
</component>
@ -145,18 +140,18 @@
<breakpoints>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url>
<line>73</line>
<line>76</line>
<option name="timeStamp" value="1" />
</line-breakpoint>
<line-breakpoint enabled="true" suspend="THREAD" type="python-line">
<url>file://$PROJECT_DIR$/main.py</url>
<line>82</line>
<line>81</line>
<option name="timeStamp" value="3" />
</line-breakpoint>
</breakpoints>
</breakpoint-manager>
</component>
<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>
</project>

Binary file not shown.

View File

@ -8,3 +8,5 @@
127.0.0.1,14,26,B
10.16.33.201,85,88,E
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,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,

29
main.py
View File

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