Merge pull request #1317 from akshgpt7/chore-refactor-issues

Refactor code quality issues
This commit is contained in:
Micah Lee 2021-04-11 11:37:42 -07:00 committed by GitHub
commit a08a12d855
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 38 additions and 97 deletions

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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:

View file

@ -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

View file

@ -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

View file

@ -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 (

View file

@ -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

View file

@ -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"

View file

@ -1,12 +1,10 @@
import contextlib
import inspect
import io
import os
import random
import re
import socket
import sys
import zipfile
import pytest

View file

@ -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