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

@ -43,4 +43,4 @@ def main():
if __name__ == "__main__":
main()
main()

View File

@ -211,7 +211,7 @@ def main():
]
print(f"○ Created unsigned installer: {msi_filename}")
print(f"○ Signing installer")
print("○ Signing installer")
run(
[
"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
and hard-code the sha256 hash.
"""
import inspect
import os
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
and hard-code the sha256 hash.
"""
import inspect
import os
import sys
@ -75,7 +74,7 @@ def main():
"e",
"-y",
exe_path,
"Browser\TorBrowser\Tor",
"Browser\\TorBrowser\\Tor",
"-o%s" % os.path.join(working_path, "Tor"),
]
).wait()
@ -85,7 +84,7 @@ def main():
"e",
"-y",
exe_path,
"Browser\TorBrowser\Data\Tor\geoip*",
"Browser\\TorBrowser\\Data\\Tor\\geoip*",
"-o%s" % os.path.join(working_path, "Data"),
]
).wait()

View File

@ -21,7 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
from __future__ import division
import os
import sys
import platform
import argparse
import signal
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/>.
"""
from PySide2 import QtCore, QtWidgets, QtGui
from PySide2 import QtCore, QtWidgets
from onionshare_cli.common import AutoStopTimer
@ -379,7 +379,7 @@ class Mode(QtWidgets.QWidget):
if self.server_status.status != ServerStatus.STATUS_STOPPED:
try:
self.web.stop(self.app.port)
except:
except Exception:
# Probably we had no port to begin with (Onion service didn't start)
pass
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/>.
"""
import os
import random
import string
from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.onion import *
from onionshare_cli.common import Common
from onionshare_cli.web import Web
from .. import Mode

View File

@ -253,7 +253,7 @@ class ReceiveHistoryItemFile(QtWidgets.QWidget):
try:
# If nautilus is available, open it
subprocess.Popen(["xdg-open", self.dir])
except:
except Exception:
Alert(
self.common,
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.tab_id, strings._("gui_tab_name_chat")
)
elif self.tab_mode == None:
elif self.tab_mode is None:
pass
else:
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
from PySide2 import QtCore, QtWidgets, QtGui
from onionshare_cli.onion import *
from onionshare_cli.common import Common
from onionshare_cli.web import Web
@ -30,7 +29,7 @@ from .. import Mode
from ..file_selection import FileSelection
from ..history import History, ToggleHistory, ShareHistoryItem
from .... import strings
from ....widgets import Alert, MinimumWidthWidget
from ....widgets import MinimumWidthWidget
from ....gui_common import GuiCommon

View File

@ -36,7 +36,7 @@ class CompressThread(QtCore.QThread):
# prepare files to share
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)
def run(self):

View File

@ -19,12 +19,9 @@ 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 onionshare_cli.onion import *
from onionshare_cli.common import Common
from onionshare_cli.web import Web
@ -32,7 +29,7 @@ from .. import Mode
from ..file_selection import FileSelection
from ..history import History, ToggleHistory
from .... import strings
from ....widgets import Alert, MinimumWidthWidget
from ....widgets import MinimumWidthWidget
from ....gui_common import GuiCommon

View File

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

View File

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

View File

@ -166,7 +166,7 @@ class TorConnectionThread(QtCore.QThread):
else:
self.canceled_connecting_to_tor.emit()
except BundledTorCanceled as e:
except BundledTorCanceled:
self.common.log(
"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
import datetime, re
import datetime
import re
import socks
from distutils.version import LooseVersion as Version

View File

@ -25,7 +25,12 @@ version = "2.3.1"
setuptools.setup(
name="onionshare",
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_email="micah@micahflee.com",
maintainer="Micah Lee",

View File

@ -1,20 +1,21 @@
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 shutil
import tempfile
from datetime import datetime, timedelta
import pytest
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
def qWait(t, qtapp):
@ -36,9 +37,6 @@ sys.path.insert(
),
)
from onionshare_cli import common, web, settings
# The temporary directory for CLI tests
test_temp_dir = None
@ -69,7 +67,7 @@ def temp_dir():
@pytest.fixture
def temp_dir_1024(temp_dir):
""" Create a temporary directory that has a single file of a
"""Create a temporary directory that has a single file of a
particular size (1024 bytes).
"""
@ -83,7 +81,7 @@ def temp_dir_1024(temp_dir):
# pytest > 2.9 only needs @pytest.fixture
@pytest.yield_fixture
def temp_dir_1024_delete(temp_dir):
""" Create a temporary directory that has a single file of a
"""Create a temporary directory that has a single file of a
particular size (1024 bytes). The temporary directory (including
the file inside) will be deleted after fixture usage.
"""
@ -97,7 +95,7 @@ def temp_dir_1024_delete(temp_dir):
@pytest.fixture
def temp_file_1024(temp_dir):
""" Create a temporary file of a particular size (1024 bytes). """
"""Create a temporary file of a particular size (1024 bytes)."""
with tempfile.NamedTemporaryFile(delete=False, dir=temp_dir) as tmp_file:
tmp_file.write(b"*" * 1024)
@ -141,7 +139,7 @@ def default_zw():
tmp_dir = os.path.dirname(zw.zip_filename)
try:
shutil.rmtree(tmp_dir, ignore_errors=True)
except:
except Exception:
pass