AC_PROG_SED
# Python
-AM_PATH_PYTHON([2.7])
+AM_PATH_PYTHON([3.5])
# scss
AC_CHECK_PROG(SASSC, [sassc], [sassc])
localedir: ${localedir}
systemd support ${have_systemd}
+ Python version: ${PYTHON_VERSION}
])
#!/usr/bin/python
-from base import Backend
+from .base import Backend
# encoding: utf-8
import PIL
-import StringIO
+import io
import hashlib
import ldap
import logging
-import urllib
+import urllib.request, urllib.parse, urllib.error
-from misc import Object
+from .misc import Object
class Accounts(Object):
@property
return self.__attrs
def _get_first_attribute(self, attr, default=None):
- if not self.attributes.has_key(attr):
+ if attr not in self.attributes:
return default
res = self.attributes.get(attr, [])
return self._resize_avatar(avatar, size)
def _resize_avatar(self, image, size):
- image = StringIO.StringIO(image)
+ image = io.StringIO(image)
image = PIL.Image.open(image)
# Resize the image to the desired resolution
image.thumbnail((size, size), PIL.Image.ANTIALIAS)
- f = StringIO.StringIO()
+ f = io.StringIO()
# If writing out the image does not work with optimization,
# we try to write it out without any optimization.
# construct the url
gravatar_url = "https://www.gravatar.com/avatar/" + \
hashlib.md5(gravatar_email).hexdigest() + "?"
- gravatar_url += urllib.urlencode({'d': "mm", 's': str(size)})
+ gravatar_url += urllib.parse.urlencode({'d': "mm", 's': str(size)})
return gravatar_url
if __name__ == "__main__":
a = Accounts()
- print a.list()
+ print(a.list())
#!/usr/bin/python
-import ConfigParser as configparser
-import StringIO
-
-import accounts
-import database
-import geoip
-import fireinfo
-import iuse
-import memcached
-import mirrors
-import netboot
-import nopaste
-import releases
-import settings
-import talk
+import configparser as configparser
+import io
+
+from . import accounts
+from . import database
+from . import geoip
+from . import fireinfo
+from . import iuse
+from . import memcached
+from . import mirrors
+from . import netboot
+from . import nopaste
+from . import releases
+from . import settings
+from . import talk
from . import blog
from . import zeiterfassung
-DEFAULT_CONFIG = StringIO.StringIO("""
+DEFAULT_CONFIG = io.StringIO("""
[global]
debug = false
def get_all(locale=None):
if locale is None:
- l = country_list.keys()
+ l = list(country_list.keys())
else:
l = []
- for c in country_list.keys():
+ for c in list(country_list.keys()):
c = locale.translate(c)
l.append(c)
as torndb.
"""
-from __future__ import absolute_import, division, with_statement
+
import copy
import itertools
try:
self._execute(cursor, query, parameters, kwparameters)
column_names = [d[0] for d in cursor.description]
- return [Row(itertools.izip(column_names, row)) for row in cursor]
+ return [Row(zip(column_names, row)) for row in cursor]
finally:
cursor.close()
#!/usr/bin/python
-from __future__ import division
+
import datetime
import hwdata
import logging
import re
-import database
-import util
-from misc import Object
+from . import database
+from . import util
+from .misc import Object
N_ = lambda x: x
for arg in self.__processor_args_mandatory:
if not args.get(arg, None):
- raise ProfileParserError, "Mandatory argument missing: %s" % arg
+ raise ProfileParserError("Mandatory argument missing: %s" % arg)
self.processor = self.fireinfo.get_processor(**args)
if not self.processor:
except KeyError:
vendors[vendor] = [(row.subsystem, row.vendor)]
- vendors = vendors.items()
+ vendors = list(vendors.items())
return sorted(vendors)
def get_devices_by_vendor(self, subsystem, vendor, when=None):
import IPy
import re
-import countries
+from . import countries
-from misc import Object
+from .misc import Object
class GeoIP(Object):
def guess_address_family(self, addr):
#!/usr/bin/python
-from __future__ import division
-import StringIO
+
+import io
import logging
import os.path
from PIL import Image, ImageDraw, ImageFont, PngImagePlugin
-from misc import Object
+from .misc import Object
image_types = []
self._image.save(filename, "PNG", optimize=True)
def to_string(self):
- f = StringIO.StringIO()
+ f = io.StringIO()
self.save(f)
return self.__font
def draw_text(self, pos, text, **kwargs):
- if not kwargs.has_key("font"):
+ if "font" not in kwargs:
kwargs["font"] = self.font
return self.paint.text(pos, text, **kwargs)
import logging
import memcache
-from misc import Object
+from .misc import Object
class Memcached(Object):
def init(self):
#!/usr/bin/python
-from __future__ import division
+
import datetime
import logging
import time
import tornado.httpclient
import tornado.netutil
-import urlparse
+import urllib.parse
-from misc import Object
+from .misc import Object
class Downloads(Object):
@property
return self._info.url
def build_url(self, filename):
- return urlparse.urljoin(self.url, filename)
+ return urllib.parse.urljoin(self.url, filename)
@property
def last_update(self):
traffic = 0
for entry in self.db.query(query, self.id, since):
- if files.has_key(entry.filename):
+ if entry.filename in files:
traffic += entry.count * files[entry.filename]
return traffic
#!/usr/bin/python
-from misc import Object
+from .misc import Object
class MenuEntry(object):
def __init__(self, _data):
import magic
-from misc import Object
+from .misc import Object
class Nopaste(Object):
def create(self, subject, content, type="text", expires=None, account=None, address=None):
import logging
import os
import re
-import urllib
-import urlparse
+import urllib.request, urllib.parse, urllib.error
+import urllib.parse
-import database
-import tracker
-from misc import Object
+from . import database
+from . import tracker
+from .misc import Object
TRACKERS = (
"http://ipv4.tracker.ipfire.org:6969/announce",
@property
def url(self):
- return urlparse.urljoin("https://downloads.ipfire.org", self.filename)
+ return urllib.parse.urljoin("https://downloads.ipfire.org", self.filename)
@property
def desc(self):
s = "magnet:?xt=urn:btih:%s" % self.torrent_hash
#s += "&xl=%d" % self.size
- s += "&dn=%s" % urllib.quote(self.basename)
+ s += "&dn=%s" % urllib.parse.quote(self.basename)
# Add our tracker.
for tracker in TRACKERS:
s += "&tr=%s" % tracker
# Add web download URL
- s += "&as=%s" % urllib.quote(self.url)
+ s += "&as=%s" % urllib.parse.quote(self.url)
return s
#!/usr/bin/python
-from misc import Object
+from .misc import Object
class Settings(Object):
def init(self):
from . import database
-from misc import Object
+from .misc import Object
class Talk(Object):
def get_phonebook(self, account=None):
#!/usr/bin/python
-from __future__ import division
+
def ncode_hex(s):
return s.encode("hex")
def encode_dict(x,r):
r.append('d')
- ilist = x.items()
+ ilist = list(x.items())
ilist.sort()
for k, v in ilist:
r.extend((str(len(k)), ':', k))
#!/usr/bin/python
-from __future__ import division
+
def format_size(s):
units = ("B", "k", "M", "G", "T")
import json
import tornado.httpclient
import tornado.gen
-import urllib
-import urlparse
+import urllib.request, urllib.parse, urllib.error
+import urllib.parse
-from misc import Object
+from .misc import Object
class ZeiterfassungClient(Object):
algorithm = "Zeiterfassung-HMAC-SHA512"
@tornado.gen.coroutine
def send_request(self, path, **kwargs):
- url = urlparse.urljoin(self.url, path)
+ url = urllib.parse.urljoin(self.url, path)
# Query arguments are all keyword arguments
arguments = kwargs
request = tornado.httpclient.HTTPRequest(url, method="POST")
- request.body = urllib.urlencode(arguments)
+ request.body = urllib.parse.urlencode(arguments)
# Compose the signature
signature = self._make_signature("POST", path, request.body)
import ipfire
-from handlers import *
+from .handlers import *
from . import auth
from . import blog
import email.utils
import tornado.web
-import handlers_base as base
+from . import handlers_base as base
from . import ui_modules
import tornado.web
#import unicodedata
-from handlers_accounts import *
-from handlers_admin import *
-from handlers_base import *
-from handlers_boot import *
-from handlers_fireinfo import *
-from handlers_iuse import *
-from handlers_mirrors import *
-from handlers_nopaste import *
-from handlers_talk import *
+from .handlers_accounts import *
+from .handlers_admin import *
+from .handlers_base import *
+from .handlers_boot import *
+from .handlers_fireinfo import *
+from .handlers_iuse import *
+from .handlers_mirrors import *
+from .handlers_nopaste import *
+from .handlers_talk import *
class LangCompatHandler(BaseHandler):
"""
import logging
import tornado.web
-from handlers_base import *
+from .handlers_base import *
class AccountsAvatarHandler(BaseHandler):
def get(self, who):
import datetime
import tornado.web
-from handlers_base import *
+from .handlers_base import *
class AdminBaseHandler(BaseHandler):
pass
#!/usr/bin/python
-from __future__ import division
+
import datetime
import dateutil.parser
-import httplib
+import http.client
import ipaddr
import logging
import time
def write_error(self, status_code, **kwargs):
# Translate code into message
try:
- message = httplib.responses[status_code]
+ message = http.client.responses[status_code]
except KeyError:
message = None
import tornado.options
import tornado.web
-from handlers_base import BaseHandler
+from .handlers_base import BaseHandler
BASEDIR = os.path.dirname(__file__)
#!/usr/bin/python
-from __future__ import division
+
import datetime
import hwdata
from .. import fireinfo
-from handlers_base import *
+from .handlers_base import *
class FireinfoBaseHandler(BaseHandler):
def cut_string(self, s, limit=15):
try:
return self[key]
except KeyError:
- raise AttributeError, key
+ raise AttributeError(key)
def __setattr__(self, key, val):
self[key] = val
"public_id",
)
for attr in attributes:
- if not profile.has_key(attr):
+ if attr not in profile:
raise tornado.web.HTTPError(400, "Profile lacks '%s' attribute: %s" % (attr, profile))
def __check_valid_ids(self, profile):
# Try to decode the profile.
try:
return json.loads(profile)
- except json.decoder.JSONDecodeError, e:
+ except json.decoder.JSONDecodeError as e:
raise tornado.web.HTTPError(400, "Profile could not be decoded: %s" % e)
# The GET method is only allowed in debugging mode.
import random
import tornado.web
-from handlers_base import *
+from .handlers_base import *
class IUseImage(BaseHandler):
expires = 3600 * 3
import socket
import tornado.web
-from handlers_base import *
+from .handlers_base import *
class MirrorIndexHandler(BaseHandler):
def get(self):
import tornado.web
-from handlers_base import *
+from .handlers_base import *
class NopasteCreateHandler(BaseHandler):
MODES = ("paste", "upload")
import tornado.web
-from handlers_base import *
+from .handlers_base import *
class TalkIndexHandler(BaseHandler):
@tornado.web.authenticated
import tornado.web
-import handlers_base as base
+from . import handlers_base as base
class IndexHandler(base.BaseHandler):
def get(self):
#!/usr/bin/python
-from __future__ import division
+
import re
import tornado.web
groups = {}
for device in devices:
- if not groups.has_key(device.cls):
+ if device.cls not in groups:
groups[device.cls] = []
groups[device.cls].append(device)
# Sort all devices
- for key in groups.keys():
+ for key in list(groups.keys()):
groups[key].sort()
# Order the groups by their name
- groups = groups.items()
+ groups = list(groups.items())
groups.sort()
return self.render_string("fireinfo/modules/table-devices-and-groups.html",
class NetBootMenuHeaderModule(UIModule):
def render(self, title, releases, arch=None, platform=None):
- id = unicodedata.normalize("NFKD", unicode(title)).encode("ascii", "ignore")
+ id = unicodedata.normalize("NFKD", str(title)).encode("ascii", "ignore")
id = re.sub(r"[^\w]+", " ", id)
id = "-".join(id.lower().strip().split())