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

Volumeマウントして、そこでデータを一時的に保持します。 #16

Merged
merged 5 commits into from
Jun 13, 2020

Conversation

solWat
Copy link
Member

@solWat solWat commented Jun 11, 2020

LINEの通知がウザすぎたので、その場しのぎですが、差分比較します。

Issue : #1

notify/notify.py Outdated
with open(CONTENT_PATH) as fr:
file_content = fr.read()

if file_content != messege:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if message の中に、if file_content != messege:があるのが気持ち悪い。これ一個にできんじゃないの

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

一個にしました
2bb9be0

@solWat solWat changed the title Volumeマウントして、そこにデータを一時的に保持します。 Volumeマウントして、そこでデータを一時的に保持します。 Jun 11, 2020
notify/notify.py Outdated
Comment on lines 63 to 67
try:
with open(CONTENT_PATH, mode='x') as f:
f.write('')
except FileExistsError:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@solaWat
try , exceptはどういうお気持ちで書いている?
ファイルがない時に88行目でこけないように書いているんかな

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

りかい

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この記事からもらってきました
https://note.nkmk.me/python-file-io-open-with/

むしろファイルがある時にキャッチしてる。

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

僕も先程同じサイトを見ました

@solWat solWat linked an issue Jun 13, 2020 that may be closed by this pull request
notify/notify.py Outdated
Comment on lines 89 to 92
if messege and messege != file_content:
with open(CONTENT_PATH, mode='w') as fw:
fw.write(messege)
PythonNotify(f"@{user}" + messege + day.upper(), TOKEN)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if message の message をなくして 予約なかったら 現在予約なしなどと PythonNotify関数でつぶやいてもらうこと出来る?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

別のissueにしよう

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そうしよう

notify/notify.py Outdated
Comment on lines 63 to 69
try:
with open(CONTENT_PATH, mode='x') as f:
f.write('')
file_content = ''
except FileExistsError:
pass
with open(CONTENT_PATH) as fr:
file_content = fr.read()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

例外キャッチ使わずに
if os.path.isfile(CONTENT_PATH):
with open(CONTENT_PATH) as fr:
file_content = fr.read()
else:
file_content = ""

としていみるのもいいかも

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

そっちもいいね。
import os
を追加しなきゃいけなかったから、やめといた。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

差分があったときだけ通知
2 participants