[Pkg-privacy-commits] [torbrowser-launcher] 08/21: Switch settings file from pickle format to json (fixes #201)

Holger Levsen holger at moszumanska.debian.org
Fri Nov 13 17:54:01 UTC 2015


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

holger pushed a commit to annotated tag debian/0.2.1-1
in repository torbrowser-launcher.

commit 3aaab8d0a2960a1f859483da0bbecceeb0b6b10d
Author: Micah Lee <micah at micahflee.com>
Date:   Thu Nov 5 18:13:57 2015 -0800

    Switch settings file from pickle format to json (fixes #201)
---
 torbrowser_launcher/common.py | 30 ++++++++++++------------------
 1 file changed, 12 insertions(+), 18 deletions(-)

diff --git a/torbrowser_launcher/common.py b/torbrowser_launcher/common.py
index e5844b9..b3685a9 100644
--- a/torbrowser_launcher/common.py
+++ b/torbrowser_launcher/common.py
@@ -26,7 +26,7 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 """
 
-import os, sys, platform, subprocess, locale, pickle, psutil
+import os, sys, platform, subprocess, locale, pickle, json, psutil
 
 import pygtk
 pygtk.require('2.0')
@@ -139,7 +139,8 @@ class Common:
                 'modem_sound': os.path.join(SHARE, 'modem.ogg'),
                 'download_dir': tbb_cache+'/download',
                 'gnupg_homedir': tbb_local+'/gnupg_homedir',
-                'settings_file': tbb_config+'/settings',
+                'settings_file': tbb_config+'/settings.json',
+                'settings_file_pickle': tbb_config+'/settings',
                 'update_check_url': 'https://www.torproject.org/projects/torbrowser/RecommendedTBBVersions',
                 'update_check_file': tbb_cache+'/download/RecommendedTBBVersions',
                 'tbb': {
@@ -201,23 +202,9 @@ class Common:
         }
 
         if os.path.isfile(self.paths['settings_file']):
-            settings = pickle.load(open(self.paths['settings_file']))
+            settings = json.load(open(self.paths['settings_file']))
             resave = False
 
-            # settings migrations
-            if settings['tbl_version'] <= '0.1.0':
-                print '0.1.0 migration'
-                settings['installed_version'] = settings['installed_version']['stable']
-                settings['latest_version'] = settings['latest_version']['stable']
-                resave = True
-
-                # make new tbb folder
-                self.mkdir(self.paths['tbb']['dir'])
-                old_tbb_dir = self.paths['old_data_dir']+'/tbb/stable/'+self.architecture+'/tor-browser_'+self.language
-                new_tbb_dir = self.paths['tbb']['dir']+'/tor-browser_'+self.language
-                if os.path.isdir(old_tbb_dir):
-                    os.rename(old_tbb_dir, new_tbb_dir)
-
             # make sure settings file is up-to-date
             for setting in default_settings:
                 if setting not in settings:
@@ -233,13 +220,20 @@ class Common:
             if resave:
                 self.save_settings()
 
+        # if settings file is still using old pickle format, convert to json
+        elif os.path.isfile(self.paths['settings_file_pickle']):
+            self.settings = pickle.load(open(self.paths['settings_file_pickle']))
+            self.save_settings()
+            os.remove(self.paths['settings_file_pickle'])
+            self.load_settings()
+
         else:
             self.settings = default_settings
             self.save_settings()
 
     # save settings
     def save_settings(self):
-        pickle.dump(self.settings, open(self.paths['settings_file'], 'w'))
+        json.dump(self.settings, open(self.paths['settings_file'], 'w'))
         return True
 
     # get the process id of a program

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/torbrowser-launcher.git



More information about the Pkg-privacy-commits mailing list