From ec6539a6cf12fac752a9c69400e67e66ade131df Mon Sep 17 00:00:00 2001 From: Yovarni Yearwood Date: Wed, 18 Sep 2019 22:03:09 -0400 Subject: [PATCH] Added win32api module to allow for long path names Windows has a 260 character limit on directory paths. The win32api module was installed and imported to allow for computers running Windows OS to bypass that limitation, as ComicRN was not able to move or rename files with a long file path. --- post-processing/autoProcessComics.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/post-processing/autoProcessComics.py b/post-processing/autoProcessComics.py index 44f9a1d2..b23df8e8 100644 --- a/post-processing/autoProcessComics.py +++ b/post-processing/autoProcessComics.py @@ -3,14 +3,26 @@ import os.path import ConfigParser import urllib2 import urllib +import platform + try: import requests use_requests = True except ImportError: - print "Requests module not found on system. I'll revert so this will work, but you probably should install " - print "requests to bypass this in the future (ie. pip install requests)" + print '''Requests module not found on system. I'll revert so this will work, but you probably should install + requests to bypass this in the future (i.e. pip install requests)''' use_requests = False +if platform.system() == 'Windows': + try: + import win32api + use_win32api = True + except ImportError: + print '''The win32api module was not found on this system. While it's fine to run without it, you're + running a Windows-based OS, so it would benefit you to install it. It enables ComicRN to better + work with file paths beyond the 260 character limit. Run "pip install pypiwin32".''' + + apc_version = "2.04" def processEpisode(dirName, nzbName=None): @@ -18,6 +30,8 @@ def processEpisode(dirName, nzbName=None): return processIssue(dirName, nzbName) def processIssue(dirName, nzbName=None, failed=False, comicrn_version=None): + if use_win32api is True: + dirName = win32api.GetShortPathName(dirName) config = ConfigParser.ConfigParser() configFilename = os.path.join(os.path.dirname(sys.argv[0]), "autoProcessComics.cfg")