Skip to content

Commit

Permalink
Apply Python 3 futurize transform libmodernize.fixes.fix_file
Browse files Browse the repository at this point in the history
Refer to zulip#256
  • Loading branch information
sharmaeklavya2 authored and timabbott committed Mar 11, 2016
1 parent e83a2c8 commit d3b63f9
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
10 changes: 5 additions & 5 deletions bots/log2zulip
Expand Up @@ -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, {})
Expand All @@ -79,18 +79,18 @@ 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):
print("Log2zulip lock held; not doing anything")
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()
Expand Down
8 changes: 4 additions & 4 deletions bots/process_ccache
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion bots/sync-public-streams
Expand Up @@ -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()

Expand Down
Expand Up @@ -31,7 +31,7 @@ down_count = 0
for results_file_name in os.listdir(RESULTS_DIR):
this_state = "OK"
results_file = os.path.join(RESULTS_DIR, results_file_name)
data = file(results_file).read().strip()
data = open(results_file).read().strip()
last_check = os.stat(results_file).st_mtime
time_since_last_check = time.time() - last_check
# time_since_last_check threshhold needs to be strictly greater
Expand Down
Expand Up @@ -28,7 +28,7 @@ def report(state, data, last_check):
data))
exit(states[state])

data = file(RESULTS_FILE).read().strip()
data = open(RESULTS_FILE).read().strip()
if data.split("\n")[-1].strip() == "0":
state = "OK"
else:
Expand Down
2 changes: 1 addition & 1 deletion tools/deprecated/inject-messages/inject-messages
Expand Up @@ -87,7 +87,7 @@ def maybe_assign_character(character):
characters[character] = dict(users[user])
characters[character]['intro'] = '(as ' + character.title() + ")\n"

play = file(os.path.dirname(__file__) + os.path.sep + "othello")
play = open(os.path.dirname(__file__) + os.path.sep + "othello")
next_character = None
next_message = ""
act = ""
Expand Down

0 comments on commit d3b63f9

Please sign in to comment.