[Pkg-privacy-commits] [torbrowser-launcher] 22/39: Fix flake8 style issues
Roger Shimizu
rosh at debian.org
Tue Mar 27 15:41:52 UTC 2018
This is an automated email from the git hooks/post-receive script.
rosh pushed a commit to branch rosh/experimental
in repository torbrowser-launcher.
commit df33b47382ced0b40345b47a7f01d1cae1efca34
Author: Micah Lee <micah at micahflee.com>
Date: Fri Mar 23 13:36:37 2018 -0700
Fix flake8 style issues
---
torbrowser_launcher/__init__.py | 5 ++-
torbrowser_launcher/common.py | 96 +++++++++++++++--------------------------
torbrowser_launcher/launcher.py | 50 ++++++++++++---------
torbrowser_launcher/settings.py | 1 +
4 files changed, 67 insertions(+), 85 deletions(-)
diff --git a/torbrowser_launcher/__init__.py b/torbrowser_launcher/__init__.py
index 0f99d05..b507da0 100644
--- a/torbrowser_launcher/__init__.py
+++ b/torbrowser_launcher/__init__.py
@@ -71,13 +71,14 @@ def main():
if settings:
# Settings mode
- gui = Settings(common, app)
+ Settings(common, app)
else:
# Launcher mode
- gui = Launcher(common, app, url_list)
+ Launcher(common, app, url_list)
sys.exit(app.exec_())
+
if __name__ == "__main__":
main()
diff --git a/torbrowser_launcher/common.py b/torbrowser_launcher/common.py
index abf8628..4f579ee 100644
--- a/torbrowser_launcher/common.py
+++ b/torbrowser_launcher/common.py
@@ -34,16 +34,11 @@ import locale
import pickle
import json
import re
-
-try:
- import gpg
- gpgme_support = True
-except ImportError:
- gpgme_support = False
+import gettext
+import gpg
SHARE = os.getenv('TBL_SHARE', sys.prefix+'/share/torbrowser-launcher')
-import gettext
gettext.install('torbrowser-launcher')
# We're looking for output which:
@@ -71,13 +66,6 @@ class Common(object):
self.mkdir(self.paths['tbb']['dir'])
self.init_gnupg()
- # allow buttons to have icons
- try:
- gtk_settings = gtk.settings_get_default()
- gtk_settings.props.gtk_button_images = True
- except:
- pass
-
# discover the architecture and language
def discover_arch_lang(self):
# figure out the architecture
@@ -129,17 +117,17 @@ class Common(object):
language = 'en-US'
else:
language = self.language
- tarball_filename = 'tor-browser-'+arch+'-'+tbb_version+'_'+language+'.tar.xz'
+ tarball_filename = 'tor-browser-' + arch + '-' + tbb_version + '_' + language + '.tar.xz'
# tarball
- self.paths['tarball_url'] = '{0}torbrowser/'+tbb_version+'/'+tarball_filename
- self.paths['tarball_file'] = tbb_cache+'/download/'+tarball_filename
+ self.paths['tarball_url'] = '{0}torbrowser/' + tbb_version + '/' + tarball_filename
+ self.paths['tarball_file'] = tbb_cache + '/download/' + tarball_filename
self.paths['tarball_filename'] = tarball_filename
# sig
- self.paths['sig_url'] = '{0}torbrowser/'+tbb_version+'/'+tarball_filename+'.asc'
- self.paths['sig_file'] = tbb_cache+'/download/'+tarball_filename+'.asc'
- self.paths['sig_filename'] = tarball_filename+'.asc'
+ self.paths['sig_url'] = '{0}torbrowser/' + tbb_version + '/' + tarball_filename + '.asc'
+ self.paths['sig_file'] = tbb_cache + '/download/' + tarball_filename + '.asc'
+ self.paths['sig_filename'] = tarball_filename + '.asc'
else:
self.paths = {
'dirs': {
@@ -156,18 +144,20 @@ class Common(object):
'tor_browser_developers': os.path.join(SHARE, 'tor-browser-developers.asc')
},
'mirrors_txt': [os.path.join(SHARE, 'mirrors.txt'),
- tbb_config+'/mirrors.txt'],
- 'download_dir': tbb_cache+'/download',
- 'gnupg_homedir': tbb_local+'/gnupg_homedir',
- 'settings_file': tbb_config+'/settings.json',
- 'settings_file_pickle': tbb_config+'/settings',
+ tbb_config + '/mirrors.txt'],
+ 'download_dir': tbb_cache + '/download',
+ 'gnupg_homedir': tbb_local + '/gnupg_homedir',
+ 'settings_file': tbb_config + '/settings.json',
+ 'settings_file_pickle': tbb_config + '/settings',
'version_check_url': 'https://aus1.torproject.org/torbrowser/update_3/release/Linux_x86_64-gcc3/x/en-US',
- 'version_check_file': tbb_cache+'/download/release.xml',
+ 'version_check_file': tbb_cache + '/download/release.xml',
'tbb': {
- 'changelog': tbb_local+'/tbb/'+self.architecture+'/tor-browser_'+self.language+'/Browser/TorBrowser/Docs/ChangeLog.txt',
- 'dir': tbb_local+'/tbb/'+self.architecture,
- 'dir_tbb': tbb_local+'/tbb/'+self.architecture+'/tor-browser_'+self.language,
- 'start': tbb_local+'/tbb/'+self.architecture+'/tor-browser_'+self.language+'/start-tor-browser.desktop',
+ 'changelog': tbb_local + '/tbb/' + self.architecture + '/tor-browser_' +
+ self.language + '/Browser/TorBrowser/Docs/ChangeLog.txt',
+ 'dir': tbb_local + '/tbb/' + self.architecture,
+ 'dir_tbb': tbb_local + '/tbb/' + self.architecture + '/tor-browser_' + self.language,
+ 'start': tbb_local + '/tbb/' + self.architecture + '/tor-browser_' +
+ self.language + '/start-tor-browser.desktop'
},
}
@@ -233,38 +223,20 @@ class Common(object):
:returns: ``True`` if the key is now within the keyring (or was
previously and hasn't changed). ``False`` otherwise.
"""
- if gpgme_support:
- with gpg.Context() as c:
- c.set_engine_info(gpg.constants.protocol.OpenPGP, home_dir=self.paths['gnupg_homedir'])
-
- impkey = self.paths['signing_keys'][key]
- try:
- c.op_import(gpg.Data(file=impkey))
- except:
- return False
+ with gpg.Context() as c:
+ c.set_engine_info(gpg.constants.protocol.OpenPGP, home_dir=self.paths['gnupg_homedir'])
+
+ impkey = self.paths['signing_keys'][key]
+ try:
+ c.op_import(gpg.Data(file=impkey))
+ except:
+ return False
+ else:
+ result = c.op_import_result()
+ if result and self.fingerprints[key] in result.imports[0].fpr:
+ return True
else:
- result = c.op_import_result()
- if result and self.fingerprints[key] in result.imports[0].fpr:
- return True
- else:
- return False
- else:
- success = False
-
- p = subprocess.Popen(['/usr/bin/gpg', '--status-fd', '2',
- '--homedir', self.paths['gnupg_homedir'],
- '--import', self.paths['signing_keys'][key]],
- stderr=subprocess.PIPE)
- p.wait()
-
- for output in p.stderr.readlines():
- match = gnupg_import_ok_pattern.match(output)
- if match:
- if match.group().find(self.fingerprints[key]) >= 0:
- success = True
- break
-
- return success
+ return False
# import gpg keys
def import_keys(self):
@@ -273,7 +245,7 @@ class Common(object):
:returns: ``True`` if all keys were successfully imported; ``False``
otherwise.
"""
- keys = ['tor_browser_developers',]
+ keys = ['tor_browser_developers', ]
all_imports_succeeded = True
for key in keys:
diff --git a/torbrowser_launcher/launcher.py b/torbrowser_launcher/launcher.py
index c058b70..37fff94 100644
--- a/torbrowser_launcher/launcher.py
+++ b/torbrowser_launcher/launcher.py
@@ -29,15 +29,10 @@ OTHER DEALINGS IN THE SOFTWARE.
import os
import subprocess
import time
-import json
import tarfile
-import hashlib
import lzma
-import threading
import re
-import unicodedata
import requests
-import socks
import gpg
import xml.etree.ElementTree as ET
@@ -86,18 +81,19 @@ class Launcher(QtWidgets.QMainWindow):
if not self.common.settings['installed']:
download_message = _("Downloading and installing Tor Browser for the first time.")
elif not self.check_min_version():
- download_message = _("Your version of Tor Browser is out-of-date. Downloading and installing the newest version.")
+ download_message = _("Your version of Tor Browser is out-of-date. "
+ "Downloading and installing the newest version.")
# Download and install
print(download_message)
self.set_state('task', download_message,
- ['download_version_check',
- 'set_version',
- 'download_sig',
- 'download_tarball',
- 'verify',
- 'extract',
- 'run'])
+ ['download_version_check',
+ 'set_version',
+ 'download_sig',
+ 'download_tarball',
+ 'verify',
+ 'extract',
+ 'run'])
if self.common.settings['download_over_tor']:
print(_('Downloading over Tor'))
@@ -364,7 +360,7 @@ class Launcher(QtWidgets.QMainWindow):
sigerror = 'SIGNATURE VERIFICATION FAILED!\n\nError Code: {0}\n\nYou might be under attack, there might' \
' be a network\nproblem, or you may be missing a recently added\nTor Browser verification key.' \
'\nClick Start to refresh the keyring and try again. If the message persists report the above' \
- ' error code here:\nhttps://github.com/micahflee/torbrowser-launcher/issues'.format(sigerror)
+ ' error code here:\nhttps://github.com/micahflee/torbrowser-launcher/issues'.format(message)
self.set_state('task', sigerror, ['start_over'], False)
self.update()
@@ -386,7 +382,11 @@ class Launcher(QtWidgets.QMainWindow):
self.run_task()
def error(message):
- self.set_state('task', _("Tor Browser Launcher doesn't understand the file format of {0}".format(self.common.paths['tarball_file'])), ['start_over'], False)
+ self.set_state(
+ 'task',
+ _("Tor Browser Launcher doesn't understand the file format of {0}".format(self.common.paths['tarball_file'])),
+ ['start_over'], False
+ )
self.update()
t = ExtractThread(self.common)
@@ -501,13 +501,18 @@ class DownloadThread(QtCore.QThread):
if self.common.settings['mirror'] != self.common.default_mirror:
message = (_("Download Error:") +
" {0}\n\n" + _("You are currently using a non-default mirror") +
- ":\n{1}\n\n" + _("Would you like to switch back to the default?")).format(r.status_code, self.common.settings['mirror'])
+ ":\n{1}\n\n" + _("Would you like to switch back to the default?")).format(
+ r.status_code, self.common.settings['mirror']
+ )
self.download_error.emit('error_try_default_mirror', message)
# Should we switch to English?
elif self.common.language != 'en-US' and not self.common.settings['force_en-US']:
message = (_("Download Error:") +
- " {0}\n\n" + _("Would you like to try the English version of Tor Browser instead?")).format(r.status_code)
+ " {0}\n\n" +
+ _("Would you like to try the English version of Tor Browser instead?")).format(
+ r.status_code
+ )
self.download_error.emit('error_try_forcing_english', message)
else:
@@ -526,21 +531,24 @@ class DownloadThread(QtCore.QThread):
self.progress_update.emit(total_bytes, bytes_so_far)
except requests.exceptions.SSLError:
+ message = _('Invalid SSL certificate for:\n{0}\n\nYou may be under attack.').format(self.url.decode())
if not self.common.settings['download_over_tor']:
- message = _('Invalid SSL certificate for:\n{0}\n\nYou may be under attack.').format(self.url.decode()) + "\n\n" + _('Try the download again using Tor?')
+ message += "\n\n" + _('Try the download again using Tor?')
self.download_error.emit('error_try_tor', message)
else:
- message = _('Invalid SSL certificate for:\n{0}\n\nYou may be under attack.'.format(self.url.decode()))
self.download_error.emit('error', message)
return
except requests.exceptions.ConnectionError:
# Connection error
if self.common.settings['download_over_tor']:
- message = _("Error starting download:\n\n{0}\n\nTrying to download over Tor. Are you sure Tor is configured correctly and running?").format(self.url.decode())
+ message = _("Error starting download:\n\n{0}\n\nTrying to download over Tor. "
+ "Are you sure Tor is configured correctly and running?").format(self.url.decode())
self.download_error.emit('error', message)
else:
- message = _("Error starting download:\n\n{0}\n\nAre you connected to the internet?").format(self.url.decode())
+ message = _("Error starting download:\n\n{0}\n\nAre you connected to the internet?").format(
+ self.url.decode()
+ )
self.download_error.emit('error', message)
return
diff --git a/torbrowser_launcher/settings.py b/torbrowser_launcher/settings.py
index 5b8ec58..e344b11 100644
--- a/torbrowser_launcher/settings.py
+++ b/torbrowser_launcher/settings.py
@@ -31,6 +31,7 @@ import shutil
from PyQt5 import QtCore, QtWidgets, QtGui
+
class Settings(QtWidgets.QMainWindow):
"""
Settings window.
--
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