summaryrefslogtreecommitdiff
path: root/onionshare
diff options
context:
space:
mode:
authorMiguel Jacq <mig@mig5.net>2019-03-25 15:05:54 +1100
committerMiguel Jacq <mig@mig5.net>2019-03-25 15:05:54 +1100
commitc411e8d61a952faca758673a5c59133986fd9623 (patch)
tree7687c654ab7cbf0e73464a932b49d4ecc0c22d6f /onionshare
parent49285e047c43d97bf9c87a00859ecf74685f9228 (diff)
downloadonionshare-c411e8d61a952faca758673a5c59133986fd9623.tar.gz
onionshare-c411e8d61a952faca758673a5c59133986fd9623.zip
Standardise all shutdown_timer, shutdown_timeout, timeout attributes as 'autostop_timer'
Diffstat (limited to 'onionshare')
-rw-r--r--onionshare/__init__.py22
-rw-r--r--onionshare/common.py4
-rw-r--r--onionshare/onionshare.py14
-rw-r--r--onionshare/settings.py2
4 files changed, 21 insertions, 21 deletions
diff --git a/onionshare/__init__.py b/onionshare/__init__.py
index 616cf9db..722b4018 100644
--- a/onionshare/__init__.py
+++ b/onionshare/__init__.py
@@ -136,9 +136,9 @@ def main(cwd=None):
app.choose_port()
# Delay the startup if a startup timer was set
if autostart_timer > 0:
- # Can't set a schedule that is later than the shutdown timer
- if app.shutdown_timeout > 0 and app.shutdown_timeout < autostart_timer:
- print(strings._('gui_timeout_cant_be_earlier_than_startup'))
+ # Can't set a schedule that is later than the auto-stop timer
+ if app.autostop_timer > 0 and app.autostop_timer < autostart_timer:
+ print(strings._('gui_autostop_timer_cant_be_earlier_than_startup'))
sys.exit()
app.start_onion_service(False, True)
@@ -204,9 +204,9 @@ def main(cwd=None):
# Wait for web.generate_slug() to finish running
time.sleep(0.2)
- # start shutdown timer thread
- if app.shutdown_timeout > 0:
- app.shutdown_timer.start()
+ # start auto-stop timer thread
+ if app.autostop_timer > 0:
+ app.autostop_timer_thread.start()
# Save the web slug if we are using a persistent private key
if common.settings.get('save_private_key'):
@@ -250,18 +250,18 @@ def main(cwd=None):
# Wait for app to close
while t.is_alive():
- if app.shutdown_timeout > 0:
- # if the shutdown timer was set and has run out, stop the server
- if not app.shutdown_timer.is_alive():
+ if app.autostop_timer > 0:
+ # if the auto-stop timer was set and has run out, stop the server
+ if not app.autostop_timer_thread.is_alive():
if mode == 'share':
# If there were no attempts to download the share, or all downloads are done, we can stop
if web.share_mode.download_count == 0 or web.done:
- print(strings._("close_on_timeout"))
+ print(strings._("close_on_autostop_timer"))
web.stop(app.port)
break
if mode == 'receive':
if web.receive_mode.upload_count == 0 or not web.receive_mode.uploads_in_progress:
- print(strings._("close_on_timeout"))
+ print(strings._("close_on_autostop_timer"))
web.stop(app.port)
break
else:
diff --git a/onionshare/common.py b/onionshare/common.py
index fcb9ca6d..02668507 100644
--- a/onionshare/common.py
+++ b/onionshare/common.py
@@ -485,7 +485,7 @@ class Common(object):
return total_size
-class ShutdownTimer(threading.Thread):
+class AutoStopTimer(threading.Thread):
"""
Background thread sleeps t hours and returns.
"""
@@ -498,6 +498,6 @@ class ShutdownTimer(threading.Thread):
self.time = time
def run(self):
- self.common.log('Shutdown Timer', 'Server will shut down after {} seconds'.format(self.time))
+ self.common.log('AutoStopTimer', 'Server will shut down after {} seconds'.format(self.time))
time.sleep(self.time)
return 1
diff --git a/onionshare/onionshare.py b/onionshare/onionshare.py
index 6598b975..e746bae1 100644
--- a/onionshare/onionshare.py
+++ b/onionshare/onionshare.py
@@ -22,14 +22,14 @@ import os, shutil
from . import common, strings
from .onion import TorTooOld, TorErrorProtocolError
-from .common import ShutdownTimer
+from .common import AutoStopTimer
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, common, onion, local_only=False, shutdown_timeout=0):
+ def __init__(self, common, onion, local_only=False, autostop_timer=0):
self.common = common
self.common.log('OnionShare', '__init__')
@@ -49,9 +49,9 @@ class OnionShare(object):
self.local_only = local_only
# optionally shut down after N hours
- self.shutdown_timeout = shutdown_timeout
- # init timing thread
- self.shutdown_timer = None
+ self.autostop_timer = autostop_timer
+ # init auto-stop timer thread
+ self.autostop_timer_thread = None
def set_stealth(self, stealth):
self.common.log('OnionShare', 'set_stealth', 'stealth={}'.format(stealth))
@@ -77,8 +77,8 @@ class OnionShare(object):
if not self.port:
self.choose_port()
- if self.shutdown_timeout > 0:
- self.shutdown_timer = ShutdownTimer(self.common, self.shutdown_timeout)
+ if self.autostop_timer > 0:
+ self.autostop_timer_thread = AutoStopTimer(self.common, self.autostop_timer)
if self.local_only:
self.onion_host = '127.0.0.1:{0:d}'.format(self.port)
diff --git a/onionshare/settings.py b/onionshare/settings.py
index d015c5ce..a5d4db6a 100644
--- a/onionshare/settings.py
+++ b/onionshare/settings.py
@@ -84,7 +84,7 @@ class Settings(object):
'auth_type': 'no_auth',
'auth_password': '',
'close_after_first_download': True,
- 'shutdown_timeout': False,
+ 'autostop_timer': False,
'startup_timer': False,
'use_stealth': False,
'use_autoupdate': True,