From 2acf2f60f3acffd99e42ac3dfe71720f8bb99048 Mon Sep 17 00:00:00 2001 From: "beville@gmail.com" Date: Tue, 11 Dec 2012 17:57:26 +0000 Subject: [PATCH] Explicitly set the working folder for rar exe commands git-svn-id: http://comictagger.googlecode.com/svn/trunk@247 6c5673fe-1810-88d6-992b-cd32ca31540c --- comicarchive.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/comicarchive.py b/comicarchive.py index 527532e..6f09c21 100644 --- a/comicarchive.py +++ b/comicarchive.py @@ -243,8 +243,10 @@ class RarArchiver: f.write( comment ) f.close() + working_dir = os.path.dirname( os.path.abspath( self.path ) ) + # use external program to write comment to Rar archive - subprocess.call([self.rar_exe_path, 'c', '-c-', '-z' + tmp_name, self.path], + subprocess.call([self.rar_exe_path, 'c', '-w' + working_dir , '-c-', '-z' + tmp_name, self.path], startupinfo=self.startupinfo, stdout=self.devnull) @@ -276,13 +278,17 @@ class RarArchiver: tmp_folder = tempfile.mkdtemp() tmp_file = os.path.join( tmp_folder, archive_file ) + + working_dir = os.path.dirname( os.path.abspath( self.path ) ) + # TODO: will this break if 'archive_file' is in a subfolder. i.e. "foo/bar.txt" + # will need to create the subfolder above, I guess... f = open(tmp_file, 'w') f.write( data ) f.close() - + # use external program to write file to Rar archive - subprocess.call([self.rar_exe_path, 'a', '-c-', '-ep', self.path, tmp_file], + subprocess.call([self.rar_exe_path, 'a', '-w' + working_dir ,'-c-', '-ep', self.path, tmp_file], startupinfo=self.startupinfo, stdout=self.devnull)