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