From 7883614d2f5a7adbd4f589ddeecc37ba703cd9cb Mon Sep 17 00:00:00 2001 From: "Desai, Kartikey H" Date: Wed, 9 Jan 2019 08:36:10 -0500 Subject: [PATCH] Fixes #232 --- stix2/datastore/filesystem.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stix2/datastore/filesystem.py b/stix2/datastore/filesystem.py index b4f3d15..27dc45d 100644 --- a/stix2/datastore/filesystem.py +++ b/stix2/datastore/filesystem.py @@ -15,7 +15,7 @@ import six from stix2 import v20, v21 from stix2.base import _STIXBase from stix2.core import parse -from stix2.datastore import DataSink, DataSource, DataStoreMixin +from stix2.datastore import DataSink, DataSource, DataStoreMixin, DataSourceError from stix2.datastore.filters import Filter, FilterSet, apply_common_filters from stix2.utils import format_datetime, get_type_from_id, is_marking @@ -546,7 +546,7 @@ class FileSystemSink(DataSink): # TODO: Better handling of the overwriting case. if os.path.isfile(file_path): - print("Attempted to overwrite file!", file_path, file=sys.stderr) + raise DataSourceError("Attempted to overwrite file (!) at: {}".format(file_path)) else: with io.open(file_path, 'w', encoding=encoding) as f: stix_obj = stix_obj.serialize(pretty=True, encoding=encoding, ensure_ascii=False)