Apply Python 3 futurize transform libmodernize.fixes.fix_file
Refer to #256
This commit is contained in:
parent
6e69c1447a
commit
ab2692b217
|
@ -56,8 +56,8 @@ def process_logs():
|
|||
data_file_path = "/var/tmp/log2zulip.state"
|
||||
mkdir_p(os.path.dirname(data_file_path))
|
||||
if not os.path.exists(data_file_path):
|
||||
file(data_file_path, "w").write("{}")
|
||||
last_data = ujson.loads(file(data_file_path).read())
|
||||
open(data_file_path, "w").write("{}")
|
||||
last_data = ujson.loads(open(data_file_path).read())
|
||||
new_data = {}
|
||||
for log_file in log_files:
|
||||
file_data = last_data.get(log_file, {})
|
||||
|
@ -79,7 +79,7 @@ def process_logs():
|
|||
process_lines(new_lines, filename)
|
||||
file_data["last"] += len(new_lines)
|
||||
new_data[log_file] = file_data
|
||||
file(data_file_path, "w").write(ujson.dumps(new_data))
|
||||
open(data_file_path, "w").write(ujson.dumps(new_data))
|
||||
|
||||
if __name__ == "__main__":
|
||||
if os.path.exists(lock_path):
|
||||
|
@ -87,10 +87,10 @@ if __name__ == "__main__":
|
|||
sys.exit(0)
|
||||
|
||||
try:
|
||||
file(lock_path, "w").write("1")
|
||||
open(lock_path, "w").write("1")
|
||||
zulip_client = zulip.Client(config_file="/etc/log2zulip.zuliprc")
|
||||
try:
|
||||
log_files = ujson.loads(file(control_path, "r").read())
|
||||
log_files = ujson.loads(open(control_path, "r").read())
|
||||
except Exception:
|
||||
print("Could not load control data from %s" % (control_path,))
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -14,22 +14,22 @@ with open("/home/zulip/ccache/%s" % (program_name,), "w") as f:
|
|||
|
||||
# Setup API key
|
||||
api_key_path = "/home/zulip/api-keys/%s" % (program_name,)
|
||||
file(api_key_path, "w").write(api_key + "\n")
|
||||
open(api_key_path, "w").write(api_key + "\n")
|
||||
|
||||
# Setup supervisord configuration
|
||||
supervisor_path = "/etc/supervisor/conf.d/%s.conf" % (program_name,)
|
||||
template = "/home/zulip/zulip/bots/zmirror_private.conf.template"
|
||||
template_data = file(template).read()
|
||||
template_data = open(template).read()
|
||||
session_path = "/home/zulip/zephyr_sessions/%s" % (program_name,)
|
||||
|
||||
# Preserve mail zephyrs forwarding setting across rewriting the config file
|
||||
|
||||
try:
|
||||
if "--forward-mail-zephyrs" in file(supervisor_path, "r").read():
|
||||
if "--forward-mail-zephyrs" in open(supervisor_path, "r").read():
|
||||
template_data = template_data.replace("--use-sessions", "--use-sessions --forward-mail-zephyrs")
|
||||
except Exception:
|
||||
pass
|
||||
file(supervisor_path, "w").write(template_data.replace("USERNAME", short_user))
|
||||
open(supervisor_path, "w").write(template_data.replace("USERNAME", short_user))
|
||||
|
||||
# Delete your session
|
||||
subprocess.check_call(["rm", "-f", session_path])
|
||||
|
|
|
@ -59,7 +59,7 @@ if __name__ == "__main__":
|
|||
if public_streams is None:
|
||||
continue
|
||||
|
||||
f = file("/home/zulip/public_streams.tmp", "w")
|
||||
f = open("/home/zulip/public_streams.tmp", "w")
|
||||
f.write(simplejson.dumps(list(public_streams)) + "\n")
|
||||
f.close()
|
||||
|
||||
|
|
Loading…
Reference in a new issue