log2zulip: Make paths Windows compatible.
This commit is contained in:
parent
761d4f44c1
commit
b53dc5de4c
|
@ -9,6 +9,7 @@ import re
|
||||||
import sys
|
import sys
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
|
import tempfile
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -24,7 +25,7 @@ sys.path.insert(0, os.path.join(os.path.dirname(__file__), "../../"))
|
||||||
import zulip
|
import zulip
|
||||||
from typing import List
|
from typing import List
|
||||||
|
|
||||||
lock_path = "/var/tmp/log2zulip.lock"
|
temp_dir = "/var/tmp/" if os.name == "posix" else tempfile.gettempdir()
|
||||||
|
|
||||||
def mkdir_p(path):
|
def mkdir_p(path):
|
||||||
# type: (str) -> None
|
# type: (str) -> None
|
||||||
|
@ -66,7 +67,7 @@ def process_lines(raw_lines, file_name):
|
||||||
def process_logs():
|
def process_logs():
|
||||||
# type: () -> None
|
# type: () -> None
|
||||||
for filename in log_files:
|
for filename in log_files:
|
||||||
data_file_path = "/var/tmp/log2zulip.state"
|
data_file_path = os.path.join(temp_dir, "log2zulip.state")
|
||||||
mkdir_p(os.path.dirname(data_file_path))
|
mkdir_p(os.path.dirname(data_file_path))
|
||||||
if not os.path.exists(data_file_path):
|
if not os.path.exists(data_file_path):
|
||||||
open(data_file_path, "w").write("{}")
|
open(data_file_path, "w").write("{}")
|
||||||
|
@ -103,6 +104,7 @@ if __name__ == "__main__":
|
||||||
if not args.zulip_config_file and os.name == "posix":
|
if not args.zulip_config_file and os.name == "posix":
|
||||||
args.zulip_config_file = "/etc/log2zulip.zuliprc"
|
args.zulip_config_file = "/etc/log2zulip.zuliprc"
|
||||||
|
|
||||||
|
lock_path = os.path.join(temp_dir, "log2zulip.lock")
|
||||||
if os.path.exists(lock_path):
|
if os.path.exists(lock_path):
|
||||||
print("Log2zulip lock held; not doing anything")
|
print("Log2zulip lock held; not doing anything")
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
Loading…
Reference in a new issue