Merge remote-tracking branch 'origin/multiprocess'
authorOliver Matthews <ojm@codersoffortune.net>
Fri, 21 Feb 2020 10:35:24 +0000 (10:35 +0000)
committerOliver Matthews <ojm@codersoffortune.net>
Fri, 21 Feb 2020 10:35:24 +0000 (10:35 +0000)
thingy_grabber.py

index 0a5602f..765b564 100755 (executable)
@@ -243,14 +243,19 @@ class Thing:
                 "bad status code {}  for thing {} - try again later?".format(req.status_code, self.thing_id))
             return
 
-        self.download_dir = os.path.join(base_dir, self.title)
+        self.old_download_dir = os.path.join(base_dir, self.title)
+        self.download_dir = os.path.join(base_dir, "{} - {}".format(self.thing_id, self.title))
 
         logging.debug("Parsing {} ({})".format(self.thing_id, self.title))
 
         if not os.path.exists(self.download_dir):
-            # Not yet downloaded
-            self._parsed = True
-            return
+            if os.path.exists(self.old_download_dir):
+                logging.info("Found previous style download directory. Moving it")
+                copyfile(self.old_download_dir, self.download_dir)
+            else:
+                # Not yet downloaded
+                self._parsed = True
+                return
 
         timestamp_file = os.path.join(self.download_dir, 'timestamp.txt')
         if not os.path.exists(timestamp_file):
@@ -463,6 +468,9 @@ def do_batch(batch_file, download_dir, quick):
     with open(batch_file) as handle:
         for line in handle:
             line = line.strip()
+            if not line:
+                # Skip empty lines
+                continue
             logging.info("Handling instruction {}".format(line))
             command_arr = line.split()
             if command_arr[0] == "thing":