def main(): """ The main() function implements all of the logic that the GUI version of onionshare uses. """ strings.load_strings(helpers) print(strings._('version_string').format(helpers.get_version())) # start the Qt app global qtapp qtapp = Application() # 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('--transparent', action='store_true', dest='transparent_torification', help=strings._("help_transparent_torification")) parser.add_argument('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename')) args = parser.parse_args() filenames = args.filenames if filenames: for i in range(len(filenames)): filenames[i] = os.path.abspath(filenames[i]) local_only = bool(args.local_only) stay_open = bool(args.stay_open) debug = bool(args.debug) transparent_torification = bool(args.transparent_torification) # create the onionshare icon global window_icon window_icon = QtGui.QIcon(helpers.get_resource_path('images/logo.png')) # validation if filenames: valid = True for filename in filenames: if not os.path.exists(filename): Alert(strings._("not_a_file", True).format(filename)) valid = False if not valid: sys.exit() # start the onionshare app web.set_stay_open(stay_open) web.set_transparent_torification(transparent_torification) app = onionshare.OnionShare(debug, local_only, stay_open, transparent_torification) # clean up when app quits def shutdown(): app.cleanup() qtapp.aboutToQuit.connect(shutdown) # launch the gui gui = OnionShareGui(qtapp, app) gui.send_files(filenames) # all done sys.exit(qtapp.exec_())
def main(): strings.load_strings() # start the Qt app global qtapp qtapp = Application() # 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('--filenames', metavar='filenames', nargs='+', help=strings._('help_filename')) args = parser.parse_args() filenames = args.filenames if filenames: for i in range(len(filenames)): filenames[i] = os.path.abspath(filenames[i]) local_only = bool(args.local_only) stay_open = bool(args.stay_open) debug = bool(args.debug) # validation if filenames: valid = True for filename in filenames: if not os.path.exists(filename): alert(strings._("not_a_file", True).format(filename)) valid = False if not valid: sys.exit() # create the onionshare icon global window_icon window_icon = QtGui.QIcon(common.get_image_path('logo.png')) # start the onionshare app web.set_stay_open(stay_open) app = onionshare.OnionShare(debug, local_only, stay_open) # clean up when app quits def shutdown(): app.cleanup() qtapp.connect(qtapp, QtCore.SIGNAL("aboutToQuit()"), shutdown) # launch the gui gui = OnionShareGui(qtapp, app) gui.send_files(filenames) # all done sys.exit(qtapp.exec_())