Reworked code to work with PyInstaller dev version 34be811.

This commit is contained in:
Thomas White 2014-06-23 21:09:26 -04:00
parent 6e707d5452
commit 5c27838379
4 changed files with 13 additions and 13 deletions

View File

@ -1 +0,0 @@
from onionshare_gui import *

View File

@ -42,8 +42,10 @@ def add_request(type, path, data=None):
@app.route("/{0}".format(slug))
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)
if getattr(sys, "frozen", False):
onionshare_dir = os.path.dirname(sys.executable)
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)

View File

@ -2,11 +2,6 @@ import os, sys, subprocess, inspect
from PyQt4.QtCore import *
from PyQt4.QtGui 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())))
@ -17,7 +12,6 @@ except ImportError:
import onionshare
import webapp
window_icon = None
class Application(QApplication):
@ -81,7 +75,6 @@ def select_file(strings):
return filename, basename
def main():
print "start main"
onionshare.strings = onionshare.load_strings()
# start the Qt app
@ -123,7 +116,6 @@ def main():
onionshare.tails_open_port(webapp_port)
webapp_thread = WebAppThread(webapp_port)
webapp_thread.start()
print "after webapp functs"
# clean up when app quits
def shutdown():
@ -134,7 +126,7 @@ def main():
# launch the window
web = Window(basename, webapp_port)
web.show()
print "after show happens"
# all done
sys.exit(app.exec_())

View File

@ -7,7 +7,6 @@ filename = None
onion_host = None
qtapp = None
clipboard = None
url = None
# 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.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.route("/")