def tearDown(self): """Try to ensure all processes are shutdown, even if the tests failed.""" dbc = sqlite3.connect(web.dbname) cur = dbc.execute('SELECT * FROM system') allsys = (row[0] for row in cur) for tsi in allsys: web.stop(tsi)
def sig_handler (sig, frame): """ Hanle ctrl c signal""" print "Close "+__file__ try: web.stop() except: pass sys.exit()
def signal_handler(signal, frame): global srv, logging print() # clear the signal written to terminal logging.info("Caught signal:" + str(signal)) logging.info("Shutting down after signal.") web.stop() srv.shutdown()
def tearDownModule(): web.stop()
def main(): strings.load_strings() tails_root() # parse arguments parser = argparse.ArgumentParser() parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only")) parser.add_argument('--stay-open', action='store_true', dest='stay_open', help=strings._("help_stay_open")) parser.add_argument('--debug', action='store_true', dest='debug', help=strings._("help_debug")) parser.add_argument('filename', metavar='filename', nargs='+', help=strings._('help_filename')) args = parser.parse_args() filenames = args.filename for i in range(len(filenames)): filenames[i] = os.path.abspath(filenames[i]) local_only = bool(args.local_only) debug = bool(args.debug) stay_open = bool(args.stay_open) # validation valid = True for filename in filenames: if not os.path.exists(filename): print(strings._("not_a_file").format(filename)) valid = False if not valid: sys.exit() # start the onionshare app try: app = OnionShare(debug, local_only, stay_open) app.choose_port() print strings._("connecting_ctrlport").format(app.port) app.start_hidden_service() except NoTor as e: sys.exit(e.args[0]) except TailsError as e: sys.exit(e.args[0]) # prepare files to share print strings._("preparing_files") web.set_file_info(filenames) app.cleanup_filenames.append(web.zip_filename) # start onionshare service in new thread t = threading.Thread(target=web.start, args=(app.port, app.stay_open)) t.daemon = True t.start() # wait for hs ready = app.wait_for_hs() if not ready: sys.exit() print strings._("give_this_url") print 'http://{0}/{1}'.format(app.onion_host, web.slug) print '' print strings._("ctrlc_to_stop") # wait for app to close running = True while running: try: time.sleep(0.5) except KeyboardInterrupt: running = False web.stop() # shutdown app.cleanup()
# otherwise some initialization will use the wrong values. import web try: import Tkinter except ImportError: args.cli = True if not args.cli: import window root = window.init() print "DriveboardApp v" + config.conf['version'] # start server in thread web.start(browser=(not args.nobrowser), debug=args.debug) # main thread loop while 1: try: if not args.cli: try: root.update() except Tkinter.TclError: break time.sleep(0.1) except KeyboardInterrupt: break web.stop() print "END of DriveboardApp"
def main(cwd=None): """ The main() function implements all of the logic that the command-line version of onionshare uses. """ strings.load_strings() # onionshare CLI in OSX needs to change current working directory (#132) if helpers.get_platform() == 'Darwin': if cwd: os.chdir(cwd) # parse arguments parser = argparse.ArgumentParser() parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only")) parser.add_argument('--stay-open', action='store_true', dest='stay_open', help=strings._("help_stay_open")) parser.add_argument('--transparent', action='store_true', dest='transparent_torification', help=strings._("help_transparent_torification")) parser.add_argument('--debug', action='store_true', dest='debug', help=strings._("help_debug")) parser.add_argument('filename', metavar='filename', nargs='+', help=strings._('help_filename')) args = parser.parse_args() filenames = args.filename for i in range(len(filenames)): filenames[i] = os.path.abspath(filenames[i]) local_only = bool(args.local_only) debug = bool(args.debug) stay_open = bool(args.stay_open) transparent_torification = bool(args.transparent_torification) # validation valid = True for filename in filenames: if not os.path.exists(filename): print(strings._("not_a_file").format(filename)) valid = False if not valid: sys.exit() # start the onionshare app try: app = OnionShare(debug, local_only, stay_open, transparent_torification) app.choose_port() app.start_hidden_service() except hs.NoTor as e: sys.exit(e.args[0]) except hs.HSDirError as e: sys.exit(e.args[0]) # prepare files to share print strings._("preparing_files") web.set_file_info(filenames) app.cleanup_filenames.append(web.zip_filename) # warn about sending large files over Tor if web.zip_filesize >= 157286400: # 150mb print '' print strings._("large_filesize") print '' # start onionshare service in new thread t = threading.Thread(target=web.start, args=(app.port, app.stay_open, app.transparent_torification)) t.daemon = True t.start() try: # Trap Ctrl-C # wait for hs, only if using old version of tor if not app.local_only: ready = app.hs.wait_for_hs(app.onion_host) if not ready: sys.exit() print strings._("give_this_url") print 'http://{0:s}/{1:s}'.format(app.onion_host, web.slug) print '' print strings._("ctrlc_to_stop") # wait for app to close while t.is_alive(): # t.join() can't catch KeyboardInterrupt in such as Ubuntu t.join(0.5) except KeyboardInterrupt: web.stop(app.port) finally: # shutdown app.cleanup()
def test_4_stop(self): """Simulate click on "Stop" for first test-system.""" self.assertEqual(sha(web.stop(1), hex=True), SHA_STOP_PAGE)
def main(cwd=None): """ The main() function implements all of the logic that the command-line version of onionshare uses. """ strings.load_strings() # onionshare CLI in OSX needs to change current working directory (#132) if helpers.get_platform() == 'Darwin': if cwd: os.chdir(cwd) # parse arguments parser = argparse.ArgumentParser() parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only")) parser.add_argument('--stay-open', action='store_true', dest='stay_open', help=strings._("help_stay_open")) parser.add_argument('--transparent', action='store_true', dest='transparent_torification', help=strings._("help_transparent_torification")) parser.add_argument('--debug', action='store_true', dest='debug', help=strings._("help_debug")) parser.add_argument('filename', metavar='filename', nargs='+', help=strings._('help_filename')) args = parser.parse_args() filenames = args.filename for i in range(len(filenames)): filenames[i] = os.path.abspath(filenames[i]) local_only = bool(args.local_only) debug = bool(args.debug) stay_open = bool(args.stay_open) transparent_torification = bool(args.transparent_torification) # validation valid = True for filename in filenames: if not os.path.exists(filename): print(strings._("not_a_file").format(filename)) valid = False if not valid: sys.exit() # start the onionshare app try: app = OnionShare(debug, local_only, stay_open, transparent_torification) app.choose_port() app.start_hidden_service() except hs.NoTor as e: sys.exit(e.args[0]) except hs.HSDirError as e: sys.exit(e.args[0]) # prepare files to share print strings._("preparing_files") web.set_file_info(filenames) app.cleanup_filenames.append(web.zip_filename) # warn about sending large files over Tor if web.zip_filesize >= 157286400: # 150mb print '' print strings._("large_filesize") print '' # start onionshare service in new thread t = threading.Thread(target=web.start, args=(app.port, app.stay_open, app.transparent_torification)) t.daemon = True t.start() try: # Trap Ctrl-C # wait for hs, only if using old version of tor if not app.hs.supports_ephemeral: if not app.local_only: ready = app.hs.wait_for_hs(app.onion_host) if not ready: sys.exit() print strings._("give_this_url") print 'http://{0:s}/{1:s}'.format(app.onion_host, web.slug) print '' print strings._("ctrlc_to_stop") # wait for app to close while t.is_alive(): # t.join() can't catch KeyboardInterrupt in such as Ubuntu t.join(0.5) except KeyboardInterrupt: web.stop(app.port) finally: # shutdown app.cleanup()
def network_lost(self): # logging.info("network lost") web.stop() self.locontrol.stop_info_screen()
def main(): strings.load_strings() tails_root() # parse arguments parser = argparse.ArgumentParser() parser.add_argument('--local-only', action='store_true', dest='local_only', help=strings._("help_local_only")) parser.add_argument('--stay-open', action='store_true', dest='stay_open', help=strings._("help_stay_open")) parser.add_argument('--debug', action='store_true', dest='debug', help=strings._("help_debug")) parser.add_argument('filename', metavar='filename', nargs='+', help=strings._('help_filename')) args = parser.parse_args() filenames = args.filename for i in range(len(filenames)): filenames[i] = os.path.abspath(filenames[i]) local_only = bool(args.local_only) debug = bool(args.debug) stay_open = bool(args.stay_open) # validation valid = True for filename in filenames: if not os.path.exists(filename): print(strings._("not_a_file").format(filename)) valid = False if not valid: sys.exit() # start the onionshare app try: app = OnionShare(debug, local_only, stay_open) app.choose_port() print strings._("connecting_ctrlport").format(app.port) app.start_hidden_service() except NoTor as e: sys.exit(e.args[0]) except TailsError as e: sys.exit(e.args[0]) # prepare files to share print strings._("preparing_files") web.set_file_info(filenames) app.cleanup_filenames.append(web.zip_filename) # warn about sending large files over Tor if web.zip_filesize >= 157286400: # 150mb print '' print strings._("large_filesize") print '' # start onionshare service in new thread t = threading.Thread(target=web.start, args=(app.port, app.stay_open)) t.daemon = True t.start() try: # Trap Ctrl-C # wait for hs ready = app.wait_for_hs() if not ready: sys.exit() print strings._("give_this_url") print 'http://{0}/{1}'.format(app.onion_host, web.slug) print '' print strings._("ctrlc_to_stop") # wait for app to close while t.is_alive(): # t.join() can't catch KeyboardInterrupt in such as Ubuntu t.join(0.5) except KeyboardInterrupt: web.stop(app.port) finally: # shutdown app.cleanup()
args = argparser.parse_args() try: import Tkinter except ImportError: args.cli = True if not args.cli: import window root = window.init() print "DriveboardApp v" + conf['version'] conf['usb_reset_hack'] = args.usbhack # start server in thread web.start(browser=(not args.nobrowser), debug=args.debug) # main thread loop while 1: try: if not args.cli: try: root.update() except Tkinter.TclError: break time.sleep(0.1) except KeyboardInterrupt: break web.stop() print "END of DriveboardApp"