diff --git a/bots/cron_file_helper.py b/bots/cron_file_helper.py index b61609c..96713b4 100644 --- a/bots/cron_file_helper.py +++ b/bots/cron_file_helper.py @@ -10,7 +10,7 @@ def nagios_from_file(results_file): This file is created by various nagios checking cron jobs such as check-rabbitmq-queues and check-rabbitmq-consumers""" - data = file(results_file).read().strip() + data = open(results_file).read().strip() pieces = data.split('|') if not len(pieces) == 4: diff --git a/bots/jabber_mirror_backend.py b/bots/jabber_mirror_backend.py index a418ac0..09c07ec 100755 --- a/bots/jabber_mirror_backend.py +++ b/bots/jabber_mirror_backend.py @@ -376,7 +376,7 @@ option does not affect login credentials.'''.replace("\n", " ")) config = SafeConfigParser() try: - with file(config_file, 'r') as f: + with open(config_file, 'r') as f: config.readfp(f, config_file) except IOError: pass diff --git a/bots/process_ccache b/bots/process_ccache index 89363b6..04a7265 100755 --- a/bots/process_ccache +++ b/bots/process_ccache @@ -9,7 +9,7 @@ ccache_data_encoded = sys.argv[3] # Update the Kerberos ticket cache file program_name = "zmirror-%s" % (short_user,) -with file("/home/zulip/ccache/%s" % (program_name,), "w") as f: +with open("/home/zulip/ccache/%s" % (program_name,), "w") as f: f.write(base64.b64decode(ccache_data_encoded)) # Setup API key diff --git a/bots/zephyr_mirror_backend.py b/bots/zephyr_mirror_backend.py index 8c5bf3b..ee57c1b 100755 --- a/bots/zephyr_mirror_backend.py +++ b/bots/zephyr_mirror_backend.py @@ -191,7 +191,7 @@ def zephyr_bulk_subscribe(subs): def update_subscriptions(): try: - f = file(options.stream_file_path, "r") + f = open(options.stream_file_path, "r") public_streams = simplejson.loads(f.read()) f.close() except: @@ -287,7 +287,7 @@ def parse_zephyr_body(zephyr_data): def parse_crypt_table(zephyr_class, instance): try: - crypt_table = file(os.path.join(os.environ["HOME"], ".crypt-table")) + crypt_table = open(os.path.join(os.environ["HOME"], ".crypt-table")) except IOError: return None @@ -349,7 +349,7 @@ def process_notice(notice, log): if zephyr_class == options.nagios_class: # Mark that we got the message and proceed - with file(options.nagios_path, "w") as f: + with open(options.nagios_path, "w") as f: f.write("0\n") return @@ -468,7 +468,7 @@ def zephyr_load_session_autoretry(session_path): backoff = zulip.RandomExponentialBackoff() while backoff.keep_going(): try: - session = file(session_path, "r").read() + session = open(session_path, "r").read() zephyr._z.initialize() zephyr._z.load_session(session) zephyr.__inited = True @@ -510,7 +510,7 @@ def zephyr_to_zulip(options): if options.nagios_class: zephyr_subscribe_autoretry((options.nagios_class, "*", "*")) if options.use_sessions: - file(options.session_path, "w").write(zephyr._z.dump_session()) + open(options.session_path, "w").write(zephyr._z.dump_session()) if options.logs_to_resend is not None: with open(options.logs_to_resend, 'r') as log: @@ -857,7 +857,7 @@ def parse_zephyr_subs(verbose=False): logger.error("Couldn't find ~/.zephyr.subs!") return [] - for line in file(subs_file, "r").readlines(): + for line in open(subs_file, "r").readlines(): line = line.strip() if len(line) == 0: continue @@ -1050,7 +1050,7 @@ Could not find API key file. You need to either place your api key file at %s, or specify the --api-key-file option.""" % (options.api_key_file,)))) sys.exit(1) - api_key = file(options.api_key_file).read().strip() + api_key = open(options.api_key_file).read().strip() # Store the API key in the environment so that our children # don't need to read it in os.environ["HUMBUG_API_KEY"] = api_key diff --git a/zulip/__init__.py b/zulip/__init__.py index 3de8ba8..a3a3317 100644 --- a/zulip/__init__.py +++ b/zulip/__init__.py @@ -164,7 +164,7 @@ class Client(object): config_file = get_default_config_filename() if os.path.exists(config_file): config = SafeConfigParser() - with file(config_file, 'r') as f: + with open(config_file, 'r') as f: config.readfp(f, config_file) if api_key is None: api_key = config.get("api", "key")