--- avahi-0.7/avahi-python/avahi-bookmarks.in.~1~ 2017-07-10 13:14:59.119370306 +0000
+++ avahi-0.7/avahi-python/avahi-bookmarks.in 2020-01-21 12:02:49.998355203 +0000
@@ -17,12 +17,17 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
+from __future__ import print_function
import sys, getopt, os
try:
- import avahi, gobject, dbus
-except ImportError:
- print "Sorry, to use this tool you need to install Avahi and python-dbus."
+ import gi
+ gi.require_version('Gtk', '3.0')
+ from gi.repository import GObject
+
+ import avahi, dbus
+except:
+ print("Sorry, to use this tool you need to install Avahi and python-dbus.")
sys.exit(1)
try:
@@ -95,7 +100,7 @@
else:
t += '
'
- for k, v in self.services.iteritems():
+ for k, v in self.services.items():
if v[3] == 80:
port = ''
@@ -138,16 +143,16 @@
def usage(retval = 0):
- print "%s [options]\n" % sys.argv[0]
- print " -h --help Show this help"
- print " -c --cgi Run as a CGI instead of as a server (default to server"
- print " unless environment variable GATEWAY_INTERFACE is set)"
- print " -t --timeout MS Specify the max time for CGI browsing (default %u)" % timeout
- print " -p --port PORT Specify the port to use (default %u)" % port
- print " -a --address ADDRESS Specify the address to bind to (default %s)" % address
- print " -H --host-names Show links with real hostnames"
- print " -A --addresses Show links with numeric IP addresses"
- print " -d --domain DOMAIN Specify the domain to browse"
+ print("%s [options]\n" % sys.argv[0])
+ print(" -h --help Show this help")
+ print(" -c --cgi Run as a CGI instead of as a server (default to server")
+ print(" unless environment variable GATEWAY_INTERFACE is set)")
+ print(" -t --timeout MS Specify the max time for CGI browsing (default %u)" % timeout)
+ print(" -p --port PORT Specify the port to use (default %u)" % port)
+ print(" -a --address ADDRESS Specify the address to bind to (default %s)" % address)
+ print(" -H --host-names Show links with real hostnames")
+ print(" -A --addresses Show links with numeric IP addresses")
+ print(" -d --domain DOMAIN Specify the domain to browse")
sys.exit(retval)
try:
@@ -181,20 +186,20 @@
domain = a
if use_CGI is None:
- use_CGI = os.environ.has_key("GATEWAY_INTERFACE")
+ use_CGI = "GATEWAY_INTERFACE" in os.environ
if use_CGI:
cgi = AvahiBookmarks(use_host_names)
- mainloop = gobject.MainLoop()
- gobject.timeout_add(timeout, mainloop.quit)
+ mainloop = GObject.MainLoop()
+ GObject.timeout_add(timeout, mainloop.quit)
try:
mainloop.run()
except KeyboardInterrupt:
pass
- print 'Content-type: text/html\n\n' + cgi.render_html()
+ print('Content-type: text/html\n\n' + cgi.render_html())
else:
try:
@@ -203,8 +208,8 @@
from twisted.internet import reactor
from twisted.web import server, resource
except ImportError:
- print "Sorry, to use this tool as a server you need to install twisted and twisted.web.\n"
- sys.exit(1)
+ print("Sorry, to use this tool as a server you need to install twisted and twisted.web.\n")
+ sys.exit(1)
class AvahiBookmarksServer(AvahiBookmarks, resource.Resource):
isLeaf = True
@@ -219,7 +224,7 @@
site = server.Site(AvahiBookmarksServer(use_host_names))
reactor.listenTCP(port, site, interface=address)
- print "Now point your web browser to http://%s:%u/!" % (address, port)
+ print("Now point your web browser to http://%s:%u/!" % (address, port))
try:
reactor.run()