[Pkg-anonymity-tools] [onionshare] 25/57: removed helpers.get_tmp_dir() in favor of tempdir module

Ulrike Uhlig u-guest at moszumanska.debian.org
Tue May 19 18:18:55 UTC 2015


This is an automated email from the git hooks/post-receive script.

u-guest pushed a commit to annotated tag 0.7
in repository onionshare.

commit ee98e1b0242c5cf1ae581ea50967b1127f9dc5a9
Author: Micah Lee <micah at micahflee.com>
Date:   Wed Dec 10 00:50:19 2014 +0000

    removed helpers.get_tmp_dir() in favor of tempdir module
---
 onionshare/helpers.py    | 15 ++-------------
 onionshare/onionshare.py |  4 ++--
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/onionshare/helpers.py b/onionshare/helpers.py
index 210b9d2..08e6af2 100644
--- a/onionshare/helpers.py
+++ b/onionshare/helpers.py
@@ -17,7 +17,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import os, inspect, hashlib, base64, hmac, platform, zipfile
+import os, inspect, hashlib, base64, hmac, platform, zipfile, tempfile
 from itertools import izip
 
 # hack to make unicode filenames work (#141)
@@ -94,23 +94,12 @@ def dir_size(start_path):
     return total_size
 
 
-def get_tmp_dir():
-    if get_platform() == "Windows":
-        if 'Temp' in os.environ:
-            temp = os.environ['Temp'].replace('\\', '/')
-        else:
-            temp = 'C:/tmp'
-    else:
-        temp = '/tmp'
-    return temp
-
-
 class ZipWriter(object):
     def __init__(self, zip_filename=None):
         if zip_filename:
             self.zip_filename = zip_filename
         else:
-            self.zip_filename = '{0}/onionshare_{1}.zip'.format(get_tmp_dir(), random_string(4, 6))
+            self.zip_filename = '{0}/onionshare_{1}.zip'.format(tempfile.mkdtemp(), random_string(4, 6))
 
         self.z = zipfile.ZipFile(self.zip_filename, 'w')
 
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index d7f13fb..55917f1 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -17,7 +17,7 @@ GNU General Public License for more details.
 You should have received a copy of the GNU General Public License
 along with this program.  If not, see <http://www.gnu.org/licenses/>.
 """
-import os, sys, subprocess, time, argparse, inspect, shutil, socket, threading, urllib2
+import os, sys, subprocess, time, argparse, inspect, shutil, socket, threading, urllib2, tempfile
 import socks
 
 from stem.control import Controller
@@ -118,7 +118,7 @@ class OnionShare(object):
 
             else:
                 # come up with a hidden service directory name
-                self.hidserv_dir = '{0}/onionshare_{1}'.format(helpers.get_tmp_dir(), helpers.random_string(8))
+                self.hidserv_dir = tempfile.mkdtemp()
                 self.cleanup_filenames.append(self.hidserv_dir)
 
                 # connect to the tor controlport

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/onionshare.git



More information about the Pkg-anonymity-tools mailing list