Fix flake8 warnings in desktop

This commit is contained in:
Micah Lee 2021-04-30 11:38:23 -07:00
parent 0a6056e5e6
commit b51c0ee046
No known key found for this signature in database
GPG Key ID: 403C2657CD994F73
18 changed files with 35 additions and 44 deletions

View File

@ -211,7 +211,7 @@ def main():
] ]
print(f"○ Created unsigned installer: {msi_filename}") print(f"○ Created unsigned installer: {msi_filename}")
print(f"○ Signing installer") print("○ Signing installer")
run( run(
[ [
"signtool.exe", "signtool.exe",

View File

@ -24,7 +24,6 @@ This script downloads a pre-built tor binary to bundle with OnionShare.
In order to avoid a Mac gnupg dependency, I manually verify the signature In order to avoid a Mac gnupg dependency, I manually verify the signature
and hard-code the sha256 hash. and hard-code the sha256 hash.
""" """
import inspect import inspect
import os import os
import sys import sys

View File

@ -23,7 +23,6 @@ This script downloads a pre-built tor binary to bundle with OnionShare.
In order to avoid a Windows gnupg dependency, I manually verify the signature In order to avoid a Windows gnupg dependency, I manually verify the signature
and hard-code the sha256 hash. and hard-code the sha256 hash.
""" """
import inspect import inspect
import os import os
import sys import sys
@ -75,7 +74,7 @@ def main():
"e", "e",
"-y", "-y",
exe_path, exe_path,
"Browser\TorBrowser\Tor", "Browser\\TorBrowser\\Tor",
"-o%s" % os.path.join(working_path, "Tor"), "-o%s" % os.path.join(working_path, "Tor"),
] ]
).wait() ).wait()
@ -85,7 +84,7 @@ def main():
"e", "e",
"-y", "-y",
exe_path, exe_path,
"Browser\TorBrowser\Data\Tor\geoip*", "Browser\\TorBrowser\\Data\\Tor\\geoip*",
"-o%s" % os.path.join(working_path, "Data"), "-o%s" % os.path.join(working_path, "Data"),
] ]
).wait() ).wait()

View File

@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import division from __future__ import division
import os import os
import sys import sys
import platform
import argparse import argparse
import signal import signal
import json import json

View File

@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
from PySide2 import QtCore, QtWidgets, QtGui from PySide2 import QtCore, QtWidgets
from onionshare_cli.common import AutoStopTimer from onionshare_cli.common import AutoStopTimer
@ -379,7 +379,7 @@ class Mode(QtWidgets.QWidget):
if self.server_status.status != ServerStatus.STATUS_STOPPED: if self.server_status.status != ServerStatus.STATUS_STOPPED:
try: try:
self.web.stop(self.app.port) self.web.stop(self.app.port)
except: except Exception:
# Probably we had no port to begin with (Onion service didn't start) # Probably we had no port to begin with (Onion service didn't start)
pass pass
self.app.cleanup() self.app.cleanup()

View File

@ -18,14 +18,8 @@ You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import os
import random
import string
from PySide2 import QtCore, QtWidgets, QtGui from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.onion import *
from onionshare_cli.common import Common
from onionshare_cli.web import Web from onionshare_cli.web import Web
from .. import Mode from .. import Mode

View File

