Use relative imports
This commit is contained in:
parent
9f446cb261
commit
98bbe61f67
@ -46,7 +46,7 @@ except ImportError:
|
|||||||
from urlparse import urlparse
|
from urlparse import urlparse
|
||||||
# pylint: enable=F0401,E0611
|
# pylint: enable=F0401,E0611
|
||||||
|
|
||||||
from radicale import auth, config, ical, log, rights, storage, xmlutils
|
from . import auth, config, ical, log, rights, storage, xmlutils
|
||||||
|
|
||||||
|
|
||||||
VERSION = "git"
|
VERSION = "git"
|
||||||
|
@ -32,7 +32,8 @@ import signal
|
|||||||
import threading
|
import threading
|
||||||
from wsgiref.simple_server import make_server
|
from wsgiref.simple_server import make_server
|
||||||
|
|
||||||
import radicale
|
from . import (
|
||||||
|
Application, config, HTTPServer, HTTPSServer, log, RequestHandler, VERSION)
|
||||||
|
|
||||||
|
|
||||||
# This is a script, many branches and variables
|
# This is a script, many branches and variables
|
||||||
@ -41,40 +42,40 @@ import radicale
|
|||||||
def run():
|
def run():
|
||||||
"""Run Radicale as a standalone server."""
|
"""Run Radicale as a standalone server."""
|
||||||
# Get command-line options
|
# Get command-line options
|
||||||
parser = optparse.OptionParser(version=radicale.VERSION)
|
parser = optparse.OptionParser(version=VERSION)
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-d", "--daemon", action="store_true",
|
"-d", "--daemon", action="store_true",
|
||||||
default=radicale.config.getboolean("server", "daemon"),
|
default=config.getboolean("server", "daemon"),
|
||||||
help="launch as daemon")
|
help="launch as daemon")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-p", "--pid",
|
"-p", "--pid",
|
||||||
default=radicale.config.get("server", "pid"),
|
default=config.get("server", "pid"),
|
||||||
help="set PID filename for daemon mode")
|
help="set PID filename for daemon mode")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-f", "--foreground", action="store_false", dest="daemon",
|
"-f", "--foreground", action="store_false", dest="daemon",
|
||||||
help="launch in foreground (opposite of --daemon)")
|
help="launch in foreground (opposite of --daemon)")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-H", "--hosts",
|
"-H", "--hosts",
|
||||||
default=radicale.config.get("server", "hosts"),
|
default=config.get("server", "hosts"),
|
||||||
help="set server hostnames and ports")
|
help="set server hostnames and ports")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-s", "--ssl", action="store_true",
|
"-s", "--ssl", action="store_true",
|
||||||
default=radicale.config.getboolean("server", "ssl"),
|
default=config.getboolean("server", "ssl"),
|
||||||
help="use SSL connection")
|
help="use SSL connection")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-S", "--no-ssl", action="store_false", dest="ssl",
|
"-S", "--no-ssl", action="store_false", dest="ssl",
|
||||||
help="do not use SSL connection (opposite of --ssl)")
|
help="do not use SSL connection (opposite of --ssl)")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-k", "--key",
|
"-k", "--key",
|
||||||
default=radicale.config.get("server", "key"),
|
default=config.get("server", "key"),
|
||||||
help="set private key file")
|
help="set private key file")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-c", "--certificate",
|
"-c", "--certificate",
|
||||||
default=radicale.config.get("server", "certificate"),
|
default=config.get("server", "certificate"),
|
||||||
help="set certificate file")
|
help="set certificate file")
|
||||||
parser.add_option(
|
parser.add_option(
|
||||||
"-D", "--debug", action="store_true",
|
"-D", "--debug", action="store_true",
|
||||||
default=radicale.config.getboolean("logging", "debug"),
|
default=config.getboolean("logging", "debug"),
|
||||||
help="print debug information")
|
help="print debug information")
|
||||||
options = parser.parse_args()[0]
|
options = parser.parse_args()[0]
|
||||||
|
|
||||||
@ -84,10 +85,10 @@ def run():
|
|||||||
if key:
|
if key:
|
||||||
section = "logging" if key == "debug" else "server"
|
section = "logging" if key == "debug" else "server"
|
||||||
value = getattr(options, key)
|
value = getattr(options, key)
|
||||||
radicale.config.set(section, key, str(value))
|
config.set(section, key, str(value))
|
||||||
|
|
||||||
# Start logging
|
# Start logging
|
||||||
radicale.log.start()
|
log.start()
|
||||||
|
|
||||||
# Fork if Radicale is launched as daemon
|
# Fork if Radicale is launched as daemon
|
||||||
if options.daemon:
|
if options.daemon:
|
||||||
@ -105,25 +106,25 @@ def run():
|
|||||||
# Register exit function
|
# Register exit function
|
||||||
def cleanup():
|
def cleanup():
|
||||||
"""Remove the PID files."""
|
"""Remove the PID files."""
|
||||||
radicale.log.LOGGER.debug("Cleaning up")
|
log.LOGGER.debug("Cleaning up")
|
||||||
# Remove PID file
|
# Remove PID file
|
||||||
if options.pid and options.daemon:
|
if options.pid and options.daemon:
|
||||||
os.unlink(options.pid)
|
os.unlink(options.pid)
|
||||||
|
|
||||||
atexit.register(cleanup)
|
atexit.register(cleanup)
|
||||||
radicale.log.LOGGER.info("Starting Radicale")
|
log.LOGGER.info("Starting Radicale")
|
||||||
|
|
||||||
# Create collection servers
|
# Create collection servers
|
||||||
servers = []
|
servers = []
|
||||||
server_class = radicale.HTTPSServer if options.ssl else radicale.HTTPServer
|
server_class = HTTPSServer if options.ssl else HTTPServer
|
||||||
shutdown_program = threading.Event()
|
shutdown_program = threading.Event()
|
||||||
|
|
||||||
for host in options.hosts.split(","):
|
for host in options.hosts.split(","):
|
||||||
address, port = host.strip().rsplit(":", 1)
|
address, port = host.strip().rsplit(":", 1)
|
||||||
address, port = address.strip("[] "), int(port)
|
address, port = address.strip("[] "), int(port)
|
||||||
servers.append(
|
servers.append(
|
||||||
make_server(address, port, radicale.Application(),
|
make_server(address, port, Application(),
|
||||||
server_class, radicale.RequestHandler))
|
server_class, RequestHandler))
|
||||||
|
|
||||||
# SIGTERM and SIGINT (aka KeyboardInterrupt) should just mark this for
|
# SIGTERM and SIGINT (aka KeyboardInterrupt) should just mark this for
|
||||||
# shutdown
|
# shutdown
|
||||||
@ -141,14 +142,14 @@ def run():
|
|||||||
# when a server exists but another server is added to the list at the same
|
# when a server exists but another server is added to the list at the same
|
||||||
# time
|
# time
|
||||||
for server in servers:
|
for server in servers:
|
||||||
radicale.log.LOGGER.debug(
|
log.LOGGER.debug(
|
||||||
"Listening to %s port %s" % (
|
"Listening to %s port %s" % (
|
||||||
server.server_name, server.server_port))
|
server.server_name, server.server_port))
|
||||||
if options.ssl:
|
if options.ssl:
|
||||||
radicale.log.LOGGER.debug("Using SSL")
|
log.LOGGER.debug("Using SSL")
|
||||||
threading.Thread(target=serve_forever, args=(server,)).start()
|
threading.Thread(target=serve_forever, args=(server,)).start()
|
||||||
|
|
||||||
radicale.log.LOGGER.debug("Radicale server ready")
|
log.LOGGER.debug("Radicale server ready")
|
||||||
|
|
||||||
# Main loop: wait until all servers are exited
|
# Main loop: wait until all servers are exited
|
||||||
try:
|
try:
|
||||||
@ -165,10 +166,10 @@ def run():
|
|||||||
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
signal.signal(signal.SIGINT, signal.SIG_IGN)
|
||||||
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
signal.signal(signal.SIGTERM, signal.SIG_IGN)
|
||||||
|
|
||||||
radicale.log.LOGGER.info("Stopping Radicale")
|
log.LOGGER.info("Stopping Radicale")
|
||||||
|
|
||||||
for server in servers:
|
for server in servers:
|
||||||
radicale.log.LOGGER.debug(
|
log.LOGGER.debug(
|
||||||
"Closing server listening to %s port %s" % (
|
"Closing server listening to %s port %s" % (
|
||||||
server.server_name, server.server_port))
|
server.server_name, server.server_port))
|
||||||
server.shutdown()
|
server.shutdown()
|
||||||
|
@ -32,7 +32,7 @@ Python 3.2 or newer is required for TLS.
|
|||||||
|
|
||||||
import imaplib
|
import imaplib
|
||||||
|
|
||||||
from radicale import config, log
|
from .. import config, log
|
||||||
|
|
||||||
IMAP_SERVER = config.get("auth", "imap_auth_host_name")
|
IMAP_SERVER = config.get("auth", "imap_auth_host_name")
|
||||||
IMAP_SERVER_PORT = config.get("auth", "imap_auth_host_port")
|
IMAP_SERVER_PORT = config.get("auth", "imap_auth_host_port")
|
||||||
|
@ -26,7 +26,8 @@ Authentication based on the ``python-ldap`` module
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import ldap
|
import ldap
|
||||||
from radicale import config, log
|
|
||||||
|
from .. import config, log
|
||||||
|
|
||||||
|
|
||||||
BASE = config.get("auth", "ldap_base")
|
BASE = config.get("auth", "ldap_base")
|
||||||
|
@ -27,7 +27,7 @@ import grp
|
|||||||
import pam
|
import pam
|
||||||
import pwd
|
import pwd
|
||||||
|
|
||||||
from radicale import config, log
|
from .. import config, log
|
||||||
|
|
||||||
|
|
||||||
GROUP_MEMBERSHIP = config.get("auth", "pam_group_membership")
|
GROUP_MEMBERSHIP = config.get("auth", "pam_group_membership")
|
||||||
|
@ -25,7 +25,7 @@ Authentication management.
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from radicale import config, log
|
from .. import config, log
|
||||||
|
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
|
@ -24,7 +24,7 @@ Courier-Authdaemon authentication.
|
|||||||
import sys
|
import sys
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
from radicale import config, log
|
from .. import config, log
|
||||||
|
|
||||||
|
|
||||||
COURIER_SOCKET = config.get("auth", "courier_socket")
|
COURIER_SOCKET = config.get("auth", "courier_socket")
|
||||||
|
@ -30,7 +30,7 @@ supported, but md5 is not (see ``htpasswd`` man page to understand why).
|
|||||||
import base64
|
import base64
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
from radicale import config
|
from .. import config
|
||||||
|
|
||||||
|
|
||||||
FILENAME = config.get("auth", "htpasswd_filename")
|
FILENAME = config.get("auth", "htpasswd_filename")
|
||||||
|
@ -29,7 +29,7 @@ import sys
|
|||||||
import logging
|
import logging
|
||||||
import logging.config
|
import logging.config
|
||||||
|
|
||||||
from radicale import config
|
from . import config
|
||||||
|
|
||||||
|
|
||||||
LOGGER = logging.getLogger()
|
LOGGER = logging.getLogger()
|
||||||
|
@ -25,7 +25,7 @@ Rights management.
|
|||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from radicale import config, log
|
from .. import config, log
|
||||||
|
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
|
@ -24,7 +24,7 @@ configuration.
|
|||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
from radicale import config, ical
|
from .. import config, ical
|
||||||
|
|
||||||
|
|
||||||
def load():
|
def load():
|
||||||
|
@ -28,7 +28,7 @@ import json
|
|||||||
import time
|
import time
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
|
|
||||||
from radicale import config, ical
|
from .. import config, ical
|
||||||
|
|
||||||
|
|
||||||
FOLDER = os.path.expanduser(config.get("storage", "filesystem_folder"))
|
FOLDER = os.path.expanduser(config.get("storage", "filesystem_folder"))
|
||||||
|
@ -35,7 +35,7 @@ except ImportError:
|
|||||||
import re
|
import re
|
||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
|
|
||||||
from radicale import client, config, ical, rights
|
from . import client, config, ical, rights
|
||||||
|
|
||||||
|
|
||||||
NAMESPACES = {
|
NAMESPACES = {
|
||||||
|
Loading…
Reference in New Issue
Block a user