mirror of
https://github.com/onionshare/onionshare.git
synced 2025-01-13 00:09:38 -05:00
Reworked code to work with PyInstaller dev version 34be811
.
This commit is contained in:
parent
6e707d5452
commit
5c27838379
@ -1 +0,0 @@
|
|||||||
from onionshare_gui import *
|
|
@ -42,8 +42,10 @@ def add_request(type, path, data=None):
|
|||||||
|
|
||||||
@app.route("/{0}".format(slug))
|
@app.route("/{0}".format(slug))
|
||||||
def index():
|
def index():
|
||||||
global filename, filesize, filehash, slug, strings, REQUEST_LOAD
|
global filename, filesize, filehash, slug, strings, REQUEST_LOAD, onionshare_dir
|
||||||
add_request(REQUEST_LOAD, request.path)
|
add_request(REQUEST_LOAD, request.path)
|
||||||
|
if getattr(sys, "frozen", False):
|
||||||
|
onionshare_dir = os.path.dirname(sys.executable)
|
||||||
return render_template_string(open('{0}/index.html'.format(onionshare_dir)).read(),
|
return render_template_string(open('{0}/index.html'.format(onionshare_dir)).read(),
|
||||||
slug=slug, filename=os.path.basename(filename), filehash=filehash, filesize=filesize, strings=strings)
|
slug=slug, filename=os.path.basename(filename), filehash=filehash, filesize=filesize, strings=strings)
|
||||||
|
|
||||||
|
@ -2,11 +2,6 @@ import os, sys, subprocess, inspect
|
|||||||
from PyQt4.QtCore import *
|
from PyQt4.QtCore import *
|
||||||
from PyQt4.QtGui import *
|
from PyQt4.QtGui import *
|
||||||
from PyQt4.QtWebKit import *
|
from PyQt4.QtWebKit import *
|
||||||
from os import path
|
|
||||||
print "after path import"
|
|
||||||
print "after path change"
|
|
||||||
import onionshare
|
|
||||||
import webapp
|
|
||||||
|
|
||||||
onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
onionshare_gui_dir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
|
||||||
|
|
||||||
@ -17,7 +12,6 @@ except ImportError:
|
|||||||
import onionshare
|
import onionshare
|
||||||
|
|
||||||
import webapp
|
import webapp
|
||||||
|
|
||||||
window_icon = None
|
window_icon = None
|
||||||
|
|
||||||
class Application(QApplication):
|
class Application(QApplication):
|
||||||
@ -81,7 +75,6 @@ def select_file(strings):
|
|||||||
return filename, basename
|
return filename, basename
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print "start main"
|
|
||||||
onionshare.strings = onionshare.load_strings()
|
onionshare.strings = onionshare.load_strings()
|
||||||
|
|
||||||
# start the Qt app
|
# start the Qt app
|
||||||
@ -123,7 +116,6 @@ def main():
|
|||||||
onionshare.tails_open_port(webapp_port)
|
onionshare.tails_open_port(webapp_port)
|
||||||
webapp_thread = WebAppThread(webapp_port)
|
webapp_thread = WebAppThread(webapp_port)
|
||||||
webapp_thread.start()
|
webapp_thread.start()
|
||||||
print "after webapp functs"
|
|
||||||
|
|
||||||
# clean up when app quits
|
# clean up when app quits
|
||||||
def shutdown():
|
def shutdown():
|
||||||
@ -134,7 +126,7 @@ def main():
|
|||||||
# launch the window
|
# launch the window
|
||||||
web = Window(basename, webapp_port)
|
web = Window(basename, webapp_port)
|
||||||
web.show()
|
web.show()
|
||||||
print "after show happens"
|
|
||||||
# all done
|
# all done
|
||||||
sys.exit(app.exec_())
|
sys.exit(app.exec_())
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ filename = None
|
|||||||
onion_host = None
|
onion_host = None
|
||||||
qtapp = None
|
qtapp = None
|
||||||
clipboard = None
|
clipboard = None
|
||||||
|
|
||||||
url = None
|
url = None
|
||||||
|
|
||||||
# figure out this platform's temp dir
|
# figure out this platform's temp dir
|
||||||
@ -26,7 +25,15 @@ import logging
|
|||||||
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
|
log_handler = logging.FileHandler('{0}/onionshare.web.log'.format(temp_dir))
|
||||||
log_handler.setLevel(logging.WARNING)
|
log_handler.setLevel(logging.WARNING)
|
||||||
|
|
||||||
app = Flask(__name__, template_folder='./templates')
|
# pyinstaller sets sys.frozen=1 on run
|
||||||
|
application_path = ""
|
||||||
|
if getattr(sys, "frozen", False):
|
||||||
|
application_path = os.path.dirname(sys.executable)
|
||||||
|
elif __file__:
|
||||||
|
application_path = os.path.dirname(__file__)
|
||||||
|
template_path = os.path.join(application_path, "templates")
|
||||||
|
|
||||||
|
app = Flask(__name__, template_folder=template_path)
|
||||||
app.logger.addHandler(log_handler)
|
app.logger.addHandler(log_handler)
|
||||||
|
|
||||||
@app.route("/")
|
@app.route("/")
|
||||||
|
Loading…
Reference in New Issue
Block a user