Skip to content

Commit b53dc5d

Browse files
roberthoenigtimabbott
authored andcommitted
log2zulip: Make paths Windows compatible.
1 parent 761d4f4 commit b53dc5d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

zulip/integrations/log2zulip/log2zulip

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import re
99
import sys
1010
import shutil
1111
import subprocess
12+
import tempfile
1213
import traceback
1314

1415
try:
@@ -24,7 +25,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../"))
2425
import zulip
2526
from typing import List
2627

27-
lock_path = "/var/tmp/log2zulip.lock"
28+
temp_dir = "/var/tmp/" if os.name == "posix" else tempfile.gettempdir()
2829

2930
def mkdir_p(path):
3031
# type: (str) -> None
@@ -66,7 +67,7 @@ def process_lines(raw_lines, file_name):
6667
def process_logs():
6768
# type: () -> None
6869
for filename in log_files:
69-
data_file_path = "/var/tmp/log2zulip.state"
70+
data_file_path = os.path.join(temp_dir, "log2zulip.state")
7071
mkdir_p(os.path.dirname(data_file_path))
7172
if not os.path.exists(data_file_path):
7273
open(data_file_path, "w").write("{}")
@@ -103,6 +104,7 @@ if __name__ == "__main__":
103104
if not args.zulip_config_file and os.name == "posix":
104105
args.zulip_config_file = "/etc/log2zulip.zuliprc"
105106

107+
lock_path = os.path.join(temp_dir, "log2zulip.lock")
106108
if os.path.exists(lock_path):
107109
print("Log2zulip lock held; not doing anything")
108110
sys.exit(0)

0 commit comments

Comments
 (0)