comparison sat/tools/utils.py @ 2793:181735d1b062

plugin mr mercurial, tools(common/utils): moved command protocol to a new module
author Goffi <goffi@goffi.org>
date Fri, 25 Jan 2019 09:06:29 +0100
parents 003b8b4b56a7
children ab2696e34d29
comparison
equal deleted inserted replaced
2792:441b536e28ed 2793:181735d1b062
19 19
20 """ various useful methods """ 20 """ various useful methods """
21 21
22 import unicodedata 22 import unicodedata
23 import os.path 23 import os.path
24 from sat.core.constants import Const as C
25 from sat.core.log import getLogger
26
27 log = getLogger(__name__)
28 import datetime 24 import datetime
29 from twisted.python import procutils
30 import subprocess 25 import subprocess
31 import time 26 import time
32 import sys 27 import sys
33 import random 28 import random
34 import inspect 29 import inspect
35 import textwrap 30 import textwrap
36 import functools 31 import functools
32 from twisted.python import procutils
33 from sat.core.constants import Const as C
34 from sat.core.log import getLogger
35
36 log = getLogger(__name__)
37 37
38 38
39 NO_REPOS_DATA = u"repository data unknown" 39 NO_REPOS_DATA = u"repository data unknown"
40 repos_cache_dict = None 40 repos_cache_dict = None
41 repos_cache = None 41 repos_cache = None
52 if unicodedata.category(char) == "Cc" and char != "\n": 52 if unicodedata.category(char) == "Cc" and char != "\n":
53 continue 53 continue
54 yield char 54 yield char
55 55
56 return "".join(valid_chars(ustr)) 56 return "".join(valid_chars(ustr))
57
58
59 def logError(failure_):
60 """Genertic errback which log the error as a warning, and re-raise it"""
61 log.warning(failure_.value)
62 raise failure_
57 63
58 64
59 def partial(func, *fixed_args, **fixed_kwargs): 65 def partial(func, *fixed_args, **fixed_kwargs):
60 # FIXME: temporary hack to workaround the fact that inspect.getargspec is not working with functools.partial 66 # FIXME: temporary hack to workaround the fact that inspect.getargspec is not working with functools.partial
61 # making partial unusable with current D-bus module (in addMethod). 67 # making partial unusable with current D-bus module (in addMethod).