mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Add log() method to onionshare.common, which logs to stdout if in debug mode
This commit is contained in:
parent
1591888863
commit
7003349873
@ -56,6 +56,11 @@ def main(cwd=None):
|
||||
stay_open = bool(args.stay_open)
|
||||
stealth = bool(args.stealth)
|
||||
|
||||
# Debug mode?
|
||||
if debug:
|
||||
common.set_debug(debug)
|
||||
web.debug_mode()
|
||||
|
||||
# Validation
|
||||
valid = True
|
||||
for filename in filenames:
|
||||
@ -66,7 +71,7 @@ def main(cwd=None):
|
||||
sys.exit()
|
||||
|
||||
# Start the Onion object
|
||||
onion = Onion(debug)
|
||||
onion = Onion()
|
||||
try:
|
||||
onion.connect()
|
||||
except (TorTooOld, TorErrorInvalidSetting, TorErrorAutomatic, TorErrorSocketPort, TorErrorSocketFile, TorErrorMissingPassword, TorErrorUnreadableCookieFile, TorErrorAuthError, TorErrorProtocolError, BundledTorNotSupported, BundledTorTimeout) as e:
|
||||
@ -84,10 +89,6 @@ def main(cwd=None):
|
||||
print("")
|
||||
sys.exit()
|
||||
|
||||
# Debug mode?
|
||||
if debug:
|
||||
web.debug_mode()
|
||||
|
||||
# Prepare files to share
|
||||
print(strings._("preparing_files"))
|
||||
web.set_file_info(filenames)
|
||||
|
@ -20,6 +20,19 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
import sys, os, inspect, hashlib, base64, platform, zipfile, tempfile, math, time, socket, random
|
||||
from random import SystemRandom
|
||||
|
||||
debug = False
|
||||
def log(module, func, msg):
|
||||
"""
|
||||
If debug mode is on, log error messages to stdout
|
||||
"""
|
||||
global debug
|
||||
if debug:
|
||||
print("[{}.{}] {}".format(module, func, msg))
|
||||
|
||||
def set_debug(new_debug):
|
||||
global debug
|
||||
debug = new_debug
|
||||
|
||||
|
||||
def get_platform():
|
||||
"""
|
||||
|
@ -119,9 +119,7 @@ class Onion(object):
|
||||
call this function and pass in a status string while connecting to tor. This
|
||||
is necessary for status updates to reach the GUI.
|
||||
"""
|
||||
def __init__(self, debug):
|
||||
self.debug = debug
|
||||
|
||||
def __init__(self):
|
||||
self.stealth = False
|
||||
self.service_id = None
|
||||
|
||||
|
@ -27,7 +27,7 @@ class OnionShare(object):
|
||||
OnionShare is the main application class. Pass in options and run
|
||||
start_onion_service and it will do the magic.
|
||||
"""
|
||||
def __init__(self, onion, debug=False, local_only=False, stay_open=False):
|
||||
def __init__(self, onion, local_only=False, stay_open=False):
|
||||
# The Onion object
|
||||
self.onion = onion
|
||||
|
||||
|
@ -76,6 +76,11 @@ def main():
|
||||
stay_open = bool(args.stay_open)
|
||||
debug = bool(args.debug)
|
||||
|
||||
# Debug mode?
|
||||
if debug:
|
||||
common.set_debug(debug)
|
||||
web.debug_mode()
|
||||
|
||||
# Validation
|
||||
if filenames:
|
||||
valid = True
|
||||
@ -87,14 +92,14 @@ def main():
|
||||
sys.exit()
|
||||
|
||||
# Start the Onion
|
||||
onion = Onion(debug)
|
||||
onion = Onion()
|
||||
|
||||
# Start the OnionShare app
|
||||
web.set_stay_open(stay_open)
|
||||
app = OnionShare(onion, debug, local_only, stay_open)
|
||||
app = OnionShare(onion, local_only, stay_open)
|
||||
|
||||
# Launch the gui
|
||||
gui = OnionShareGui(onion, debug, qtapp, app, filenames)
|
||||
gui = OnionShareGui(onion, qtapp, app, filenames)
|
||||
|
||||
# Clean up when app quits
|
||||
def shutdown():
|
||||
|
@ -44,10 +44,9 @@ class OnionShareGui(QtWidgets.QMainWindow):
|
||||
starting_server_step3 = QtCore.pyqtSignal()
|
||||
starting_server_error = QtCore.pyqtSignal(str)
|
||||
|
||||
def __init__(self, onion, debug, qtapp, app, filenames):
|
||||
def __init__(self, onion, qtapp, app, filenames):
|
||||
super(OnionShareGui, self).__init__()
|
||||
self.onion = onion
|
||||
self.debug = debug
|
||||
self.qtapp = qtapp
|
||||
self.app = app
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user