/mandos/trunk

To get this branch, use:
bzr branch http://bzr.recompile.se/loggerhead/mandos/trunk

« back to all changes in this revision

Viewing changes to mandos

  • Committer: Teddy Hogeborn
  • Date: 2015-04-03 03:01:02 UTC
  • Revision ID: teddy@recompile.se-20150403030102-xdxyaqcwc4wmqeyb
mandos: Do minor formatting and whitespace adjustments.

Show diffs side-by-side

added added

removed removed

Lines of Context:
36
36
 
37
37
from future_builtins import *
38
38
 
39
 
try:
40
 
    import SocketServer as socketserver
41
 
except ImportError:
42
 
    import socketserver
 
39
import SocketServer as socketserver
43
40
import socket
44
41
import argparse
45
42
import datetime
50
47
import gnutls.library.functions
51
48
import gnutls.library.constants
52
49
import gnutls.library.types
53
 
try:
54
 
    import ConfigParser as configparser
55
 
except ImportError:
56
 
    import configparser
 
50
import ConfigParser as configparser
57
51
import sys
58
52
import re
59
53
import os
68
62
import struct
69
63
import fcntl
70
64
import functools
71
 
try:
72
 
    import cPickle as pickle
73
 
except ImportError:
74
 
    import pickle
 
65
import cPickle as pickle
75
66
import multiprocessing
76
67
import types
77
68
import binascii
78
69
import tempfile
79
70
import itertools
80
71
import collections
81
 
import codecs
82
72
 
83
73
import dbus
84
74
import dbus.service
85
 
try:
86
 
    import gobject
87
 
except ImportError:
88
 
    from gi.repository import GObject as gobject
 
75
import gobject
89
76
import avahi
90
77
from dbus.mainloop.glib import DBusGMainLoop
91
78
import ctypes
2511
2498
            pidfilename = "/var/run/mandos.pid"
2512
2499
        pidfile = None
2513
2500
        try:
2514
 
            pidfile = codecs.open(pidfilename, "w", encoding="utf-8")
 
2501
            pidfile = open(pidfilename, "w")
2515
2502
        except IOError as e:
2516
2503
            logger.error("Could not open file %r", pidfilename,
2517
2504
                         exc_info=e)
2576
2563
            old_bus_name = dbus.service.BusName(
2577
2564
                "se.bsnet.fukt.Mandos", bus,
2578
2565
                do_not_queue=True)
2579
 
        except dbus.exceptions.DBusException as e:
 
2566
        except dbus.exceptions.NameExistsException as e:
2580
2567
            logger.error("Disabling D-Bus:", exc_info=e)
2581
2568
            use_dbus = False
2582
2569
            server_settings["use_dbus"] = False
2713
2700
    
2714
2701
    if not foreground:
2715
2702
        if pidfile is not None:
2716
 
            pid = os.getpid()
2717
2703
            try:
2718
2704
                with pidfile:
2719
 
                    print(pid, file=pidfile)
 
2705
                    pid = os.getpid()
 
2706
                    pidfile.write("{}\n".format(pid).encode("utf-8"))
2720
2707
            except IOError:
2721
2708
                logger.error("Could not write to file %r with PID %d",
2722
2709
                             pidfilename, pid)