Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

多分完成かな #9

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
################################################################################
# この .gitignore ファイルは Microsoft(R) Visual Studio によって自動的に作成されました。
################################################################################

/customers.txt
/customers.json
/customers.json
/.vs/config
3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": null
}
Binary file added .vs/slnx.sqlite
Binary file not shown.
Binary file added .vs/syokudou/v15/.suo
Binary file not shown.
25 changes: 24 additions & 1 deletion syokudou_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,31 @@

customers=[]

def save(n):
"""
save
customers.jsonに指定文字列,日付を書き込む
それだけ
"""
r = open('customers.json','a')
r.write(str(n) + ":" + str(datetime.date.today()) + "\n")
r.close()
def load():
"""
load
この関数を呼び出したときと同日にsaveされた記録をすべてcustomerに書き込む
それだけ
"""
r = open('customers.json','r')
for toCust in r.readlines():
if toCust[7:17] == str(datetime.date.today()):
customers.append(toCust[0:6])
r.close()

with socket.socket()as listen_sock:
listen_sock.bind(("",55555))
listen_sock.listen(1)
load()
with open("log.csv","a") as csvfile:
while True:
try:
Expand All @@ -22,10 +44,11 @@
client_sock.sendall("多重利用です!!!!!".encode())
else:
customers.append(student_id)
save(student_id)
client_sock.sendall(b"ok")
else:
client_sock.sendall("不正な学生証です.".encode())
except ConnectionResetError:
print("接続が切断されました.LANケーブル,ハブの電源を確認して下さい.")
except BaseException as ex:
print(ex+"原因不明の例外です.")
print(ex+"原因不明の例外です.")