fix remote_path handling on different os types.

This commit is contained in:
clinton-hall 2014-05-26 16:49:19 +09:30
commit 7ece7997a9
4 changed files with 38 additions and 7 deletions

View file

@ -59,13 +59,20 @@ class autoProcessComics:
replaceExtensions(dirName)
if remote_path:
if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator
remote_path = remote_path + os.path.basename(dirName)
elif remote_path[0] == '/': # posix path
remote_path = remote_path + '/' + os.path.basename(dirName)
else: # assume windows path or UNF path
remote_path = remote_path + '\\' + os.path.basename(dirName)
params = {}
params['apikey'] = apikey
params['cmd'] = "forceProcess"
params['nzb_folder'] = dirName
if remote_path:
params['nzb_folder'] = os.path.join(remote_path, os.path.basename(dirName))
else:
params['nzb_folder'] = dirName
params['nzb_folder'] = remote_path
if inputName != None:
params['nzb_name'] = inputName

View file

@ -145,6 +145,14 @@ class autoProcessMovie:
process_all_exceptions(inputName.lower(), dirName)
inputName, dirName = convert_to_ascii(inputName, dirName)
if remote_path:
if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator
remote_path = remote_path + os.path.basename(dirName)
elif remote_path[0] == '/': # posix path
remote_path = remote_path + '/' + os.path.basename(dirName)
else: # assume windows path or UNF path
remote_path = remote_path + '\\' + os.path.basename(dirName)
if status == 0:
if nzbtomedia.TRANSCODE == 1:
result = transcoder.Transcode_directory(dirName)
@ -165,7 +173,7 @@ class autoProcessMovie:
params['media_folder'] = dirName
if remote_path:
params['media_folder'] = os.path.join(remote_path, os.path.basename(dirName))
params['media_folder'] = remote_path
url = "%s%s" % (baseURL, command)

View file

@ -58,6 +58,14 @@ class autoProcessMusic:
inputName, dirName = convert_to_ascii(inputName, dirName)
if remote_path:
if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator
remote_path = remote_path + os.path.basename(dirName)
elif remote_path[0] == '/': # posix path
remote_path = remote_path + '/' + os.path.basename(dirName)
else: # assume windows path or UNF path
remote_path = remote_path + '\\' + os.path.basename(dirName)
url = "%s%s:%s%s/api" % (protocol,host,port,web_root)
if status == 0:
@ -68,7 +76,7 @@ class autoProcessMusic:
params['dir'] = os.path.dirname(dirName)
if remote_path:
params['dir'] = os.path.join(remote_path, os.path.basename(os.path.dirname(dirName)))
params['dir'] = remote_path
release_status = self.get_status(url, apikey, dirName)
if not release_status:

View file

@ -107,6 +107,14 @@ class autoProcessTV:
status = 1
failed = 1
if remote_path:
if remote_path[-1] in ['\\','/']: # supplied directory includes final directory separator
remote_path = remote_path + os.path.basename(dirName)
elif remote_path[0] == '/': # posix path
remote_path = remote_path + '/' + os.path.basename(dirName)
else: # assume windows path or UNF path
remote_path = remote_path + '\\' + os.path.basename(dirName)
# configure SB params to pass
fork_params['quiet'] = 1
if inputName is not None:
@ -119,7 +127,7 @@ class autoProcessTV:
if param in ["dirName", "dir"]:
fork_params[param] = dirName
if remote_path:
fork_params[param] = os.path.join(remote_path, os.path.basename(dirName))
fork_params[param] = remote_path
if param == "process_method":
if process_method:
@ -163,7 +171,7 @@ class autoProcessTV:
headers = {"X-Api-Key": apikey}
params = {'sortKey': 'series.title', 'page': 1, 'pageSize': 1, 'sortDir': 'asc'}
if remote_path:
data = json.dumps({"name": "DownloadedEpisodesScan", "path": os.path.join(remote_path, os.path.basename(dirName))})
data = json.dumps({"name": "DownloadedEpisodesScan", "path": remote_path})
else:
data = json.dumps({"name": "DownloadedEpisodesScan", "path": dirName})