Skip to content
Permalink
Browse files

Fixed issues with get_latest_screenshot with directory paths different

then my own and handled case with nothing in the screenshot directory
better.
  • Loading branch information...
BradfordBach committed May 25, 2019
1 parent 8102b0c commit 34575363677a195045ebe541ebe036f8e10f5456
Showing with 11 additions and 6 deletions.
  1. +11 −6 NMS_Locator.py
@@ -54,13 +54,18 @@ def get_latest_save_file():

def get_latest_screenshot():
all_screenshot_files = []
exclude = set(["thumbnails"])
for (dirpath, dirnames, filenames) in os.walk(config.get('SETTINGS', 'SCREENSHOT_DIRECTORY')):
for dir in dirnames:
if dir != 'thumbnails':
for file in filenames:
if file[-4:] == ".jpg":
all_screenshot_files.append(os.path.join(dirpath, file))
latest_save = max(all_screenshot_files, key=os.path.getmtime)
dirnames[:] = [d for d in dirnames if d not in exclude]
for file in filenames:
if file[-4:] == ".jpg":
all_screenshot_files.append(os.path.join(dirpath, file))

try:
latest_save = max(all_screenshot_files, key=os.path.getmtime)
except ValueError:
print('No screenshot found in screenshot directory on latest check')
latest_save = None

# if latest file is already cropped it means we've already processed it, so skip it
if os.path.isfile("cropped" + os.sep + os.path.splitext(os.path.basename(file))[0] + "_cropped.png"):

0 comments on commit 3457536

Please sign in to comment.
You can’t perform that action at this time.