From: Michael Tremer Date: Thu, 12 Jul 2018 16:01:21 +0000 (+0100) Subject: Fix relative imports X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a95c2f979d90b7c29c99f57101973a9e2cf16f63;p=ipfire.org.git Fix relative imports Signed-off-by: Michael Tremer --- diff --git a/src/scripts/ipfire.org-webapp.in b/src/scripts/ipfire.org-webapp.in index 588031da..8b1b02a9 100755 --- a/src/scripts/ipfire.org-webapp.in +++ b/src/scripts/ipfire.org-webapp.in @@ -5,7 +5,7 @@ import tornado.options tornado.options.define("port", type=int, default=8001, help="Port to listen on") -from webapp import Application +from ipfire.web import Application def run(): tornado.options.parse_command_line() diff --git a/src/web/__init__.py b/src/web/__init__.py index 0a241d17..fdd5b477 100644 --- a/src/web/__init__.py +++ b/src/web/__init__.py @@ -6,7 +6,7 @@ import tornado.locale import tornado.options import tornado.web -import backend +import ipfire from handlers import * from ui_modules import * @@ -16,7 +16,7 @@ BASEDIR = os.path.join(os.path.dirname(__file__), "..") class Application(tornado.web.Application): def __init__(self, config, **kwargs): # Initialize backend - self.backend = backend.Backend(config) + self.backend = ipfire.Backend(config) settings = dict( debug = tornado.options.options.debug, diff --git a/src/web/handlers.py b/src/web/handlers.py index d380d5f4..79e3f4d9 100644 --- a/src/web/handlers.py +++ b/src/web/handlers.py @@ -15,8 +15,6 @@ import tornado.gen import tornado.web #import unicodedata -import backend - from handlers_accounts import * from handlers_admin import * from handlers_base import * diff --git a/src/web/handlers_admin.py b/src/web/handlers_admin.py index b7a3f9d1..36ee0bad 100644 --- a/src/web/handlers_admin.py +++ b/src/web/handlers_admin.py @@ -5,8 +5,6 @@ import tornado.web from handlers_base import * -import backend - class AdminBaseHandler(BaseHandler): pass diff --git a/src/web/handlers_base.py b/src/web/handlers_base.py index 9575a4b3..96f81774 100644 --- a/src/web/handlers_base.py +++ b/src/web/handlers_base.py @@ -11,7 +11,7 @@ import time import tornado.locale import tornado.web -import backend.util +from .. import util class BaseHandler(tornado.web.RequestHandler): rss_url = None @@ -37,8 +37,8 @@ class BaseHandler(tornado.web.RequestHandler): today = datetime.date.today() ret = { - "format_size" : backend.util.format_size, - "format_time" : backend.util.format_time, + "format_size" : util.format_size, + "format_time" : util.format_time, "hostname" : self.hostname, "rss_url" : self.rss_url, "year" : today.year, diff --git a/src/web/handlers_boot.py b/src/web/handlers_boot.py index 0fc23c03..3922ad46 100644 --- a/src/web/handlers_boot.py +++ b/src/web/handlers_boot.py @@ -8,8 +8,6 @@ import tornado.locale import tornado.options import tornado.web -import backend - from handlers_base import BaseHandler BASEDIR = os.path.dirname(__file__) diff --git a/src/web/handlers_download.py b/src/web/handlers_download.py index 8efe74cf..406d47a8 100644 --- a/src/web/handlers_download.py +++ b/src/web/handlers_download.py @@ -4,8 +4,6 @@ import logging import random import tornado.web -import backend - from handlers_base import * class DownloadsIndexHandler(BaseHandler): diff --git a/src/web/handlers_fireinfo.py b/src/web/handlers_fireinfo.py index bc3d102f..580a3c73 100644 --- a/src/web/handlers_fireinfo.py +++ b/src/web/handlers_fireinfo.py @@ -6,10 +6,10 @@ import datetime import hwdata import logging import re -import simplejson +import json import tornado.web -import backend +from .. import fireinfo from handlers_base import * @@ -135,8 +135,8 @@ class FireinfoProfileSendHandler(FireinfoBaseHandler): # Try to decode the profile. try: - return simplejson.loads(profile) - except simplejson.decoder.JSONDecodeError, e: + return json.loads(profile) + except json.decoder.JSONDecodeError, e: raise tornado.web.HTTPError(400, "Profile could not be decoded: %s" % e) # The GET method is only allowed in debugging mode. @@ -160,7 +160,7 @@ class FireinfoProfileSendHandler(FireinfoBaseHandler): try: self.fireinfo.handle_profile(public_id, profile_blob, location=location) - except backend.fireinfo.ProfileParserError: + except fireinfo.ProfileParserError: raise tornado.web.HTTPError(400) self.finish("Your profile was successfully saved to the database.") diff --git a/src/web/handlers_iuse.py b/src/web/handlers_iuse.py index 4fce56d8..66f982be 100644 --- a/src/web/handlers_iuse.py +++ b/src/web/handlers_iuse.py @@ -7,7 +7,6 @@ import random import tornado.web from handlers_base import * -import backend class IUseImage(BaseHandler): expires = 3600 * 3 diff --git a/src/web/handlers_rss.py b/src/web/handlers_rss.py index 0ea9b4d8..8d3257f9 100644 --- a/src/web/handlers_rss.py +++ b/src/web/handlers_rss.py @@ -3,7 +3,7 @@ import logging import textile -import backend +from .. import database from handlers_base import * @@ -64,7 +64,7 @@ class RSSNewsHandler(RSSHandler): # Render text n.text = textile.textile(n.text.decode("utf-8")) - item = backend.database.Row({ + item = database.Row({ "title" : n.title, "author" : n.author, "published" : n.published, diff --git a/src/web/ui_modules.py b/src/web/ui_modules.py index 945af36e..67a4d75a 100644 --- a/src/web/ui_modules.py +++ b/src/web/ui_modules.py @@ -13,7 +13,7 @@ import tornado.locale import tornado.web import unicodedata -import backend +from .. import database class UIModule(tornado.web.UIModule): @property @@ -113,7 +113,7 @@ class FireinfoGeoTableModule(UIModule): other_countries.append(name) continue - country = backend.database.Row({ + country = database.Row({ "code" : code, "name" : name, "value" : value,