From 0892ec28e7962c48f6f39ec11700c3873d3043d7 Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Tue, 26 May 2015 13:59:29 -0400 Subject: [PATCH] Use team name instead of [SlackMail] for temporary file paths Signed-off-by: Anna Schumaker --- slackmail.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/slackmail.py b/slackmail.py index 1bc6909..3bb4244 100644 --- a/slackmail.py +++ b/slackmail.py @@ -37,8 +37,10 @@ def call_method_auth(method, args = dict()): # if call_method("api.test")["ok"] == False: sys.exit(1) -if call_method_auth("auth.test")["ok"] == False: +auth = call_method_auth("auth.test") +if auth["ok"] == False: sys.exit(1) +team = auth["team"] @@ -84,15 +86,18 @@ def write_message(fout, message): _write_message(fout, name, message) +tmp_dir = "/tmp/%s" % team +if not os.path.exists(tmp_dir): + os.mkdir(tmp_dir) -os.mkdir("/tmp/slackmail/") for id in list_channel_ids(): channel = find_channel_info(id) if not channel["is_member"]: continue if channel["unread_count"] == 0: continue - fout = open("/tmp/slackmail/%s" % channel["name"], 'w') + + fout = open("%s/%s" % (tmp_dir, channel["name"]), 'w') fout.write(channel["purpose"]["value"].encode("utf-8").decode("latin-1")) fout.write("\n") for message in read_channel(id, channel["last_read"]):