mirror of
https://github.com/narkoz/hacker-scripts
synced 2025-08-23 19:07:33 +00:00
Merge pull request #41 from WKPlus/master
use with instead of file open and close
This commit is contained in:
commit
47e8900c37
@ -41,17 +41,4 @@ client.messages.create(
|
|||||||
body="Gonna work from home. " + random.choice(excuses)
|
body="Gonna work from home. " + random.choice(excuses)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
print "Message sent at " + strftime("%a, %d %b %Y %H:%M:%S")
|
||||||
f = open('logs/file.txt', 'a')
|
|
||||||
except IOError as e:
|
|
||||||
# dir & file don't exist; create them
|
|
||||||
os.mkdir('logs')
|
|
||||||
f = open('logs/file.txt', 'a')
|
|
||||||
except Exception as e:
|
|
||||||
print e
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# log it
|
|
||||||
f.write("Message sent at " + strftime("%a, %d %b %Y %H:%M:%S") + "\n")
|
|
||||||
f.close()
|
|
||||||
|
@ -42,17 +42,4 @@ client.messages.create(
|
|||||||
body="Late at work. " + random.choice(reasons)
|
body="Late at work. " + random.choice(reasons)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
print "Message sent at " + strftime("%a, %d %b %Y %H:%M:%S")
|
||||||
f = open('logs/file.txt', 'a')
|
|
||||||
except IOError as e:
|
|
||||||
# dir & file don't exist; create them
|
|
||||||
os.mkdir('logs')
|
|
||||||
f = open('logs/file.txt', 'a')
|
|
||||||
except Exception as e:
|
|
||||||
print e
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
|
|
||||||
# log it
|
|
||||||
f.write("Message sent at " + strftime("%a, %d %b %Y %H:%M:%S") + "\n")
|
|
||||||
f.close()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user