Rev4016, Fix updater
This commit is contained in:
parent
6254143fc6
commit
9a267ffcaf
3 changed files with 22 additions and 8 deletions
|
@ -13,7 +13,7 @@ class Config(object):
|
||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
self.version = "0.7.0"
|
self.version = "0.7.0"
|
||||||
self.rev = 4104
|
self.rev = 4106
|
||||||
self.argv = argv
|
self.argv = argv
|
||||||
self.action = None
|
self.action = None
|
||||||
self.pending_changes = {}
|
self.pending_changes = {}
|
||||||
|
|
|
@ -83,6 +83,10 @@ def update():
|
||||||
num_error = 0
|
num_error = 0
|
||||||
for path_from, path_to in update_paths.items():
|
for path_from, path_to in update_paths.items():
|
||||||
print("-", path_from, "->", path_to)
|
print("-", path_from, "->", path_to)
|
||||||
|
if not os.path.isfile(path_from):
|
||||||
|
print("Missing file")
|
||||||
|
continue
|
||||||
|
|
||||||
data = open(path_from, "rb").read()
|
data = open(path_from, "rb").read()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -108,4 +112,4 @@ def update():
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src")) # Imports relative to src
|
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "src")) # Imports relative to src
|
||||||
|
|
||||||
update()
|
update()
|
22
zeronet.py
22
zeronet.py
|
@ -31,11 +31,8 @@ def main():
|
||||||
if main and (main.update_after_shutdown or main.restart_after_shutdown): # Updater
|
if main and (main.update_after_shutdown or main.restart_after_shutdown): # Updater
|
||||||
if main.update_after_shutdown:
|
if main.update_after_shutdown:
|
||||||
import update
|
import update
|
||||||
if sys.platform.startswith("win"):
|
update.update()
|
||||||
update.update(restart_win=True)
|
restart()
|
||||||
else:
|
|
||||||
update.update()
|
|
||||||
restart()
|
|
||||||
else:
|
else:
|
||||||
print("Restarting...")
|
print("Restarting...")
|
||||||
restart()
|
restart()
|
||||||
|
@ -56,13 +53,26 @@ def restart():
|
||||||
import time
|
import time
|
||||||
time.sleep(1) # Wait files to close
|
time.sleep(1) # Wait files to close
|
||||||
|
|
||||||
args = [arg for arg in sys.argv[:] if arg not in ("--open_browser", "default_browser")]
|
args = sys.argv[:]
|
||||||
|
|
||||||
sys.executable = sys.executable.replace(".pkg", "") # Frozen mac fix
|
sys.executable = sys.executable.replace(".pkg", "") # Frozen mac fix
|
||||||
|
|
||||||
if not getattr(sys, 'frozen', False):
|
if not getattr(sys, 'frozen', False):
|
||||||
args.insert(0, sys.executable)
|
args.insert(0, sys.executable)
|
||||||
|
|
||||||
|
# Don't open browser after restart
|
||||||
|
if "--open_browser" in args:
|
||||||
|
del args[args.index("--open_browser") + 1] # argument value
|
||||||
|
del args[args.index("--open_browser")] # argument key
|
||||||
|
|
||||||
|
if getattr(sys, 'frozen', False):
|
||||||
|
pos_first_arg = 1 # Only the executable
|
||||||
|
else:
|
||||||
|
pos_first_arg = 2 # Interpter, .py file path
|
||||||
|
|
||||||
|
args.insert(pos_first_arg, "--open_browser")
|
||||||
|
args.insert(pos_first_arg + 1, "False")
|
||||||
|
|
||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
args = ['"%s"' % arg for arg in args]
|
args = ['"%s"' % arg for arg in args]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue