示例#1
0
	def cb_process_exit(self, process, *a):
		""" Called after daemon binary outputs version and exits """
		from syncthing_gtk.app import MIN_ST_VERSION
		bin_path = process.get_commandline()[0]
		if compare_version(self.version_string, MIN_ST_VERSION):
			# Daemon binary exists, is executable and meets
			# version requirements. That's good, btw.
			self.parent.config["syncthing_binary"] = bin_path
			if not can_upgrade_binary(bin_path):
				# Don't try enable auto-update if binary is in
				# non-writable location (auto-update is enabled
				# by default on Windows only)
				self.parent.config["st_autoupdate"] = False
			self.parent.set_page_complete(self, True)
			self.label.set_markup(
					"<b>" + _("Syncthing daemon binary found.") + "</b>" +
					"\n\n" +
					_("Binary path:") + " " + bin_path + "\n" +
					_("Version:") + " " + self.version_string
				)
		else:
			# Found daemon binary too old to be ussable.
			# Just ignore it and try to find better one.
			log.info("Binary in %s is too old", bin_path)
			self.ignored_version = self.version_string
			GLib.idle_add(self.search)
示例#2
0
	def cb_process_exit(self, process, *a):
		""" Called after daemon binary outputs version and exits """
		from syncthing_gtk.app import MIN_ST_VERSION
		bin_path = process.get_commandline()[0]
		if compare_version(self.version_string, MIN_ST_VERSION):
			# Daemon binary exists, is executable and meets
			# version requirements. That's good, btw.
			self.parent.config["syncthing_binary"] = bin_path
			if not can_upgrade_binary(bin_path):
				# Don't try enable auto-update if binary is in
				# non-writable location (auto-update is enabled
				# by default on Windows only)
				self.parent.config["st_autoupdate"] = False
			self.parent.set_page_complete(self, True)
			self.label.set_markup(
					_("<b>Syncthing daemon binary found.</b>") +
					"\n\n" +
					_("Binary path:") + " " + bin_path + "\n" +
					_("Version:") + " " + self.version_string
				)
		else:
			# Found daemon binary too old to be ussable.
			# Just ignore it and try to find better one.
			log.info("Binary in %s is too old", bin_path)
			self.ignored_version = self.version_string
			GLib.idle_add(self.search)
示例#3
0
	def search(self, paths):
		"""
		Called repeatedly through GLib.idle_add, until binary is found
		or all possible paths are tried.
		"""
		try:
			path, paths = paths[0], paths[1:]
		except IndexError:
			# Out of possible paths. Not found
			if IS_WINDOWS:
				# On Windows, don't say anything and download Syncthing
				# directly
				self.parent.insert_and_go(DownloadSTPage())
				return False
			else:
				# On Linux, generate and display error page
				target_folder_link = '<a href="file://%s">%s</a>' % (
						os.path.expanduser(StDownloader.get_target_folder()),
						StDownloader.get_target_folder())
				dll_link = '<a href="https://github.com/syncthing/syncthing/releases">' + \
						_('download latest binary') + '</a>'
				page = self.parent.error(self,
						_("Syncthing daemon not found."),
						(_("Please, use package manager to install the Syncthing package") + " " +
						 _("or %s from Syncthing page and save it to your %s directory.") +
						 "\n\n" +
						 _("Alternatively, Syncthing-GTK can download Syncthing binary "
						   "to %s and keep it up-to-date, but this option is meant as "
						   "last resort and generally not suggested.")
						 ) % (dll_link, target_folder_link, target_folder_link), +
						False)
				# Attach [ ] Download Syncthing checkbox
				cb = Gtk.CheckButton(_("_Download Syncthing binary"), use_underline=True)
				cb.connect("toggled", lambda cb, *a : self.parent.set_page_complete(page, cb.get_active()))
				page.attach(cb,	0, 2, 2, 1)
				# Attach [ ] Autoupdate checkbox
				cb = Gtk.CheckButton(_("Auto_update downloaded binary"), use_underline=True)
				cb.connect("toggled", lambda cb, *a : self.parent.config.set("st_autoupdate", cb.get_active()))
				page.attach(cb,	0, 3, 2, 1)
				page.show_all()
				# Add Download page
				self.parent.insert(DownloadSTPage())
				return
		
		for bin in self.binaries:
			bin_path = os.path.join(path, bin)
			print " ...", bin_path,
			if os.path.isfile(bin_path):
				if os.access(bin_path, os.X_OK):
					# File exists and is executable
					print "FOUND"
					if IS_WINDOWS: bin_path = bin_path.replace("/", "\\")
					self.parent.config["syncthing_binary"] = bin_path
					if not can_upgrade_binary(bin_path):
						# Don't try enable auto-update if binary is in
						# non-writable location (auto-update is enabled
						# by default on Windows only)
						self.parent.config["st_autoupdate"] = False
					self.parent.set_page_complete(self, True)
					self.label.set_markup(
							_("<b>Syncthing daemon binary found.</b>") +
							"\n\n" +
							_("Binary path:") +
							" " +
							bin_path
						)
					return
				else:
					print "not executable"
			else:
				print "not found"
		GLib.idle_add(self.search, paths)