Permalink
Browse files

MB-6411: Create zip working dir under system temp directory

Instead of using the current working directory such as bin or
/opt/couchbase/lib/python, use system temp directory.

Change-Id: Ie2452df0581f5f3659d1deab856e7092037c68fb
Reviewed-on: http://review.couchbase.org/20141
Reviewed-by: Steve Yen <steve.yen@gmail.com>
Tested-by: Bin Cui <bin.cui@gmail.com>
  • Loading branch information...
1 parent 250c194 commit c22674bf046016b2bcf851b7d88fbf1e75a77d8e @bcui6611 bcui6611 committed Aug 24, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 cbdocloader
View
@@ -8,7 +8,8 @@ import os
import os.path
import shutil
import simplejson as json
-from tempfile import TemporaryFile
+import tempfile
+
from optparse import OptionParser
from couchbase import client
@@ -118,7 +119,11 @@ class DocLoader:
def unzip_file_and_upload(self):
zfobj = zipfile.ZipFile(self.args[0])
- working_dir = os.path.join(os.path.dirname(sys.argv[0]), '_working')
+ tmpdir = tempfile.gettempdir()
+ working_dir = os.path.join(tmpdir, '_working')
+ if not os.path.exists(working_dir):
+ os.makedirs(working_dir)
+
zfobj.extractall(working_dir)
self.enumerate_and_save(working_dir)
shutil.rmtree(working_dir)

0 comments on commit c22674b

Please sign in to comment.