fixes for updater
This commit is contained in:
		
							parent
							
								
									52a5d248c7
								
							
						
					
					
						commit
						e598d027eb
					
				
					 2 changed files with 7 additions and 6 deletions
				
			
		| 
						 | 
					@ -259,6 +259,8 @@ class Toxygen:
 | 
				
			||||||
        self.tray.show()
 | 
					        self.tray.show()
 | 
				
			||||||
        self.tray.activated.connect(tray_activated)
 | 
					        self.tray.activated.connect(tray_activated)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        self.ms.show()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        updating = False
 | 
					        updating = False
 | 
				
			||||||
        if settings['update'] and updater.updater_available() and updater.connection_available():  # auto update
 | 
					        if settings['update'] and updater.updater_available() and updater.connection_available():  # auto update
 | 
				
			||||||
            version = updater.check_for_updates()
 | 
					            version = updater.check_for_updates()
 | 
				
			||||||
| 
						 | 
					@ -268,7 +270,7 @@ class Toxygen:
 | 
				
			||||||
                    updating = True
 | 
					                    updating = True
 | 
				
			||||||
                else:
 | 
					                else:
 | 
				
			||||||
                    reply = QtGui.QMessageBox.question(None,
 | 
					                    reply = QtGui.QMessageBox.question(None,
 | 
				
			||||||
                                                       '',
 | 
					                                                       'Toxygen',
 | 
				
			||||||
                                                       QtGui.QApplication.translate("login",
 | 
					                                                       QtGui.QApplication.translate("login",
 | 
				
			||||||
                                                                                    'Update for Toxygen was found. Download and install it?',
 | 
					                                                                                    'Update for Toxygen was found. Download and install it?',
 | 
				
			||||||
                                                                                    None,
 | 
					                                                                                    None,
 | 
				
			||||||
| 
						 | 
					@ -286,8 +288,6 @@ class Toxygen:
 | 
				
			||||||
            del self.tox
 | 
					            del self.tox
 | 
				
			||||||
            return
 | 
					            return
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        self.ms.show()
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        plugin_helper = PluginLoader(self.tox, settings)  # plugin support
 | 
					        plugin_helper = PluginLoader(self.tox, settings)  # plugin support
 | 
				
			||||||
        plugin_helper.load()
 | 
					        plugin_helper.load()
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,14 +50,14 @@ def get_url(version):
 | 
				
			||||||
        return 'https://github.com/toxygen-project/toxygen/archive/v' + version + '.zip'
 | 
					        return 'https://github.com/toxygen-project/toxygen/archive/v' + version + '.zip'
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        name = 'toxygen_windows.zip' if platform.system() == 'Windows' else 'toxygen_linux.tar.gz'
 | 
					        name = 'toxygen_windows.zip' if platform.system() == 'Windows' else 'toxygen_linux.tar.gz'
 | 
				
			||||||
        return 'https://github.com/toxygen-project/toxygen/releases/tag/v{}/{}'.format(version, name)
 | 
					        return 'https://github.com/toxygen-project/toxygen/releases/download/v{}/{}'.format(version, name)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def get_params(url, version):
 | 
					def get_params(url, version):
 | 
				
			||||||
    if is_from_sources():
 | 
					    if is_from_sources():
 | 
				
			||||||
        return ['python3', 'toxygen_updater.py', url, version]
 | 
					        return ['python3', 'toxygen_updater.py', url, version]
 | 
				
			||||||
    elif platform.system() == 'Windows':
 | 
					    elif platform.system() == 'Windows':
 | 
				
			||||||
        return ['run', 'toxygen_updater.exe', url, version]
 | 
					        return [util.curr_directory() + '/toxygen_updater.exe', url, version]
 | 
				
			||||||
    else:
 | 
					    else:
 | 
				
			||||||
        return ['./toxygen_updater', url, version]
 | 
					        return ['./toxygen_updater', url, version]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -66,6 +66,7 @@ def download(version):
 | 
				
			||||||
    os.chdir(util.curr_directory())
 | 
					    os.chdir(util.curr_directory())
 | 
				
			||||||
    url = get_url(version)
 | 
					    url = get_url(version)
 | 
				
			||||||
    params = get_params(url, version)
 | 
					    params = get_params(url, version)
 | 
				
			||||||
 | 
					    print('Updating Toxygen')
 | 
				
			||||||
    try:
 | 
					    try:
 | 
				
			||||||
        subprocess.Popen(params)
 | 
					        subprocess.Popen(params)
 | 
				
			||||||
    except Exception as ex:
 | 
					    except Exception as ex:
 | 
				
			||||||
| 
						 | 
					@ -89,7 +90,7 @@ def send_request(version):
 | 
				
			||||||
            QtCore.QThread.msleep(1)
 | 
					            QtCore.QThread.msleep(1)
 | 
				
			||||||
            QtCore.QCoreApplication.processEvents()
 | 
					            QtCore.QCoreApplication.processEvents()
 | 
				
			||||||
        attr = reply.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute)
 | 
					        attr = reply.attribute(QtNetwork.QNetworkRequest.HttpStatusCodeAttribute)
 | 
				
			||||||
        return 200 <= attr < 300
 | 
					        return attr is not None and 200 <= attr < 300
 | 
				
			||||||
    except Exception as ex:
 | 
					    except Exception as ex:
 | 
				
			||||||
        util.log('TOXYGEN UPDATER ERROR: ' + str(ex))
 | 
					        util.log('TOXYGEN UPDATER ERROR: ' + str(ex))
 | 
				
			||||||
        return False
 | 
					        return False
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue