From: Jason Ish Date: Wed, 6 Dec 2017 18:59:37 +0000 (-0600) Subject: python 3 fixups X-Git-Tag: 1.0.0b1~34 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=404da90bb77ccbb21c6aa150746ddfa1d8e49a96;p=thirdparty%2Fsuricata-update.git python 3 fixups - enable-source - update-sources - setup.py --- diff --git a/setup.py b/setup.py index 351f2bb..99dec9a 100644 --- a/setup.py +++ b/setup.py @@ -8,7 +8,7 @@ def write_revision(): revision = subprocess.check_output( ["git", "rev-parse", "--short", "HEAD"]) with open("./suricata/update/revision.py", "w") as fileobj: - fileobj.write("revision = '%s'" % (revision.strip())) + fileobj.write("revision = '%s'" % (revision.decode().strip())) except Exception as err: print("Failed to get current git revision: %s" % (err)) diff --git a/suricata/update/commands/enablesource.py b/suricata/update/commands/enablesource.py index aa1113c..747edeb 100644 --- a/suricata/update/commands/enablesource.py +++ b/suricata/update/commands/enablesource.py @@ -134,6 +134,6 @@ def write_source_config(config, enabled): filename = sources.get_enabled_source_filename(config.name) else: filename = sources.get_disabled_source_filename(config.name) - with open(filename, "wb") as fileobj: + with open(filename, "w") as fileobj: logger.debug("Writing %s", filename) fileobj.write(yaml.safe_dump(config.dict(), default_flow_style=False)) diff --git a/suricata/update/commands/updatesources.py b/suricata/update/commands/updatesources.py index 0e6c984..1ec8e16 100644 --- a/suricata/update/commands/updatesources.py +++ b/suricata/update/commands/updatesources.py @@ -44,6 +44,6 @@ def update_sources(config): logger.error("Failed to create directory %s: %s", config.get_cache_dir(), err) return 1 - with open(local_index_filename, "w") as outobj: + with open(local_index_filename, "wb") as outobj: outobj.write(fileobj.getvalue()) logger.info("Saved %s", local_index_filename) diff --git a/suricata/update/sources.py b/suricata/update/sources.py index f1e3146..7bb8251 100644 --- a/suricata/update/sources.py +++ b/suricata/update/sources.py @@ -68,7 +68,7 @@ def get_source_index_url(config): return DEFAULT_SOURCE_INDEX_URL def save_source_config(source_config): - with open(get_enabled_source_filename(source_config.name), "wb") as fileobj: + with open(get_enabled_source_filename(source_config.name), "w") as fileobj: fileobj.write(yaml.safe_dump( source_config.dict(), default_flow_style=False))