log2zulip: Remove unnecessary loop and fix incorrect variable name.

This commit is contained in:
Puneeth Chaganti 2019-06-12 10:40:05 +05:30 committed by Tim Abbott
parent ca1b415a1b
commit 1231da46bf

View file

@ -66,8 +66,7 @@ def process_lines(raw_lines, file_name):
def process_logs(): def process_logs():
# type: () -> None # type: () -> None
for filename in log_files: data_file_path = os.path.join(temp_dir, "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("{}")
@ -91,7 +90,7 @@ def process_logs():
output = subprocess.check_output(["tail", "-n+%s" % (file_data["last"],), log_file]) output = subprocess.check_output(["tail", "-n+%s" % (file_data["last"],), log_file])
new_lines = output.decode('utf-8', errors='replace').split('\n')[:-1] new_lines = output.decode('utf-8', errors='replace').split('\n')[:-1]
if len(new_lines) > 0: if len(new_lines) > 0:
process_lines(new_lines, filename) process_lines(new_lines, log_file)
file_data["last"] += len(new_lines) file_data["last"] += len(new_lines)
new_data[log_file] = file_data new_data[log_file] = file_data
open(data_file_path, "w").write(json.dumps(new_data)) open(data_file_path, "w").write(json.dumps(new_data))