@ -253,7 +253,7 @@ class ReceiveHistoryItemFile(QtWidgets.QWidget):
try: try:
# If nautilus is available, open it # If nautilus is available, open it
subprocess.Popen(["xdg-open", self.dir]) subprocess.Popen(["xdg-open", self.dir])
except: except Exception:
Alert( Alert(
self.common, self.common,
strings._("gui_open_folder_error").format(abs_filename), strings._("gui_open_folder_error").format(abs_filename),

View File

@ -234,7 +234,7 @@ class ModeSettingsWidget(QtWidgets.QWidget):
self.tab.change_title.emit( self.tab.change_title.emit(
self.tab.tab_id, strings._("gui_tab_name_chat") self.tab.tab_id, strings._("gui_tab_name_chat")
) )
elif self.tab_mode == None: elif self.tab_mode is None:
pass pass
else: else:
title = self.title_lineedit.text() title = self.title_lineedit.text()

View File

@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
import os import os
from PySide2 import QtCore, QtWidgets, QtGui from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.onion import *
from onionshare_cli.common import Common from onionshare_cli.common import Common
from onionshare_cli.web import Web from onionshare_cli.web import Web
@ -30,7 +29,7 @@ from .. import Mode
from ..file_selection import FileSelection from ..file_selection import FileSelection
from ..history import History, ToggleHistory, ShareHistoryItem from ..history import History, ToggleHistory, ShareHistoryItem
from .... import strings from .... import strings
from ....widgets import Alert, MinimumWidthWidget from ....widgets import MinimumWidthWidget
from ....gui_common import GuiCommon from ....gui_common import GuiCommon

View File

@ -36,7 +36,7 @@ class CompressThread(QtCore.QThread):
# prepare files to share # prepare files to share
def set_processed_size(self, x): def set_processed_size(self, x):
if self.mode._zip_progress_bar != None: if self.mode._zip_progress_bar is not None:
self.mode._zip_progress_bar.update_processed_size_signal.emit(x) self.mode._zip_progress_bar.update_processed_size_signal.emit(x)
def run(self): def run(self):

View File

@ -19,12 +19,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import os import os
import random
import string
from PySide2 import QtCore, QtWidgets, QtGui from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.onion import *
from onionshare_cli.common import Common from onionshare_cli.common import Common
from onionshare_cli.web import Web from onionshare_cli.web import Web
@ -32,7 +29,7 @@ from .. import Mode
from ..file_selection import FileSelection from ..file_selection import FileSelection
from ..history import History, ToggleHistory from ..history import History, ToggleHistory
from .... import strings from .... import strings
from ....widgets import Alert, MinimumWidthWidget from ....widgets import MinimumWidthWidget
from ....gui_common import GuiCommon from ....gui_common import GuiCommon

View File

@ -161,7 +161,7 @@ class ServerStatus(QtWidgets.QWidget):
self.url.setText(wrapped_onion_url) self.url.setText(wrapped_onion_url)
else: else:
self.url.setText(self.get_url()) self.url.setText(self.get_url())
except: except Exception:
pass pass
def show_url(self): def show_url(self):

View File

@ -252,7 +252,7 @@ class EventHandlerThread(QtCore.QThread):
"EventHandler", "run", f"invalid event type: {obj}" "EventHandler", "run", f"invalid event type: {obj}"
) )
except: except Exception:
pass pass
if self.should_quit: if self.should_quit:

View File

@ -166,7 +166,7 @@ class TorConnectionThread(QtCore.QThread):
else: else:
self.canceled_connecting_to_tor.emit() self.canceled_connecting_to_tor.emit()
except BundledTorCanceled as e: except BundledTorCanceled:
self.common.log( self.common.log(
"TorConnectionThread", "run", "caught exception: BundledTorCanceled" "TorConnectionThread", "run", "caught exception: BundledTorCanceled"
) )

View File

@ -19,7 +19,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
from PySide2 import QtCore from PySide2 import QtCore
import datetime, re import datetime
import re
import socks import socks
from distutils.version import LooseVersion as Version from distutils.version import LooseVersion as Version

View File

@ -25,7 +25,12 @@ version = "2.3.1"
setuptools.setup( setuptools.setup(
name="onionshare", name="onionshare",
version=version, version=version,
description="OnionShare lets you securely and anonymously send and receive files. It works by starting a web server, making it accessible as a Tor onion service, and generating an unguessable web address so others can download files from you, or upload files to you. It does _not_ require setting up a separate server or using a third party file-sharing service.", description=(
"OnionShare lets you securely and anonymously send and receive files. It works by starting a web "
"server, making it accessible as a Tor onion service, and generating an unguessable web address so "
"others can download files from you, or upload files to you. It does _not_ require setting up a "
"separate server or using a third party file-sharing service."
),
author="Micah Lee", author="Micah Lee",
author_email="micah@micahflee.com", author_email="micah@micahflee.com",
maintainer="Micah Lee", maintainer="Micah Lee",

View File

@ -1,20 +1,21 @@
import sys import sys
# Force tests to look for resources in the source code tree
sys.onionshare_dev_mode = True
# Let OnionShare know the tests are running, to avoid colliding with settings files
sys.onionshare_test_mode = True
import os import os
import shutil import shutil
import tempfile import tempfile
from datetime import datetime, timedelta from datetime import datetime, timedelta
import pytest import pytest
from PySide2 import QtTest from PySide2 import QtTest
from onionshare_cli import common, web, settings
# Force tests to look for resources in the source code tree
sys.onionshare_dev_mode = True
# Let OnionShare know the tests are running, to avoid colliding with settings files
sys.onionshare_test_mode = True
@staticmethod @staticmethod
def qWait(t, qtapp): def qWait(t, qtapp):
@ -36,9 +37,6 @@ sys.path.insert(
), ),
) )
from onionshare_cli import common, web, settings
# The temporary directory for CLI tests # The temporary directory for CLI tests
test_temp_dir = None test_temp_dir = None
@ -141,7 +139,7 @@ def default_zw():
tmp_dir = os.path.dirname(zw.zip_filename) tmp_dir = os.path.dirname(zw.zip_filename)
try: try:
shutil.rmtree(tmp_dir, ignore_errors=True) shutil.rmtree(tmp_dir, ignore_errors=True)
except: except Exception:
pass pass