mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Merge pull request #1317 from akshgpt7/chore-refactor-issues
Refactor code quality issues
This commit is contained in:
commit
a08a12d855
19
.deepsource.toml
Normal file
19
.deepsource.toml
Normal file
@ -0,0 +1,19 @@
|
||||
version = 1
|
||||
|
||||
test_patterns = [
|
||||
"desktop/tests/**",
|
||||
"cli/tests/**"
|
||||
]
|
||||
|
||||
exclude_patterns = [
|
||||
"snap/**",
|
||||
"licenses/**",
|
||||
"flatpak/**"
|
||||
]
|
||||
|
||||
[[analyzers]]
|
||||
name = "python"
|
||||
enabled = true
|
||||
|
||||
[analyzers.meta]
|
||||
runtime_version = "3.x.x"
|
@ -514,8 +514,7 @@ def main(cwd=None):
|
||||
print("Stopped because auto-stop timer ran out")
|
||||
web.stop(app.port)
|
||||
break
|
||||
else:
|
||||
web.receive_mode.can_upload = False
|
||||
web.receive_mode.can_upload = False
|
||||
# Allow KeyboardInterrupt exception to be handled with threads
|
||||
# https://stackoverflow.com/questions/3788208/python-threading-ignores-keyboardinterrupt-exception
|
||||
time.sleep(0.2)
|
||||
|
@ -19,13 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
import base64
|
||||
import hashlib
|
||||
import inspect
|
||||
import os
|
||||
import platform
|
||||
import random
|
||||
import socket
|
||||
import sys
|
||||
import tempfile
|
||||
import threading
|
||||
import time
|
||||
import shutil
|
||||
|
@ -28,11 +28,9 @@ import tempfile
|
||||
import subprocess
|
||||
import time
|
||||
import shlex
|
||||
import getpass
|
||||
import psutil
|
||||
|
||||
from distutils.version import LooseVersion as Version
|
||||
from .settings import Settings
|
||||
|
||||
|
||||
class TorErrorAutomatic(Exception):
|
||||
@ -518,13 +516,12 @@ class Onion(object):
|
||||
self.settings.get("control_port_address"),
|
||||
self.settings.get("control_port_port"),
|
||||
)
|
||||
else:
|
||||
print(
|
||||
"Can't connect to the Tor controller using socket file {}.".format(
|
||||
self.settings.get("socket_file_path")
|
||||
)
|
||||
print(
|
||||
"Can't connect to the Tor controller using socket file {}.".format(
|
||||
self.settings.get("socket_file_path")
|
||||
)
|
||||
raise TorErrorSocketFile(self.settings.get("socket_file_path"))
|
||||
)
|
||||
raise TorErrorSocketFile(self.settings.get("socket_file_path"))
|
||||
|
||||
# Try authenticating
|
||||
try:
|
||||
@ -755,7 +752,7 @@ class Onion(object):
|
||||
):
|
||||
rendezvous_circuit_ids.append(c.id)
|
||||
|
||||
symbols = [c for c in "\\|/-"]
|
||||
symbols = list("\\|/-")
|
||||
symbols_i = 0
|
||||
|
||||
while True:
|
||||
@ -837,9 +834,6 @@ class Onion(object):
|
||||
# Import the key
|
||||
key = RSA.importKey(base64.b64decode(key))
|
||||
# Is this a v2 Onion key? (1024 bits) If so, we should keep using it.
|
||||
if key.n.bit_length() == 1024:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
return key.n.bit_length() == 1024
|
||||
except:
|
||||
return False
|
||||
|
@ -19,8 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import os, shutil
|
||||
|
||||
from . import common
|
||||
from .common import AutoStopTimer
|
||||
|
||||
|
||||
|
@ -20,7 +20,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import json
|
||||
import os
|
||||
import platform
|
||||
import locale
|
||||
|
||||
try:
|
||||
|
@ -19,15 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from flask import (
|
||||
Request,
|
||||
request,
|
||||
render_template,
|
||||
make_response,
|
||||
jsonify,
|
||||
redirect,
|
||||
session,
|
||||
)
|
||||
from werkzeug.utils import secure_filename
|
||||
session)
|
||||
from flask_socketio import emit, join_room, leave_room
|
||||
|
||||
|
||||
|
@ -23,7 +23,7 @@ import sys
|
||||
import tempfile
|
||||
import mimetypes
|
||||
import gzip
|
||||
from flask import Response, request, render_template, make_response
|
||||
from flask import Response, request
|
||||
from unidecode import unidecode
|
||||
from werkzeug.urls import url_quote
|
||||
|
||||
|
@ -17,17 +17,11 @@ 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 hmac
|
||||
import logging
|
||||
import os
|
||||
import queue
|
||||
import socket
|
||||
import sys
|
||||
import tempfile
|
||||
import requests
|
||||
from distutils.version import LooseVersion as Version
|
||||
from urllib.request import urlopen
|
||||
|
||||
import flask
|
||||
from flask import (
|
||||
|
@ -19,10 +19,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import tempfile
|
||||
import mimetypes
|
||||
from flask import Response, request, render_template, make_response
|
||||
from flask import render_template, make_response
|
||||
|
||||
from .send_base_mode import SendBaseModeWeb
|
||||
|
||||
|
@ -18,11 +18,6 @@ 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/>.
|
||||
"""
|
||||
|
||||
# snap and flatpak packaging uses setup.py
|
||||
# PyPi publishing, developing, and testing uses poetry
|
||||
|
||||
import os
|
||||
import setuptools
|
||||
|
||||
version = "2.3.1"
|
||||
|
@ -1,12 +1,10 @@
|
||||
import contextlib
|
||||
import inspect
|
||||
import io
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import zipfile
|
||||
|
||||
import pytest
|
||||
|
||||
|
@ -1,11 +1,6 @@
|
||||
import contextlib
|
||||
import inspect
|
||||
import io
|
||||
import os
|
||||
import random
|
||||
import re
|
||||
import socket
|
||||
import sys
|
||||
import zipfile
|
||||
import tempfile
|
||||
import base64
|
||||
|
@ -2,7 +2,6 @@
|
||||
import os
|
||||
import inspect
|
||||
import subprocess
|
||||
import argparse
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
|
@ -2,7 +2,6 @@
|
||||
import os
|
||||
import inspect
|
||||
import subprocess
|
||||
import argparse
|
||||
import shutil
|
||||
import glob
|
||||
|
||||
|
@ -105,11 +105,10 @@ def main():
|
||||
if src[quote_i] == '"':
|
||||
quote = '"'
|
||||
break
|
||||
elif src[quote_i] == "'":
|
||||
if src[quote_i] == "'":
|
||||
quote = "'"
|
||||
break
|
||||
else:
|
||||
inc += 1
|
||||
inc += 1
|
||||
|
||||
# find the starting quote
|
||||
starting_i = src.find(quote, starting_i)
|
||||
|
@ -29,8 +29,6 @@ import inspect
|
||||
import os
|
||||
import sys
|
||||
import hashlib
|
||||
import zipfile
|
||||
import io
|
||||
import shutil
|
||||
import subprocess
|
||||
import requests
|
||||
|
@ -6,7 +6,6 @@ and installs it in the virtual environment.
|
||||
|
||||
import inspect
|
||||
import os
|
||||
import sys
|
||||
import glob
|
||||
import subprocess
|
||||
import shutil
|
||||
|
@ -19,7 +19,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
import os
|
||||
import inspect
|
||||
import shutil
|
||||
from pkg_resources import resource_filename
|
||||
|
||||
|
@ -21,8 +21,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import time
|
||||
from PySide2 import QtCore, QtWidgets, QtGui
|
||||
|
||||
from onionshare_cli.web import Web
|
||||
|
||||
from . import strings
|
||||
from .tor_connection_dialog import TorConnectionDialog
|
||||
from .settings_dialog import SettingsDialog
|
||||
|
@ -24,8 +24,6 @@ import platform
|
||||
import datetime
|
||||
import re
|
||||
import os
|
||||
|
||||
from onionshare_cli import common
|
||||
from onionshare_cli.settings import Settings
|
||||
from onionshare_cli.onion import (
|
||||
Onion,
|
||||
@ -47,11 +45,7 @@ from onionshare_cli.onion import (
|
||||
from . import strings
|
||||
from .widgets import Alert
|
||||
from .update_checker import (
|
||||
UpdateCheckerCheckError,
|
||||
UpdateCheckerInvalidLatestVersion,
|
||||
UpdateChecker,
|
||||
UpdateThread,
|
||||
)
|
||||
UpdateThread)
|
||||
from .tor_connection_dialog import TorConnectionDialog
|
||||
from .gui_common import GuiCommon
|
||||
|
||||
|
@ -18,7 +18,6 @@ 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 json
|
||||
import locale
|
||||
import os
|
||||
|
||||
strings = {}
|
||||
|
@ -17,8 +17,6 @@ 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 platform
|
||||
import textwrap
|
||||
from PySide2 import QtCore, QtWidgets, QtGui
|
||||
from PySide2.QtCore import Qt
|
||||
|
@ -158,14 +158,14 @@ class AutoStartTimer(QtCore.QThread):
|
||||
)
|
||||
try:
|
||||
# Sleep until scheduled time
|
||||
while autostart_timer_datetime_delta > 0 and self.canceled == False:
|
||||
while autostart_timer_datetime_delta > 0 and self.canceled is False:
|
||||
time.sleep(0.1)
|
||||
now = QtCore.QDateTime.currentDateTime()
|
||||
autostart_timer_datetime_delta = now.secsTo(
|
||||
self.mode.server_status.autostart_timer_datetime
|
||||
)
|
||||
# Timer has now finished
|
||||
if self.canceled == False:
|
||||
if self.canceled is False:
|
||||
self.mode.server_status.server_button.setText(
|
||||
strings._("gui_please_wait")
|
||||
)
|
||||
|
@ -19,14 +19,11 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
"""
|
||||
|
||||
from PySide2 import QtCore
|
||||
import datetime, time, socket, re, platform
|
||||
import datetime, re
|
||||
import socks
|
||||
from distutils.version import LooseVersion as Version
|
||||
|
||||
from onionshare_cli.settings import Settings
|
||||
from onionshare_cli.onion import Onion
|
||||
|
||||
from . import strings
|
||||
|
||||
|
||||
class UpdateCheckerCheckError(Exception):
|
||||
|
@ -18,11 +18,6 @@ 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/>.
|
||||
"""
|
||||
|
||||
# This setup.py file is used for snap and flatpak packaging. For other packaging,
|
||||
# OnionShare uses briefcase.
|
||||
|
||||
import os
|
||||
import setuptools
|
||||
|
||||
version = "2.3.1"
|
||||
|
@ -13,7 +13,7 @@ from datetime import datetime, timedelta
|
||||
|
||||
import pytest
|
||||
|
||||
from PySide2 import QtTest, QtGui
|
||||
from PySide2 import QtTest
|
||||
|
||||
|
||||
@staticmethod
|
||||
|
@ -1,11 +1,7 @@
|
||||
import pytest
|
||||
import unittest
|
||||
|
||||
import json
|
||||
import os
|
||||
import requests
|
||||
import shutil
|
||||
import base64
|
||||
import tempfile
|
||||
import secrets
|
||||
import platform
|
||||
@ -13,9 +9,6 @@ import platform
|
||||
from PySide2 import QtCore, QtTest, QtWidgets
|
||||
|
||||
from onionshare_cli.common import Common
|
||||
from onionshare_cli.settings import Settings
|
||||
from onionshare_cli.onion import Onion
|
||||
from onionshare_cli.web import Web
|
||||
|
||||
from onionshare import Application, MainWindow, GuiCommon
|
||||
from onionshare.tab.mode.share_mode import ShareMode
|
||||
|
@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import os
|
||||
import requests
|
||||
import tempfile
|
||||
|
@ -1,4 +1,3 @@
|
||||
import pytest
|
||||
import os
|
||||
|
||||
from PySide2 import QtCore, QtTest, QtWidgets
|
||||
|
@ -1,10 +1,6 @@
|
||||
import pytest
|
||||
import os
|
||||
import requests
|
||||
import shutil
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
from PySide2 import QtCore, QtTest
|
||||
from PySide2 import QtTest
|
||||
|
||||
from .gui_base_test import GuiBaseTest
|
||||
|
||||
|
@ -1,5 +1,3 @@
|
||||
import sphinx_rtd_theme
|
||||
import sphinx_intl
|
||||
|
||||
|
||||
project = "OnionShare"
|
||||
|
Loading…
Reference in New Issue
Block a user