forked from p15670423/monkey
PEP8 + Python exceptions
This commit is contained in:
parent
b77aa5d10c
commit
b668a0d0f3
|
@ -1,7 +1,8 @@
|
||||||
import sys
|
|
||||||
import ctypes
|
import ctypes
|
||||||
import logging
|
import logging
|
||||||
|
import sys
|
||||||
from abc import ABCMeta, abstractmethod
|
from abc import ABCMeta, abstractmethod
|
||||||
|
|
||||||
from config import WormConfiguration
|
from config import WormConfiguration
|
||||||
|
|
||||||
__author__ = 'itamar'
|
__author__ = 'itamar'
|
||||||
|
@ -28,7 +29,7 @@ class _SystemSingleton(object):
|
||||||
|
|
||||||
class WindowsSystemSingleton(_SystemSingleton):
|
class WindowsSystemSingleton(_SystemSingleton):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._mutex_name = r"Global\%s" % (WormConfiguration.singleton_mutex_name, )
|
self._mutex_name = r"Global\%s" % (WormConfiguration.singleton_mutex_name,)
|
||||||
self._mutex_handle = None
|
self._mutex_handle = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -84,7 +85,7 @@ class LinuxSystemSingleton(_SystemSingleton):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sock.bind('\0' + self._unix_sock_name)
|
sock.bind('\0' + self._unix_sock_name)
|
||||||
except socket.error, e:
|
except socket.error as e:
|
||||||
LOG.error("Cannot acquire system singleton %r, error code %d, error: %s",
|
LOG.error("Cannot acquire system singleton %r, error code %d, error: %s",
|
||||||
self._unix_sock_name, e.args[0], e.args[1])
|
self._unix_sock_name, e.args[0], e.args[1])
|
||||||
return False
|
return False
|
||||||
|
@ -100,9 +101,12 @@ class LinuxSystemSingleton(_SystemSingleton):
|
||||||
self._sock_handle.close()
|
self._sock_handle.close()
|
||||||
self._sock_handle = None
|
self._sock_handle = None
|
||||||
|
|
||||||
|
|
||||||
if sys.platform == "win32":
|
if sys.platform == "win32":
|
||||||
import winerror
|
import winerror
|
||||||
|
|
||||||
SystemSingleton = WindowsSystemSingleton
|
SystemSingleton = WindowsSystemSingleton
|
||||||
else:
|
else:
|
||||||
import socket
|
import socket
|
||||||
|
|
||||||
SystemSingleton = LinuxSystemSingleton
|
SystemSingleton = LinuxSystemSingleton
|
||||||
|
|
Loading…
Reference in New Issue