Kaydet (Commit) 5b364139 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

util parçalanması sonrası değişimler yapıldı

üst 561c2629
......@@ -28,6 +28,7 @@ import inary.context as ctx
import inary.configfile
import inary.errors
import inary.util
from inary.util import Singleton
class Error(inary.errors.Error):
pass
......@@ -42,7 +43,8 @@ class Options(object):
def __setattr__(self, name, value):
self.__dict__[name] = value
class Config(object, metaclass=inary.util.Singleton):
class Config(object, metaclass=Singleton):
"""Config Singleton"""
def __init__(self, options = Options()):
......
......@@ -20,7 +20,16 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
from inary.util import Singleton
class Singleton(type):
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(name, bases, dict)
cls.instance = None
def __call__(cls, *args, **kw):
if cls.instance is None:
cls.instance = super(Singleton, cls).__call__(*args, **kw)
return cls.instance
class _constant:
"Constant members implementation"
......
......@@ -18,9 +18,8 @@ import time
import inary.context as ctx
import inary.util as util
from .. import strutils
# lower borks for international locales. What we want is ascii lower.
lower_map = str.maketrans(strutils.ascii_uppercase, strutils.ascii_lowercase)
lower_map = str.maketrans(util.ascii_uppercase, util.ascii_lowercase)
class Singleton(object):
......
......@@ -14,7 +14,6 @@
import os
import time
from . import strutils
import gettext
__trans = gettext.translation('inary', fallback=True)
......@@ -23,6 +22,7 @@ _ = __trans.gettext
import inary.api
import inary.context as ctx
import inary.errors
import inary.util as util
class Error(inary.errors.Error):
pass
......@@ -36,7 +36,7 @@ except ImportError:
def is_char_valid(char):
"""Test if char is valid object path character."""
return char in strutils.ascii_letters + strutils.digits + "_"
return char in util.ascii_letters + util.digits + "_"
def is_method_missing(exception):
"""Tells if exception is about missing method in SCOM script"""
......@@ -84,9 +84,15 @@ def get_link():
link.setLocale()
return link
except dbus.exceptions.DBusException as e:
exceptions.append(str(e))
except Exception as e:
exceptions.append(str(e))
if str(e) in exceptions:
pass
else:
exceptions.append(str(e))
except Exception as e:
if str(e) in exceptions:
pass
else:
exceptions.append(str(e))
time.sleep(0.2)
timeout -= 0.2
raise Error(_("Cannot connect to SCOM: \n {}\n").format("\n ".join(exceptions)))
......
......@@ -53,7 +53,7 @@ class UI(object):
def set_debug(self, flag):
self.show_debug = flag
def info(self, msg, verbose = False, noln = False):
def info(self, msg, verbose = False, noln = False,color='default'):
"give an informative message"
pass
......
......@@ -18,7 +18,6 @@ __trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import inary
import inary.context as ctx
from .file_utils import *
from .package_utils import *
......@@ -26,3 +25,14 @@ from .path_utils import *
from .process_utils import *
from .term_utils import *
from .type_utils import *
class Singleton(type):
def __init__(cls, name, bases, dict):
super(Singleton, cls).__init__(name, bases, dict)
cls.instance = None
def __call__(cls, *args, **kw):
if cls.instance is None:
cls.instance = super(Singleton, cls).__call__(*args, **kw)
return cls.instance
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment