diff --git a/CHANGELOG.md b/CHANGELOG.md
index 78b25e2..63b209b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -18,7 +18,7 @@ Date (Timezone) | Version | Comment
07/18/2019 04:14:32 AM (PDT) | 0.1.9 | Merge the test cases from the [Pull request #5 "add set_tags_batch, set_tags + constructor takes added options"](https://github.com/smarnach/pyexiftool/pull/5) by [halloleo](https://github.com/halloleo) on Aug 1, 2012
07/18/2019 04:34:46 AM (PDT) | 0.3.0 | changed the setup.py licensing and updated the version numbering as in changelog
changed the version number scheme, as it appears the "official last release" was 0.2.0 tagged. There's going to be a lot of things broken in this current build, and I'll fix it as they come up. I'm going to start playing with the library and the included tests and such.
There's one more pull request #11 which would be pending, but it duplicates the extra arguments option.
I'm also likely to remove the print conversion as it's now covered by the extra args. I'll also rename some variable names with the addedargs patch
**for my changes (sylikc), I can only guarantee they will work on Python 3.7, because that's my environment... and while I'll try to maintain compatibility, there's no guarantees**
07/18/2019 05:06:19 AM (PDT) | 0.3.1 | make some minor tweaks to the naming of the extra args variable. The other pull request 11 names them params, and when I decide how to merge that pull request, I'll probably change the variable names again.
-
+07/19/2019 12:01:22 AM (PTD) | 0.3.2 | fix the select() problem for windows, and fix all tests
# Changes around the web
diff --git a/exiftool.py b/exiftool.py
index be67cf4..ebae68d 100644
--- a/exiftool.py
+++ b/exiftool.py
@@ -294,18 +294,23 @@ def execute(self, *params):
if not self.running:
raise ValueError("ExifTool instance not running.")
cmd_text = b"\n".join(params + (b"-execute\n",))
- self._process.stdin.write(cmd_text.encode("utf-8")) # a commit reverted this to the original where it's not encoded in UTF-8, will see if there are conflicts later
+ # cmd_text.encode("utf-8") # a commit put this in the next line, but i can't get it to work TODO
+ # might look at something like this https://stackoverflow.com/questions/7585435/best-way-to-convert-string-to-bytes-in-python-3
+ self._process.stdin.write(cmd_text)
self._process.stdin.flush()
output = b""
fd = self._process.stdout.fileno()
while not output[-32:].strip().endswith(sentinel):
- #output += os.read(fd, block_size)
-
- # not sure if this works on windows
- inputready,outputready,exceptready = select.select([fd],[],[])
- for i in inputready:
- if i == fd:
- output += os.read(fd, block_size)
+ if sys.platform == 'win32':
+ # windows does not support select() for anything except sockets
+ # https://docs.python.org/3.7/library/select.html
+ output += os.read(fd, block_size)
+ else:
+ # this does NOT work on windows... and it may not work on other systems... in that case, put more things to use the original code above
+ inputready,outputready,exceptready = select.select([fd],[],[])
+ for i in inputready:
+ if i == fd:
+ output += os.read(fd, block_size)
return output.strip()[:-len(sentinel)]
def execute_json(self, *params):
@@ -486,7 +491,8 @@ def set_keywords_batch(self, mode, keywords, filenames):
raise TypeError("The argument 'filenames' must be "
"an iterable of strings")
- params = []
+ params = []
+ params_utf8 = []
kw_operation = {KW_REPLACE:"-%s=%s",
KW_ADD:"-%s+=%s",
@@ -497,7 +503,9 @@ def set_keywords_batch(self, mode, keywords, filenames):
params.extend(kw_params)
params.extend(filenames)
logging.debug (params)
- return self.execute(*params)
+
+ params_utf8 = [x.encode('utf-8') for x in params]
+ return self.execute(*params_utf8)
def set_keywords(self, mode, keywords, filename):
"""Modifies the keywords tag for the given file.
diff --git a/test/test_exiftool.py b/test/test_exiftool.py
index 37094c9..83059c4 100644
--- a/test/test_exiftool.py
+++ b/test/test_exiftool.py
@@ -10,7 +10,7 @@
class TestExifTool(unittest.TestCase):
def setUp(self):
- self.et = exiftool.ExifTool(addedargs=["-overwrite_original"])
+ self.et = exiftool.ExifTool(added_args=["-overwrite_original"])
def tearDown(self):
if hasattr(self, "et"):
self.et.terminate()