mirror of
https://github.com/narkoz/hacker-scripts
synced 2025-08-23 02:47:14 +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)
|
||||
)
|
||||
|
||||
try:
|
||||
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()
|
||||
print "Message sent at " + strftime("%a, %d %b %Y %H:%M:%S")
|
||||
|
@ -42,17 +42,4 @@ client.messages.create(
|
||||
body="Late at work. " + random.choice(reasons)
|
||||
)
|
||||
|
||||
try:
|
||||
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()
|
||||
print "Message sent at " + strftime("%a, %d %b %Y %H:%M:%S")
|
||||
|
Loading…
x
Reference in New Issue
Block a user