massive refactoring to switch from camelCase to snake_case:

historically, Libervia (SàT before) was using camelCase as allowed by PEP8 when using a
pre-PEP8 code, to use the same coding style as in Twisted.

However, snake_case is more readable and it's better to follow PEP8 best practices, so it
has been decided to move on full snake_case. Because Libervia has a huge codebase, this
ended with a ugly mix of camelCase and snake_case.

To fix that, this patch does a big refactoring by renaming every function and method
(including bridge) that are not coming from Twisted or Wokkel, to use fully snake_case.

This is a massive change, and may result in some bugs.
This commit is contained in:
Goffi 2023-04-08 13:54:42 +02:00
commit 6a6f15707a
202 changed files with 9945 additions and 9945 deletions

View file

@ -74,7 +74,7 @@ class Constructor(object):
function[option] = value
return function
def getDefault(self, name):
def get_default(self, name):
"""Return default values of a function in a dict
@param name: Name of the function to get
@return: dict, each key is the integer param number (no key if no default value)"""
@ -106,7 +106,7 @@ class Constructor(object):
flags.append(option)
return flags
def getArgumentsDoc(self, name):
def get_arguments_doc(self, name):
"""Return documentation of arguments
@param name: Name of the function to get
@return: dict, each key is the integer param number (no key if no argument doc), value is a tuple (name, doc)"""
@ -131,7 +131,7 @@ class Constructor(object):
doc_dict[idx] = (value_match.group(1), value_match.group(2))
return doc_dict
def getDoc(self, name):
def get_doc(self, name):
"""Return documentation of the method
@param name: Name of the function to get
@return: string documentation, or None"""
@ -139,7 +139,7 @@ class Constructor(object):
return self.bridge_template.get(name, "doc")
return None
def argumentsParser(self, signature):
def arguments_parser(self, signature):
"""Generator which return individual arguments signatures from a global signature"""
start = 0
i = 0
@ -176,19 +176,19 @@ class Constructor(object):
yield signature[start:i]
start = i
def getArguments(self, signature, name=None, default=None, unicode_protect=False):
def get_arguments(self, signature, name=None, default=None, unicode_protect=False):
"""Return arguments to user given a signature
@param signature: signature in the short form (using s,a,i,b etc)
@param name: dictionary of arguments name like given by getArgumentsDoc
@param default: dictionary of default values, like given by getDefault
@param name: dictionary of arguments name like given by get_arguments_doc
@param default: dictionary of default values, like given by get_default
@param unicode_protect: activate unicode protection on strings (return strings as unicode(str))
@return (str): arguments that correspond to a signature (e.g.: "sss" return "arg1, arg2, arg3")
"""
idx = 0
attr_string = []
for arg in self.argumentsParser(signature):
for arg in self.arguments_parser(signature):
attr_string.append(
(
"str(%(name)s)%(default)s"
@ -206,7 +206,7 @@ class Constructor(object):
return ", ".join(attr_string)
def getTemplatePath(self, template_file):
def get_template_path(self, template_file):
"""return template path corresponding to file name
@param template_file(str): name of template file
@ -232,12 +232,12 @@ class Constructor(object):
def generate(self, side):
"""generate bridge
call generateCoreSide or generateFrontendSide if they exists
call generate_core_side or generateFrontendSide if they exists
else call generic self._generate method
"""
try:
if side == "core":
method = self.generateCoreSide
method = self.generate_core_side
elif side == "frontend":
if not self.FRONTEND_ACTIVATE:
print("This constructor only handle core, please use core side")
@ -272,8 +272,8 @@ class Constructor(object):
for section in sections:
function = self.getValues(section)
print(("Adding %s %s" % (section, function["type"])))
default = self.getDefault(section)
arg_doc = self.getArgumentsDoc(section)
default = self.get_default(section)
arg_doc = self.get_arguments_doc(section)
async_ = "async" in self.getFlags(section)
completion = {
"sig_in": function["sig_in"] or "",
@ -281,10 +281,10 @@ class Constructor(object):
"category": "plugin" if function["category"] == "plugin" else "core",
"name": section,
# arguments with default values
"args": self.getArguments(
"args": self.get_arguments(
function["sig_in"], name=arg_doc, default=default
),
"args_no_default": self.getArguments(function["sig_in"], name=arg_doc),
"args_no_default": self.get_arguments(function["sig_in"], name=arg_doc),
}
extend_method = getattr(
@ -305,7 +305,7 @@ class Constructor(object):
for env, v in os.environ.items()
if env.startswith(C.ENV_OVERRIDE)
}
template_path = self.getTemplatePath(TEMPLATE)
template_path = self.get_template_path(TEMPLATE)
try:
with open(template_path) as template:
for line in template:
@ -332,9 +332,9 @@ class Constructor(object):
sys.exit(1)
# now we write to final file
self.finalWrite(DEST, bridge)
self.final_write(DEST, bridge)
def finalWrite(self, filename, file_buf):
def final_write(self, filename, file_buf):
"""Write the final generated file in [dest dir]/filename
@param filename: name of the file to generate

View file

@ -32,7 +32,7 @@ __version__ = C.APP_VERSION
class BridgeConstructor(object):
def importConstructors(self):
def import_constructors(self):
constructors_dir = os.path.dirname(constructors.__file__)
self.protocoles = {}
for dir_ in os.listdir(constructors_dir):
@ -120,7 +120,7 @@ class BridgeConstructor(object):
return parser.parse_args()
def go(self):
self.importConstructors()
self.import_constructors()
args = self.parse_args()
template_parser = Parser()
try:

View file

@ -20,7 +20,7 @@ sig_in=s
doc=Connection is finished or lost
doc_param_0=%(doc_profile)s
[newContact]
[contact_new]
type=signal
category=core
sig_in=sa{ss}ass
@ -34,7 +34,7 @@ doc_param_1=attributes: Dictionary of attributes where keys are:
doc_param_2=groups: Roster's groups where the contact is
doc_param_3=%(doc_profile)s
[messageNew]
[message_new]
type=signal
category=core
sig_in=sdssa{ss}a{ss}sss
@ -54,7 +54,7 @@ doc_param_7=extra: extra message information, can have data added by plugins and
- info_type: subtype for info messages
doc_param_8=%(doc_profile)s
[messageEncryptionStarted]
[message_encryption_started]
type=signal
category=core
sig_in=sss
@ -68,7 +68,7 @@ doc_param_1=encryption_data: (JSON_OBJ) data of the encryption algorithm used, e
- directed_devices: list or resource where session is encrypted
doc_param_2=%(doc_profile_key)s
[messageEncryptionStopped]
[message_encryption_stopped]
type=signal
category=core
sig_in=sa{ss}s
@ -79,7 +79,7 @@ doc_param_1=encryption_data: data of the encryption algorithm stopped, has a lea
- namespace: namespace of the encryption plugin
doc_param_2=%(doc_profile_key)s
[presenceUpdate]
[presence_update]
type=signal
category=core
sig_in=ssia{ss}s
@ -99,7 +99,7 @@ doc_param_0=sub_type: Subscription states (see RFC 6121 §3)
doc_param_1=entity_jid: JID from which the subscription is coming
doc_param_2=%(doc_profile)s
[paramUpdate]
[param_update]
type=signal
category=core
sig_in=ssss
@ -109,7 +109,7 @@ doc_param_1=value: New value of the parameter
doc_param_2=category: Category of the updated parameter
doc_param_3=%(doc_profile)s
[contactDeleted]
[contact_deleted]
type=signal
category=core
sig_in=ss
@ -117,7 +117,7 @@ doc=A contact has been supressed from roster
doc_param_0=entity_jid: JID of the contact removed from roster
doc_param_1=%(doc_profile)s
[actionNew]
[action_new]
type=signal
category=core
sig_in=a{ss}sis
@ -137,7 +137,7 @@ doc_param_1=id: action id
doc_param_2=%(doc_security_limit)s
doc_param_3=%(doc_profile)s
[entityDataUpdated]
[entity_data_updated]
type=signal
category=core
sig_in=ssss
@ -147,7 +147,7 @@ doc_param_1=name: Name of the updated value
doc_param_2=value: New value
doc_param_3=%(doc_profile)s
[progressStarted]
[progress_started]
type=signal
category=core
sig_in=sa{ss}s
@ -160,7 +160,7 @@ doc_param_1=metadata: dict of progress metadata, key can be:
C.META_TYPE_FILE: file transfer
doc_param_2=%(doc_profile)s
[progressFinished]
[progress_finished]
type=signal
category=core
sig_in=sa{ss}s
@ -170,11 +170,11 @@ doc_param_1=metadata: dict of progress status metadata, key can be:
- hash: value of the computed hash
- hash_algo: alrorithm used to compute hash
- hash_verified: C.BOOL_TRUE if hash is verified and OK
C.BOOL_FALSE if hash was not received ([progressError] will be used if there is a mismatch)
C.BOOL_FALSE if hash was not received ([progress_error] will be used if there is a mismatch)
- url: url linked to the progression (e.g. download url after a file upload)
doc_param_2=%(doc_profile)s
[progressError]
[progress_error]
type=signal
category=core
sig_in=sss
@ -194,7 +194,7 @@ doc_param_2=%(doc_profile)s
;methods
[getReady]
[ready_get]
async=
type=method
category=core
@ -202,14 +202,14 @@ sig_in=
sig_out=
doc=Return when backend is initialised
[getVersion]
[version_get]
type=method
category=core
sig_in=
sig_out=s
doc=Get "Salut à Toi" full version
[getFeatures]
[features_get]
type=method
category=core
sig_in=s
@ -221,7 +221,7 @@ doc_return=dictionary of available features:
plugin import name is used as key, data is an other dict managed by the plugin
async=
[profileNameGet]
[profile_name_get]
type=method
category=core
sig_in=s
@ -231,7 +231,7 @@ doc=Get real profile name from profile key
doc_param_0=%(doc_profile_key)s
doc_return=Real profile name
[profilesListGet]
[profiles_list_get]
type=method
category=core
sig_in=bb
@ -242,7 +242,7 @@ doc_param_0=clients: get clients profiles
doc_param_1=components: get components profiles
doc=Get list of profiles
[profileSetDefault]
[profile_set_default]
type=method
category=core
sig_in=s
@ -250,7 +250,7 @@ sig_out=
doc_param_0=%(doc_profile)s
doc=Set default profile
[getEntityData]
[entity_data_get]
type=method
category=core
sig_in=sass
@ -262,7 +262,7 @@ doc_param_2=%(doc_profile)s
doc_return=dictionary of asked key,
if key doesn't exist, the resulting dictionary will not have the key
[getEntitiesData]
[entities_data_get]
type=method
category=core
sig_in=asass
@ -275,7 +275,7 @@ doc_return=dictionary with jids as keys and dictionary of asked key as values
values are serialised
if key doesn't exist for a jid, the resulting dictionary will not have it
[profileCreate]
[profile_create]
async=
type=method
category=core
@ -293,7 +293,7 @@ errback is called with error constant as parameter:
- CancelError: profile creation canceled
- NotFound: component entry point is not available
[asyncDeleteProfile]
[profile_delete_async]
async=
type=method
category=core
@ -325,7 +325,7 @@ doc_return=a deferred boolean or failure:
- False if the XMPP connection has been initiated (it may still fail)
- failure if the profile authentication failed
[profileStartSession]
[profile_start_session]
async=
type=method
category=core
@ -340,7 +340,7 @@ doc_return=D(bool):
- True if the profile session was already started
- False else
[profileIsSessionStarted]
[profile_is_session_started]
type=method
category=core
sig_in=s
@ -359,7 +359,7 @@ param_0_default="@DEFAULT@"
doc=Disconnect a profile
doc_param_0=%(doc_profile_key)s
[isConnected]
[is_connected]
type=method
category=core
sig_in=s
@ -368,7 +368,7 @@ param_0_default="@DEFAULT@"
doc=Tell if a profile is connected
doc_param_0=%(doc_profile_key)s
[contactGet]
[contact_get]
async=
type=method
category=core
@ -378,10 +378,10 @@ param_1_default="@DEFAULT@"
doc=Return informations in roster about a contact
doc_param_1=%(doc_profile_key)s
doc_return=tuple with the following values:
- list of attributes as in [newContact]
- list of attributes as in [contact_new]
- groups where the contact is
[getContacts]
[contacts_get]
async=
type=method
category=core
@ -392,10 +392,10 @@ doc=Return information about all contacts (the roster)
doc_param_0=%(doc_profile_key)s
doc_return=array of tuples with the following values:
- JID of the contact
- list of attributes as in [newContact]
- list of attributes as in [contact_new]
- groups where the contact is
[getContactsFromGroup]
[contacts_get_from_group]
type=method
category=core
sig_in=ss
@ -406,7 +406,7 @@ doc_param_0=group: name of the group to check
doc_param_1=%(doc_profile_key)s
doc_return=array of jids
[getMainResource]
[main_resource_get]
type=method
category=core
sig_in=ss
@ -417,7 +417,7 @@ doc_param_0=contact_jid: jid of the contact
doc_param_1=%(doc_profile_key)s
doc_return=the resource connected of the contact with highest priority, or ""
[getPresenceStatuses]
[presence_statuses_get]
type=method
category=core
sig_in=s
@ -426,9 +426,9 @@ param_0_default="@DEFAULT@"
doc=Return presence information of all contacts
doc_param_0=%(doc_profile_key)s
doc_return=Dict of presence with bare JID of contact as key, and value as follow:
A dict where key is the resource and the value is a tuple with (show, priority, statuses) as for [presenceUpdate]
A dict where key is the resource and the value is a tuple with (show, priority, statuses) as for [presence_update]
[getWaitingSub]
[sub_waiting_get]
type=method
category=core
sig_in=s
@ -438,7 +438,7 @@ doc=Get subscription requests in queue
doc_param_0=%(doc_profile_key)s
doc_return=Dict where contact JID is the key, and value is the subscription type
[messageSend]
[message_send]
async=
type=method
category=core
@ -458,7 +458,7 @@ doc_param_3=mess_type: Type of the message (cf RFC 6121 §5.2.2) or "auto" for a
doc_param_4=extra: (serialised) optional data that can be used by a plugin to build more specific messages
doc_param_5=%(doc_profile_key)s
[messageEncryptionStart]
[message_encryption_start]
async=
type=method
category=core
@ -474,7 +474,7 @@ doc_param_2=replace: if True and an encryption session already exists, it will b
else a ConflictError will be raised
doc_param_3=%(doc_profile_key)s
[messageEncryptionStop]
[message_encryption_stop]
async=
type=method
category=core
@ -484,7 +484,7 @@ doc=Stop an encryption session
doc_param_0=to_jid: JID of the recipient (full jid if encryption must be stopped for one device only)
doc_param_1=%(doc_profile_key)s
[messageEncryptionGet]
[message_encryption_get]
type=method
category=core
sig_in=ss
@ -499,21 +499,21 @@ doc_return=(JSON_OBJ) empty string if session is unencrypted, else a json encode
following key can be present if suitable:
- directed_devices: list or resource where session is encrypted
[encryptionNamespaceGet]
[encryption_namespace_get]
type=method
category=core
sig_in=s
sig_out=s
doc=Get algorithm namespace from its name
[encryptionPluginsGet]
[encryption_plugins_get]
type=method
category=core
sig_in=
sig_out=s
doc=Retrieve registered plugins for encryption
[encryptionTrustUIGet]
[encryption_trust_ui_get]
async=
type=method
category=core
@ -525,7 +525,7 @@ doc_param_1=namespace: namespace of the algorithm to manage
doc_param_2=%(doc_profile_key)s
doc_return=(XMLUI) UI of the trust management
[setPresence]
[presence_set]
type=method
category=core
sig_in=ssa{ss}s
@ -536,8 +536,8 @@ param_2_default={}
param_3_default="@DEFAULT@"
doc=Set presence information for the profile
doc_param_0=to_jid: the JID to who we send the presence data (emtpy string for broadcast)
doc_param_1=show: as for [presenceUpdate]
doc_param_2=statuses: as for [presenceUpdate]
doc_param_1=show: as for [presence_update]
doc_param_2=statuses: as for [presence_update]
doc_param_3=%(doc_profile_key)s
[subscription]
@ -551,7 +551,7 @@ doc_param_0=sub_type: as for [subscribe]
doc_param_1=entity: as for [subscribe]
doc_param_2=%(doc_profile_key)s
[getConfig]
[config_get]
type=method
category=core
sig_in=ss
@ -560,7 +560,7 @@ doc=get main configuration option
doc_param_0=section: section of the configuration file (empty string for DEFAULT)
doc_param_1=name: name of the option
[setParam]
[param_set]
type=method
category=core
sig_in=sssis
@ -574,7 +574,7 @@ doc_param_2=category: Category of the parameter to change
doc_param_3=%(doc_security_limit)s
doc_param_4=%(doc_profile_key)s
[getParamA]
[param_get_a]
type=method
category=core
sig_in=ssss
@ -582,12 +582,12 @@ sig_out=s
param_2_default="value"
param_3_default="@DEFAULT@"
doc=Helper method to get a parameter's attribute *when profile is connected*
doc_param_0=name: as for [setParam]
doc_param_1=category: as for [setParam]
doc_param_0=name: as for [param_set]
doc_param_1=category: as for [param_set]
doc_param_2=attribute: Name of the attribute
doc_param_3=%(doc_profile_key)s
[privateDataGet]
[private_data_get]
async=
type=method
category=core
@ -599,7 +599,7 @@ doc_param_1=key: key of the data to set
doc_param_2=%(doc_profile_key)s
doc_return=serialised data
[privateDataSet]
[private_data_set]
async=
type=method
category=core
@ -611,7 +611,7 @@ doc_param_1=key: key of the data to set
doc_param_2=data: serialised data
doc_param_3=%(doc_profile_key)s
[privateDataDelete]
[private_data_delete]
async=
type=method
category=core
@ -622,7 +622,7 @@ doc_param_0=namespace: unique namespace to use
doc_param_1=key: key of the data to delete
doc_param_3=%(doc_profile_key)s
[asyncGetParamA]
[param_get_a_async]
async=
type=method
category=core
@ -632,13 +632,13 @@ param_2_default="value"
param_3_default=-1
param_4_default="@DEFAULT@"
doc=Helper method to get a parameter's attribute
doc_param_0=name: as for [setParam]
doc_param_1=category: as for [setParam]
doc_param_0=name: as for [param_set]
doc_param_1=category: as for [param_set]
doc_param_2=attribute: Name of the attribute
doc_param_3=%(doc_security_limit)s
doc_param_4=%(doc_profile_key)s
[asyncGetParamsValuesFromCategory]
[params_values_from_category_get_async]
async=
type=method
category=code
@ -649,13 +649,13 @@ param_2_default=""
param_3_default=""
param_4_default="@DEFAULT@"
doc=Get "attribute" for all params of a category
doc_param_0=category: as for [setParam]
doc_param_0=category: as for [param_set]
doc_param_1=%(doc_security_limit)s
doc_param_2=app: name of the frontend requesting the parameters, or '' to get all parameters
doc_param_3=extra: extra options/filters
doc_param_4=%(doc_profile_key)s
[getParamsUI]
[param_ui_get]
async=
type=method
category=core
@ -671,7 +671,7 @@ doc_param_1=app: name of the frontend requesting the parameters, or '' to get al
doc_param_2=extra: extra options/filters
doc_param_3=%(doc_profile_key)s
[getParamsCategories]
[params_categories_get]
type=method
category=core
sig_in=
@ -679,7 +679,7 @@ sig_out=as
doc=Get all categories currently existing in parameters
doc_return=list of categories
[paramsRegisterApp]
[params_register_app]
type=method
category=core
sig_in=sis
@ -691,7 +691,7 @@ doc_param_0=xml: XML definition of the parameters to be added
doc_param_1=%(doc_security_limit)s
doc_param_2=app: name of the frontend registering the parameters
[historyGet]
[history_get]
async=
type=method
category=core
@ -712,9 +712,9 @@ doc_param_4=filters: patterns to filter the history results, can be:
- not_types: type must not be one of those, values are separated by spaces
- before_uid: check only message received before message with given uid
doc_param_5=%(doc_profile)s
doc_return=Ordered list (by timestamp) of data as in [messageNew] (without final profile)
doc_return=Ordered list (by timestamp) of data as in [message_new] (without final profile)
[addContact]
[contact_add]
type=method
category=core
sig_in=ss
@ -724,7 +724,7 @@ doc=Add a contact to profile's roster
doc_param_0=entity_jid: JID to add to roster
doc_param_1=%(doc_profile_key)s
[updateContact]
[contact_update]
type=method
category=core
sig_in=ssass
@ -736,7 +736,7 @@ doc_param_1=name: roster's name for the entity
doc_param_2=groups: list of group where the entity is
doc_param_3=%(doc_profile_key)s
[delContact]
[contact_del]
async=
type=method
category=core
@ -747,7 +747,7 @@ doc=Remove a contact from profile's roster
doc_param_0=entity_jid: JID to remove from roster
doc_param_1=%(doc_profile_key)s
[rosterResync]
[roster_resync]
async=
type=method
category=core
@ -757,7 +757,7 @@ param_0_default="@DEFAULT@"
doc=Do a full resynchronisation of roster with server
doc_param_0=%(doc_profile_key)s
[launchAction]
[action_launch]
async=
type=method
category=core
@ -771,7 +771,7 @@ doc_param_2=%(doc_profile_key)s
doc_return=dict where key can be:
- xmlui: a XMLUI need to be displayed
[actionsGet]
[actions_get]
type=method
category=core
sig_in=s
@ -779,9 +779,9 @@ sig_out=a(a{ss}si)
param_0_default="@DEFAULT@"
doc=Get all not yet answered actions
doc_param_0=%(doc_profile_key)s
doc_return=list of data as for [actionNew] (without the profile)
doc_return=list of data as for [action_new] (without the profile)
[progressGet]
[progress_get]
type=method
category=core
sig_in=ss
@ -794,7 +794,7 @@ doc_return=dict with progress informations:
- size: end position (optional if not known)
other metadata may be present
[progressGetAllMetadata]
[progress_get_all_metadata]
type=method
category=core
sig_in=s
@ -803,9 +803,9 @@ doc=Get all active progress informations
doc_param_0=%(doc_profile)s or C.PROF_KEY_ALL for all profiles
doc_return= a dict which map profile to progress_dict
progress_dict map progress_id to progress_metadata
progress_metadata is the same dict as sent by [progressStarted]
progress_metadata is the same dict as sent by [progress_started]
[progressGetAll]
[progress_get_all]
type=method
category=core
sig_in=s
@ -814,9 +814,9 @@ doc=Get all active progress informations
doc_param_0=%(doc_profile)s or C.PROF_KEY_ALL for all profiles
doc_return= a dict which map profile to progress_dict
progress_dict map progress_id to progress_data
progress_data is the same dict as returned by [progressGet]
progress_data is the same dict as returned by [progress_get]
[menusGet]
[menus_get]
type=method
category=core
sig_in=si
@ -832,7 +832,7 @@ doc_return=list of tuple with the following value:
- menu_path_i18n: translated path of the menu
- extra: extra data, like icon name
[menuLaunch]
[menu_launch]
async=
type=method
category=core
@ -847,7 +847,7 @@ doc_param_4=%(doc_profile_key)s
doc_return=dict where key can be:
- xmlui: a XMLUI need to be displayed
[menuHelpGet]
[menu_help_get]
type=method
category=core
sig_in=ss
@ -858,7 +858,7 @@ doc_param_0=menu_id: id of the menu (same as callback_id)
doc_param_1=language: language in which the menu should be translated (empty string for default)
doc_return=Translated help string
[discoInfos]
[disco_infos]
async=
type=method
category=core
@ -884,7 +884,7 @@ doc_return=discovery data:
* desc
- list of values
[discoItems]
[disco_items]
async=
type=method
category=core
@ -900,7 +900,7 @@ doc_param_2=use_cache: use cached data if available
doc_param_3=%(doc_profile_key)s
doc_return=array of tuple (entity, node identifier, name)
[discoFindByFeatures]
[disco_find_by_features]
async=
type=method
category=core
@ -927,7 +927,7 @@ doc_return=tuple of maps of found entities full jids to their identities. Maps a
- own entities (i.e. entities linked to profile's jid)
- roster entities
[saveParamsTemplate]
[params_template_save]
type=method
category=core
sig_in=s
@ -936,7 +936,7 @@ doc=Save parameters template to xml file
doc_param_0=filename: output filename
doc_return=boolean (True in case of success)
[loadParamsTemplate]
[params_template_load]
type=method
category=core
sig_in=s
@ -945,7 +945,7 @@ doc=Load parameters template from xml file
doc_param_0=filename: input filename
doc_return=boolean (True in case of success)
[sessionInfosGet]
[session_infos_get]
async=
type=method
category=core
@ -957,7 +957,7 @@ doc_return=session informations, with at least the following keys:
jid: current full jid
started: date of creation of the session (Epoch time)
[devicesInfosGet]
[devices_infos_get]
async=
type=method
category=core
@ -970,7 +970,7 @@ doc_param_1=%(doc_profile_key)s
doc_return=list of known devices, where each item is a dict with a least following keys:
resource: device resource
[namespacesGet]
[namespaces_get]
type=method
category=core
sig_in=
@ -978,7 +978,7 @@ sig_out=a{ss}
doc=Get a dict to short name => whole namespaces
doc_return=namespaces mapping
[imageCheck]
[image_check]
type=method
category=core
sig_in=s
@ -986,7 +986,7 @@ sig_out=s
doc=Analyze an image a return a report
doc_return=serialized report
[imageResize]
[image_resize]
async=
type=method
category=core
@ -999,7 +999,7 @@ doc_param_2=height: height of the new image
doc_return=path of the new image with desired size
the image must be deleted once not needed anymore
[imageGeneratePreview]
[image_generate_preview]
async=
type=method
category=core
@ -1010,7 +1010,7 @@ doc_param_0=image_path: path of the original image
doc_param_1=%(doc_profile_key)s
doc_return=path to the preview in cache
[imageConvert]
[image_convert]
async=
type=method
category=core

View file

@ -38,9 +38,9 @@ class DbusXmlConstructor(base_constructor.Constructor):
"a{sa{s(sia{ss})}}": "PresenceStatusT",
}
def generateCoreSide(self):
def generate_core_side(self):
try:
doc = minidom.parse(self.getTemplatePath(self.template))
doc = minidom.parse(self.get_template_path(self.template))
interface_elt = doc.getElementsByTagName("interface")[0]
except IOError:
print("Can't access template")
@ -60,8 +60,8 @@ class DbusXmlConstructor(base_constructor.Constructor):
new_elt.setAttribute("name", section)
idx = 0
args_doc = self.getArgumentsDoc(section)
for arg in self.argumentsParser(function["sig_in"] or ""):
args_doc = self.get_arguments_doc(section)
for arg in self.arguments_parser(function["sig_in"] or ""):
arg_elt = doc.createElement("arg")
arg_elt.setAttribute(
"name", args_doc[idx][0] if idx in args_doc else "arg_%i" % idx
@ -99,4 +99,4 @@ class DbusXmlConstructor(base_constructor.Constructor):
interface_elt.appendChild(new_elt)
# now we write to final file
self.finalWrite(self.core_dest, [doc.toprettyxml()])
self.final_write(self.core_dest, [doc.toprettyxml()])

View file

@ -81,7 +81,7 @@ class DbusConstructor(base_constructor.Constructor):
"debug": ""
if not self.args.debug
else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "),
"args_result": self.getArguments(function["sig_in"], name=arg_doc),
"args_result": self.get_arguments(function["sig_in"], name=arg_doc),
"async_args": "callback=None, errback=None",
"async_comma": ", " if function["sig_in"] else "",
"error_handler": """if callback is None:

View file

@ -30,8 +30,8 @@ from txdbus.interface import DBusInterface, Method, Signal
log = getLogger(__name__)
# Interface prefix
const_INT_PREFIX = config.getConfig(
config.parseMainConf(),
const_INT_PREFIX = config.config_get(
config.parse_main_conf(),
"",
"bridge_dbus_int_prefix",
"org.libervia.Libervia")
@ -118,13 +118,13 @@ class DBusObject(objects.DBusObject):
##METHODS_PART##
class Bridge:
class bridge:
def __init__(self):
log.info("Init DBus...")
self._obj = DBusObject(const_OBJ_PATH)
async def postInit(self):
async def post_init(self):
try:
conn = await client.connect(reactor)
except error.DBusException as e:
@ -145,13 +145,13 @@ class Bridge:
log.debug(f"registering DBus bridge method [{name}]")
self._obj.register_method(name, callback)
def emitSignal(self, name, *args):
def emit_signal(self, name, *args):
self._obj.emitSignal(name, *args)
def addMethod(
def add_method(
self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
):
"""Dynamically add a method to D-Bus Bridge"""
"""Dynamically add a method to D-Bus bridge"""
# FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug(f"Adding method {name!r} to D-Bus bridge")
self._obj.plugin_iface.addMethod(
@ -164,8 +164,8 @@ class Bridge:
setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj))
self.register_method(name, method)
def addSignal(self, name, int_suffix, signature, doc={}):
"""Dynamically add a signal to D-Bus Bridge"""
def add_signal(self, name, int_suffix, signature, doc={}):
"""Dynamically add a signal to D-Bus bridge"""
log.debug(f"Adding signal {name!r} to D-Bus bridge")
self._obj.plugin_iface.addSignal(Signal(name, signature))
setattr(Bridge, name, partialmethod(Bridge.emitSignal, name))
setattr(bridge, name, partialmethod(bridge.emit_signal, name))

View file

@ -32,8 +32,8 @@ log = getLogger(__name__)
# Interface prefix
const_INT_PREFIX = config.getConfig(
config.parseMainConf(),
const_INT_PREFIX = config.config_get(
config.parse_main_conf(),
"",
"bridge_dbus_int_prefix",
"org.libervia.Libervia")
@ -66,9 +66,9 @@ def dbus_to_bridge_exception(dbus_e):
return BridgeException(name, message, condition)
class Bridge:
class bridge:
def bridgeConnect(self, callback, errback):
def bridge_connect(self, callback, errback):
try:
self.sessions_bus = dbus.SessionBus()
self.db_object = self.sessions_bus.get_object(const_INT_PREFIX,
@ -105,7 +105,7 @@ class Bridge:
except AttributeError:
# The attribute is not found, we try the plugin proxy to find the requested method
def getPluginMethod(*args, **kwargs):
def get_plugin_method(*args, **kwargs):
# We first check if we have an async call. We detect this in two ways:
# - if we have the 'callback' and 'errback' keyword arguments
# - or if the last two arguments are callable
@ -156,11 +156,11 @@ class Bridge:
return self.db_plugin_iface.get_dbus_method(name)(*args, **kwargs)
raise e
return getPluginMethod
return get_plugin_method
##METHODS_PART##
class AIOBridge(Bridge):
class AIOBridge(bridge):
def register_signal(self, functionName, handler, iface="core"):
loop = asyncio.get_running_loop()
@ -173,7 +173,7 @@ class AIOBridge(Bridge):
return object.__getattribute__(self, name)
except AttributeError:
# The attribute is not found, we try the plugin proxy to find the requested method
def getPluginMethod(*args, **kwargs):
def get_plugin_method(*args, **kwargs):
loop = asyncio.get_running_loop()
fut = loop.create_future()
method = getattr(self.db_plugin_iface, name)
@ -191,7 +191,7 @@ class AIOBridge(Bridge):
)
except ValueError as e:
if e.args[0].startswith("Unable to guess signature"):
# same hack as for Bridge.__getattribute__
# same hack as for bridge.__getattribute__
log.warning("using hack to work around inspection issue")
proxy = self.db_plugin_iface.proxy_object
IN_PROGRESS = proxy.INTROSPECT_STATE_INTROSPECT_IN_PROGRESS
@ -209,12 +209,12 @@ class AIOBridge(Bridge):
raise e
return fut
return getPluginMethod
return get_plugin_method
def bridgeConnect(self):
def bridge_connect(self):
loop = asyncio.get_running_loop()
fut = loop.create_future()
super().bridgeConnect(
super().bridge_connect(
callback=lambda: loop.call_soon_threadsafe(fut.set_result, None),
errback=lambda e: loop.call_soon_threadsafe(fut.set_exception, e)
)

View file

@ -51,7 +51,7 @@ class EmbeddedConstructor(base_constructor.Constructor):
"debug": ""
if not self.args.debug
else 'log.debug ("%s")\n%s' % (completion["name"], 8 * " "),
"args_result": self.getArguments(function["sig_in"], name=arg_doc),
"args_result": self.get_arguments(function["sig_in"], name=arg_doc),
"args_comma": ", " if function["sig_in"] else "",
}
)
@ -96,5 +96,5 @@ class EmbeddedConstructor(base_constructor.Constructor):
def core_completion_signal(self, completion, function, default, arg_doc, async_):
completion.update(
{"args_result": self.getArguments(function["sig_in"], name=arg_doc)}
{"args_result": self.get_arguments(function["sig_in"], name=arg_doc)}
)

View file

@ -17,4 +17,4 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from sat.bridge.embedded import Bridge
from sat.bridge.embedded import bridge

View file

@ -29,7 +29,7 @@ class _Bridge(object):
self._methods_cbs = {}
self._signals_cbs = {"core": {}, "plugin": {}}
def bridgeConnect(self, callback, errback):
def bridge_connect(self, callback, errback):
callback()
def register_method(self, name, callback):
@ -85,7 +85,7 @@ class _Bridge(object):
else:
cb(*args, **kwargs)
def addMethod(self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}):
def add_method(self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}):
# FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug("Adding method [{}] to embedded bridge".format(name))
self.register_method(name, method)
@ -97,7 +97,7 @@ class _Bridge(object):
),
)
def addSignal(self, name, int_suffix, signature, doc={}):
def add_signal(self, name, int_suffix, signature, doc={}):
setattr(
self.__class__,
name,
@ -116,7 +116,7 @@ class _Bridge(object):
bridge = None
def Bridge():
def bridge():
global bridge
if bridge is None:
bridge = _Bridge()

View file

@ -29,7 +29,7 @@ class MediawikiConstructor(base_constructor.Constructor):
self.core_template = "mediawiki_template.tpl"
self.core_dest = "mediawiki.wiki"
def _addTextDecorations(self, text):
def _add_text_decorations(self, text):
"""Add text decorations like coloration or shortcuts"""
def anchor_link(match):
@ -42,43 +42,43 @@ class MediawikiConstructor(base_constructor.Constructor):
return re.sub(r"\[(\w+)\]", anchor_link, text)
def _wikiParameter(self, name, sig_in):
def _wiki_parameter(self, name, sig_in):
"""Format parameters with the wiki syntax
@param name: name of the function
@param sig_in: signature in
@return: string of the formated parameters"""
arg_doc = self.getArgumentsDoc(name)
arg_default = self.getDefault(name)
args_str = self.getArguments(sig_in)
arg_doc = self.get_arguments_doc(name)
arg_default = self.get_default(name)
args_str = self.get_arguments(sig_in)
args = args_str.split(", ") if args_str else [] # ugly but it works :)
wiki = []
for i in range(len(args)):
if i in arg_doc:
name, doc = arg_doc[i]
doc = "\n:".join(doc.rstrip("\n").split("\n"))
wiki.append("; %s: %s" % (name, self._addTextDecorations(doc)))
wiki.append("; %s: %s" % (name, self._add_text_decorations(doc)))
else:
wiki.append("; arg_%d: " % i)
if i in arg_default:
wiki.append(":''DEFAULT: %s''" % arg_default[i])
return "\n".join(wiki)
def _wikiReturn(self, name):
def _wiki_return(self, name):
"""Format return doc with the wiki syntax
@param name: name of the function
"""
arg_doc = self.getArgumentsDoc(name)
arg_doc = self.get_arguments_doc(name)
wiki = []
if "return" in arg_doc:
wiki.append("\n|-\n! scope=row | return value\n|")
wiki.append(
"<br />\n".join(
self._addTextDecorations(arg_doc["return"]).rstrip("\n").split("\n")
self._add_text_decorations(arg_doc["return"]).rstrip("\n").split("\n")
)
)
return "\n".join(wiki)
def generateCoreSide(self):
def generate_core_side(self):
signals_part = []
methods_part = []
sections = self.bridge_template.sections()
@ -114,13 +114,13 @@ class MediawikiConstructor(base_constructor.Constructor):
"sig_out": function["sig_out"] or "",
"category": function["category"],
"name": section,
"doc": self.getDoc(section) or "FIXME: No description available",
"doc": self.get_doc(section) or "FIXME: No description available",
"async": async_msg if "async" in self.getFlags(section) else "",
"deprecated": deprecated_msg
if "deprecated" in self.getFlags(section)
else "",
"parameters": self._wikiParameter(section, function["sig_in"]),
"return": self._wikiReturn(section)
"parameters": self._wiki_parameter(section, function["sig_in"]),
"return": self._wiki_return(section)
if function["type"] == "method"
else "",
}
@ -148,7 +148,7 @@ class MediawikiConstructor(base_constructor.Constructor):
# at this point, signals_part, and methods_part should be filled,
# we just have to place them in the right part of the template
core_bridge = []
template_path = self.getTemplatePath(self.core_template)
template_path = self.get_template_path(self.core_template)
try:
with open(template_path) as core_template:
for line in core_template:
@ -165,4 +165,4 @@ class MediawikiConstructor(base_constructor.Constructor):
sys.exit(1)
# now we write to final file
self.finalWrite(self.core_dest, core_bridge)
self.final_write(self.core_dest, core_bridge)

View file

@ -26,7 +26,7 @@ class pbConstructor(base_constructor.Constructor):
CORE_FORMATS = {
"signals": """\
def {name}(self, {args}):
{debug}self.sendSignal("{name}", {args_no_def})\n"""
{debug}self.send_signal("{name}", {args_no_def})\n"""
}
FRONTEND_TEMPLATE = "pb_frontend_template.py"
@ -49,7 +49,7 @@ class pbConstructor(base_constructor.Constructor):
}
def core_completion_signal(self, completion, function, default, arg_doc, async_):
completion["args_no_def"] = self.getArguments(function["sig_in"], name=arg_doc)
completion["args_no_def"] = self.get_arguments(function["sig_in"], name=arg_doc)
completion["debug"] = (
""
if not self.args.debug
@ -60,7 +60,7 @@ class pbConstructor(base_constructor.Constructor):
completion.update(
{
"args_comma": ", " if function["sig_in"] else "",
"args_no_def": self.getArguments(function["sig_in"], name=arg_doc),
"args_no_def": self.get_arguments(function["sig_in"], name=arg_doc),
"callback": "callback"
if function["sig_out"]
else "lambda __: callback()",

View file

@ -55,17 +55,17 @@ class PBRoot(pb.Root):
def __init__(self):
self.signals_handlers = []
def remote_initBridge(self, signals_handler):
def remote_init_bridge(self, signals_handler):
self.signals_handlers.append(HandlerWrapper(signals_handler))
log.info("registered signal handler")
def sendSignalEb(self, failure_, signal_name):
def send_signal_eb(self, failure_, signal_name):
if not failure_.check(pb.PBConnectionLost):
log.error(
f"Error while sending signal {signal_name}: {failure_}",
)
def sendSignal(self, name, args, kwargs):
def send_signal(self, name, args, kwargs):
to_remove = []
for wrapper in self.signals_handlers:
handler = wrapper.handler
@ -74,13 +74,13 @@ class PBRoot(pb.Root):
except pb.DeadReferenceError:
to_remove.append(wrapper)
else:
d.addErrback(self.sendSignalEb, name)
d.addErrback(self.send_signal_eb, name)
if to_remove:
for wrapper in to_remove:
log.debug("Removing signal handler for dead frontend")
self.signals_handlers.remove(wrapper)
def _bridgeDeactivateSignals(self):
def _bridge_deactivate_signals(self):
if hasattr(self, "signals_paused"):
log.warning("bridge signals already deactivated")
if self.signals_handler:
@ -90,7 +90,7 @@ class PBRoot(pb.Root):
self.signals_handlers = []
log.debug("bridge signals have been deactivated")
def _bridgeReactivateSignals(self):
def _bridge_reactivate_signals(self):
try:
self.signals_handlers = self.signals_paused
except AttributeError:
@ -102,31 +102,31 @@ class PBRoot(pb.Root):
##METHODS_PART##
class Bridge(object):
class bridge(object):
def __init__(self):
log.info("Init Perspective Broker...")
self.root = PBRoot()
conf = config.parseMainConf()
getConf = partial(config.getConf, conf, "bridge_pb", "")
conn_type = getConf("connection_type", "unix_socket")
conf = config.parse_main_conf()
get_conf = partial(config.get_conf, conf, "bridge_pb", "")
conn_type = get_conf("connection_type", "unix_socket")
if conn_type == "unix_socket":
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
local_dir = Path(config.config_get(conf, "", "local_dir")).resolve()
socket_path = local_dir / "bridge_pb"
log.info(f"using UNIX Socket at {socket_path}")
reactor.listenUNIX(
str(socket_path), pb.PBServerFactory(self.root), mode=0o600
)
elif conn_type == "socket":
port = int(getConf("port", 8789))
port = int(get_conf("port", 8789))
log.info(f"using TCP Socket at port {port}")
reactor.listenTCP(port, pb.PBServerFactory(self.root))
else:
raise ValueError(f"Unknown pb connection type: {conn_type!r}")
def sendSignal(self, name, *args, **kwargs):
self.root.sendSignal(name, args, kwargs)
def send_signal(self, name, *args, **kwargs):
self.root.send_signal(name, args, kwargs)
def remote_initBridge(self, signals_handler):
def remote_init_bridge(self, signals_handler):
self.signals_handlers.append(signals_handler)
log.info("registered signal handler")
@ -135,32 +135,32 @@ class Bridge(object):
setattr(self.root, "remote_" + name, callback)
#  self.root.register_method(name, callback)
def addMethod(
def add_method(
self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
):
"""Dynamically add a method to PB Bridge"""
"""Dynamically add a method to PB bridge"""
# FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug("Adding method {name} to PB bridge".format(name=name))
self.register_method(name, method)
def addSignal(self, name, int_suffix, signature, doc={}):
def add_signal(self, name, int_suffix, signature, doc={}):
log.debug("Adding signal {name} to PB bridge".format(name=name))
setattr(
self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs)
self, name, lambda *args, **kwargs: self.send_signal(name, *args, **kwargs)
)
def bridgeDeactivateSignals(self):
def bridge_deactivate_signals(self):
"""Stop sending signals to bridge
Mainly used for mobile frontends, when the frontend is paused
"""
self.root._bridgeDeactivateSignals()
self.root._bridge_deactivate_signals()
def bridgeReactivateSignals(self):
def bridge_reactivate_signals(self):
"""Send again signals to bridge
Should only be used after bridgeDeactivateSignals has been called
Should only be used after bridge_deactivate_signals has been called
"""
self.root._bridgeReactivateSignals()
self.root._bridge_reactivate_signals()
##SIGNALS_PART##

View file

@ -55,7 +55,7 @@ class SignalsHandler(pb.Referenceable):
setattr(self, method_name, handler)
class Bridge(object):
class bridge(object):
def __init__(self):
self.signals_handler = SignalsHandler()
@ -75,7 +75,7 @@ class Bridge(object):
)
)
def remoteCallback(self, result, callback):
def remote_callback(self, result, callback):
"""call callback with argument or None
if result is not None not argument is used,
@ -112,11 +112,11 @@ class Bridge(object):
callback = args.pop()
d = self.root.callRemote(name, *args, **kwargs)
if callback is not None:
d.addCallback(self.remoteCallback, callback)
d.addCallback(self.remote_callback, callback)
if errback is not None:
d.addErrback(errback)
def _initBridgeEb(self, failure_):
def _init_bridge_eb(self, failure_):
log.error("Can't init bridge: {msg}".format(msg=failure_))
return failure_
@ -127,28 +127,28 @@ class Bridge(object):
"""
self.root = root
d = root.callRemote("initBridge", self.signals_handler)
d.addErrback(self._initBridgeEb)
d.addErrback(self._init_bridge_eb)
return d
def getRootObjectEb(self, failure_):
def get_root_object_eb(self, failure_):
"""Call errback with appropriate bridge error"""
if failure_.check(ConnectionRefusedError, ConnectError):
raise exceptions.BridgeExceptionNoService
else:
raise failure_
def bridgeConnect(self, callback, errback):
def bridge_connect(self, callback, errback):
factory = pb.PBClientFactory()
conf = config.parseMainConf()
getConf = partial(config.getConf, conf, "bridge_pb", "")
conn_type = getConf("connection_type", "unix_socket")
conf = config.parse_main_conf()
get_conf = partial(config.get_conf, conf, "bridge_pb", "")
conn_type = get_conf("connection_type", "unix_socket")
if conn_type == "unix_socket":
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
local_dir = Path(config.config_get(conf, "", "local_dir")).resolve()
socket_path = local_dir / "bridge_pb"
reactor.connectUNIX(str(socket_path), factory)
elif conn_type == "socket":
host = getConf("host", "localhost")
port = int(getConf("port", 8789))
host = get_conf("host", "localhost")
port = int(get_conf("port", 8789))
reactor.connectTCP(host, port, factory)
else:
raise ValueError(f"Unknown pb connection type: {conn_type!r}")
@ -156,7 +156,7 @@ class Bridge(object):
d.addCallback(self._set_root)
if callback is not None:
d.addCallback(lambda __: callback())
d.addErrback(self.getRootObjectEb)
d.addErrback(self.get_root_object_eb)
if errback is not None:
d.addErrback(lambda failure_: errback(failure_.value))
return d
@ -175,7 +175,7 @@ class AIOSignalsHandler(SignalsHandler):
return super().register_signal(name, async_handler, iface)
class AIOBridge(Bridge):
class AIOBridge(bridge):
def __init__(self):
self.signals_handler = AIOSignalsHandler()
@ -192,8 +192,8 @@ class AIOBridge(Bridge):
d.addErrback(self._errback)
return d.asFuture(asyncio.get_event_loop())
async def bridgeConnect(self):
d = super().bridgeConnect(callback=None, errback=None)
async def bridge_connect(self):
d = super().bridge_connect(callback=None, errback=None)
return await d.asFuture(asyncio.get_event_loop())
##ASYNC_METHODS_PART##

View file

@ -30,8 +30,8 @@ from txdbus.interface import DBusInterface, Method, Signal
log = getLogger(__name__)
# Interface prefix
const_INT_PREFIX = config.getConfig(
config.parseMainConf(),
const_INT_PREFIX = config.config_get(
config.parse_main_conf(),
"",
"bridge_dbus_int_prefix",
"org.libervia.Libervia")
@ -88,87 +88,87 @@ class DBusObject(objects.DBusObject):
core_iface = DBusInterface(
const_INT_PREFIX + const_CORE_SUFFIX,
Method('actionsGet', arguments='s', returns='a(a{ss}si)'),
Method('addContact', arguments='ss', returns=''),
Method('asyncDeleteProfile', arguments='s', returns=''),
Method('asyncGetParamA', arguments='sssis', returns='s'),
Method('asyncGetParamsValuesFromCategory', arguments='sisss', returns='a{ss}'),
Method('action_launch', arguments='sa{ss}s', returns='a{ss}'),
Method('actions_get', arguments='s', returns='a(a{ss}si)'),
Method('config_get', arguments='ss', returns='s'),
Method('connect', arguments='ssa{ss}', returns='b'),
Method('contactGet', arguments='ss', returns='(a{ss}as)'),
Method('delContact', arguments='ss', returns=''),
Method('devicesInfosGet', arguments='ss', returns='s'),
Method('discoFindByFeatures', arguments='asa(ss)bbbbbs', returns='(a{sa(sss)}a{sa(sss)}a{sa(sss)})'),
Method('discoInfos', arguments='ssbs', returns='(asa(sss)a{sa(a{ss}as)})'),
Method('discoItems', arguments='ssbs', returns='a(sss)'),
Method('contact_add', arguments='ss', returns=''),
Method('contact_del', arguments='ss', returns=''),
Method('contact_get', arguments='ss', returns='(a{ss}as)'),
Method('contact_update', arguments='ssass', returns=''),
Method('contacts_get', arguments='s', returns='a(sa{ss}as)'),
Method('contacts_get_from_group', arguments='ss', returns='as'),
Method('devices_infos_get', arguments='ss', returns='s'),
Method('disco_find_by_features', arguments='asa(ss)bbbbbs', returns='(a{sa(sss)}a{sa(sss)}a{sa(sss)})'),
Method('disco_infos', arguments='ssbs', returns='(asa(sss)a{sa(a{ss}as)})'),
Method('disco_items', arguments='ssbs', returns='a(sss)'),
Method('disconnect', arguments='s', returns=''),
Method('encryptionNamespaceGet', arguments='s', returns='s'),
Method('encryptionPluginsGet', arguments='', returns='s'),
Method('encryptionTrustUIGet', arguments='sss', returns='s'),
Method('getConfig', arguments='ss', returns='s'),
Method('getContacts', arguments='s', returns='a(sa{ss}as)'),
Method('getContactsFromGroup', arguments='ss', returns='as'),
Method('getEntitiesData', arguments='asass', returns='a{sa{ss}}'),
Method('getEntityData', arguments='sass', returns='a{ss}'),
Method('getFeatures', arguments='s', returns='a{sa{ss}}'),
Method('getMainResource', arguments='ss', returns='s'),
Method('getParamA', arguments='ssss', returns='s'),
Method('getParamsCategories', arguments='', returns='as'),
Method('getParamsUI', arguments='isss', returns='s'),
Method('getPresenceStatuses', arguments='s', returns='a{sa{s(sia{ss})}}'),
Method('getReady', arguments='', returns=''),
Method('getVersion', arguments='', returns='s'),
Method('getWaitingSub', arguments='s', returns='a{ss}'),
Method('historyGet', arguments='ssiba{ss}s', returns='a(sdssa{ss}a{ss}ss)'),
Method('imageCheck', arguments='s', returns='s'),
Method('imageConvert', arguments='ssss', returns='s'),
Method('imageGeneratePreview', arguments='ss', returns='s'),
Method('imageResize', arguments='sii', returns='s'),
Method('isConnected', arguments='s', returns='b'),
Method('launchAction', arguments='sa{ss}s', returns='a{ss}'),
Method('loadParamsTemplate', arguments='s', returns='b'),
Method('menuHelpGet', arguments='ss', returns='s'),
Method('menuLaunch', arguments='sasa{ss}is', returns='a{ss}'),
Method('menusGet', arguments='si', returns='a(ssasasa{ss})'),
Method('messageEncryptionGet', arguments='ss', returns='s'),
Method('messageEncryptionStart', arguments='ssbs', returns=''),
Method('messageEncryptionStop', arguments='ss', returns=''),
Method('messageSend', arguments='sa{ss}a{ss}sss', returns=''),
Method('namespacesGet', arguments='', returns='a{ss}'),
Method('paramsRegisterApp', arguments='sis', returns=''),
Method('privateDataDelete', arguments='sss', returns=''),
Method('privateDataGet', arguments='sss', returns='s'),
Method('privateDataSet', arguments='ssss', returns=''),
Method('profileCreate', arguments='sss', returns=''),
Method('profileIsSessionStarted', arguments='s', returns='b'),
Method('profileNameGet', arguments='s', returns='s'),
Method('profileSetDefault', arguments='s', returns=''),
Method('profileStartSession', arguments='ss', returns='b'),
Method('profilesListGet', arguments='bb', returns='as'),
Method('progressGet', arguments='ss', returns='a{ss}'),
Method('progressGetAll', arguments='s', returns='a{sa{sa{ss}}}'),
Method('progressGetAllMetadata', arguments='s', returns='a{sa{sa{ss}}}'),
Method('rosterResync', arguments='s', returns=''),
Method('saveParamsTemplate', arguments='s', returns='b'),
Method('sessionInfosGet', arguments='s', returns='a{ss}'),
Method('setParam', arguments='sssis', returns=''),
Method('setPresence', arguments='ssa{ss}s', returns=''),
Method('encryption_namespace_get', arguments='s', returns='s'),
Method('encryption_plugins_get', arguments='', returns='s'),
Method('encryption_trust_ui_get', arguments='sss', returns='s'),
Method('entities_data_get', arguments='asass', returns='a{sa{ss}}'),
Method('entity_data_get', arguments='sass', returns='a{ss}'),
Method('features_get', arguments='s', returns='a{sa{ss}}'),
Method('history_get', arguments='ssiba{ss}s', returns='a(sdssa{ss}a{ss}ss)'),
Method('image_check', arguments='s', returns='s'),
Method('image_convert', arguments='ssss', returns='s'),
Method('image_generate_preview', arguments='ss', returns='s'),
Method('image_resize', arguments='sii', returns='s'),
Method('is_connected', arguments='s', returns='b'),
Method('main_resource_get', arguments='ss', returns='s'),
Method('menu_help_get', arguments='ss', returns='s'),
Method('menu_launch', arguments='sasa{ss}is', returns='a{ss}'),
Method('menus_get', arguments='si', returns='a(ssasasa{ss})'),
Method('message_encryption_get', arguments='ss', returns='s'),
Method('message_encryption_start', arguments='ssbs', returns=''),
Method('message_encryption_stop', arguments='ss', returns=''),
Method('message_send', arguments='sa{ss}a{ss}sss', returns=''),
Method('namespaces_get', arguments='', returns='a{ss}'),
Method('param_get_a', arguments='ssss', returns='s'),
Method('param_get_a_async', arguments='sssis', returns='s'),
Method('param_set', arguments='sssis', returns=''),
Method('param_ui_get', arguments='isss', returns='s'),
Method('params_categories_get', arguments='', returns='as'),
Method('params_register_app', arguments='sis', returns=''),
Method('params_template_load', arguments='s', returns='b'),
Method('params_template_save', arguments='s', returns='b'),
Method('params_values_from_category_get_async', arguments='sisss', returns='a{ss}'),
Method('presence_set', arguments='ssa{ss}s', returns=''),
Method('presence_statuses_get', arguments='s', returns='a{sa{s(sia{ss})}}'),
Method('private_data_delete', arguments='sss', returns=''),
Method('private_data_get', arguments='sss', returns='s'),
Method('private_data_set', arguments='ssss', returns=''),
Method('profile_create', arguments='sss', returns=''),
Method('profile_delete_async', arguments='s', returns=''),
Method('profile_is_session_started', arguments='s', returns='b'),
Method('profile_name_get', arguments='s', returns='s'),
Method('profile_set_default', arguments='s', returns=''),
Method('profile_start_session', arguments='ss', returns='b'),
Method('profiles_list_get', arguments='bb', returns='as'),
Method('progress_get', arguments='ss', returns='a{ss}'),
Method('progress_get_all', arguments='s', returns='a{sa{sa{ss}}}'),
Method('progress_get_all_metadata', arguments='s', returns='a{sa{sa{ss}}}'),
Method('ready_get', arguments='', returns=''),
Method('roster_resync', arguments='s', returns=''),
Method('session_infos_get', arguments='s', returns='a{ss}'),
Method('sub_waiting_get', arguments='s', returns='a{ss}'),
Method('subscription', arguments='sss', returns=''),
Method('updateContact', arguments='ssass', returns=''),
Method('version_get', arguments='', returns='s'),
Signal('_debug', 'sa{ss}s'),
Signal('actionNew', 'a{ss}sis'),
Signal('action_new', 'a{ss}sis'),
Signal('connected', 'ss'),
Signal('contactDeleted', 'ss'),
Signal('contact_deleted', 'ss'),
Signal('contact_new', 'sa{ss}ass'),
Signal('disconnected', 's'),
Signal('entityDataUpdated', 'ssss'),
Signal('messageEncryptionStarted', 'sss'),
Signal('messageEncryptionStopped', 'sa{ss}s'),
Signal('messageNew', 'sdssa{ss}a{ss}sss'),
Signal('newContact', 'sa{ss}ass'),
Signal('paramUpdate', 'ssss'),
Signal('presenceUpdate', 'ssia{ss}s'),
Signal('progressError', 'sss'),
Signal('progressFinished', 'sa{ss}s'),
Signal('progressStarted', 'sa{ss}s'),
Signal('entity_data_updated', 'ssss'),
Signal('message_encryption_started', 'sss'),
Signal('message_encryption_stopped', 'sa{ss}s'),
Signal('message_new', 'sdssa{ss}a{ss}sss'),
Signal('param_update', 'ssss'),
Signal('presence_update', 'ssia{ss}s'),
Signal('progress_error', 'sss'),
Signal('progress_finished', 'sa{ss}s'),
Signal('progress_started', 'sa{ss}s'),
Signal('subscribe', 'sss'),
)
plugin_iface = DBusInterface(
@ -196,212 +196,212 @@ class DBusObject(objects.DBusObject):
d.addErrback(GenericException.create_and_raise)
return d
def dbus_actionsGet(self, profile_key="@DEFAULT@"):
return self._callback("actionsGet", profile_key)
def dbus_action_launch(self, callback_id, data, profile_key="@DEFAULT@"):
return self._callback("action_launch", callback_id, data, profile_key)
def dbus_addContact(self, entity_jid, profile_key="@DEFAULT@"):
return self._callback("addContact", entity_jid, profile_key)
def dbus_actions_get(self, profile_key="@DEFAULT@"):
return self._callback("actions_get", profile_key)
def dbus_asyncDeleteProfile(self, profile):
return self._callback("asyncDeleteProfile", profile)
def dbus_asyncGetParamA(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@"):
return self._callback("asyncGetParamA", name, category, attribute, security_limit, profile_key)
def dbus_asyncGetParamsValuesFromCategory(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@"):
return self._callback("asyncGetParamsValuesFromCategory", category, security_limit, app, extra, profile_key)
def dbus_config_get(self, section, name):
return self._callback("config_get", section, name)
def dbus_connect(self, profile_key="@DEFAULT@", password='', options={}):
return self._callback("connect", profile_key, password, options)
def dbus_contactGet(self, arg_0, profile_key="@DEFAULT@"):
return self._callback("contactGet", arg_0, profile_key)
def dbus_contact_add(self, entity_jid, profile_key="@DEFAULT@"):
return self._callback("contact_add", entity_jid, profile_key)
def dbus_delContact(self, entity_jid, profile_key="@DEFAULT@"):
return self._callback("delContact", entity_jid, profile_key)
def dbus_contact_del(self, entity_jid, profile_key="@DEFAULT@"):
return self._callback("contact_del", entity_jid, profile_key)
def dbus_devicesInfosGet(self, bare_jid, profile_key):
return self._callback("devicesInfosGet", bare_jid, profile_key)
def dbus_contact_get(self, arg_0, profile_key="@DEFAULT@"):
return self._callback("contact_get", arg_0, profile_key)
def dbus_discoFindByFeatures(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@"):
return self._callback("discoFindByFeatures", namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key)
def dbus_contact_update(self, entity_jid, name, groups, profile_key="@DEFAULT@"):
return self._callback("contact_update", entity_jid, name, groups, profile_key)
def dbus_discoInfos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"):
return self._callback("discoInfos", entity_jid, node, use_cache, profile_key)
def dbus_contacts_get(self, profile_key="@DEFAULT@"):
return self._callback("contacts_get", profile_key)
def dbus_discoItems(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"):
return self._callback("discoItems", entity_jid, node, use_cache, profile_key)
def dbus_contacts_get_from_group(self, group, profile_key="@DEFAULT@"):
return self._callback("contacts_get_from_group", group, profile_key)
def dbus_devices_infos_get(self, bare_jid, profile_key):
return self._callback("devices_infos_get", bare_jid, profile_key)
def dbus_disco_find_by_features(self, namespaces, identities, bare_jid=False, service=True, roster=True, own_jid=True, local_device=False, profile_key="@DEFAULT@"):
return self._callback("disco_find_by_features", namespaces, identities, bare_jid, service, roster, own_jid, local_device, profile_key)
def dbus_disco_infos(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"):
return self._callback("disco_infos", entity_jid, node, use_cache, profile_key)
def dbus_disco_items(self, entity_jid, node=u'', use_cache=True, profile_key="@DEFAULT@"):
return self._callback("disco_items", entity_jid, node, use_cache, profile_key)
def dbus_disconnect(self, profile_key="@DEFAULT@"):
return self._callback("disconnect", profile_key)
def dbus_encryptionNamespaceGet(self, arg_0):
return self._callback("encryptionNamespaceGet", arg_0)
def dbus_encryption_namespace_get(self, arg_0):
return self._callback("encryption_namespace_get", arg_0)
def dbus_encryptionPluginsGet(self, ):
return self._callback("encryptionPluginsGet", )
def dbus_encryption_plugins_get(self, ):
return self._callback("encryption_plugins_get", )
def dbus_encryptionTrustUIGet(self, to_jid, namespace, profile_key):
return self._callback("encryptionTrustUIGet", to_jid, namespace, profile_key)
def dbus_encryption_trust_ui_get(self, to_jid, namespace, profile_key):
return self._callback("encryption_trust_ui_get", to_jid, namespace, profile_key)
def dbus_getConfig(self, section, name):
return self._callback("getConfig", section, name)
def dbus_entities_data_get(self, jids, keys, profile):
return self._callback("entities_data_get", jids, keys, profile)
def dbus_getContacts(self, profile_key="@DEFAULT@"):
return self._callback("getContacts", profile_key)
def dbus_entity_data_get(self, jid, keys, profile):
return self._callback("entity_data_get", jid, keys, profile)
def dbus_getContactsFromGroup(self, group, profile_key="@DEFAULT@"):
return self._callback("getContactsFromGroup", group, profile_key)
def dbus_features_get(self, profile_key):
return self._callback("features_get", profile_key)
def dbus_getEntitiesData(self, jids, keys, profile):
return self._callback("getEntitiesData", jids, keys, profile)
def dbus_history_get(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@"):
return self._callback("history_get", from_jid, to_jid, limit, between, filters, profile)
def dbus_getEntityData(self, jid, keys, profile):
return self._callback("getEntityData", jid, keys, profile)
def dbus_image_check(self, arg_0):
return self._callback("image_check", arg_0)
def dbus_getFeatures(self, profile_key):
return self._callback("getFeatures", profile_key)
def dbus_image_convert(self, source, dest, arg_2, extra):
return self._callback("image_convert", source, dest, arg_2, extra)
def dbus_getMainResource(self, contact_jid, profile_key="@DEFAULT@"):
return self._callback("getMainResource", contact_jid, profile_key)
def dbus_image_generate_preview(self, image_path, profile_key):
return self._callback("image_generate_preview", image_path, profile_key)
def dbus_getParamA(self, name, category, attribute="value", profile_key="@DEFAULT@"):
return self._callback("getParamA", name, category, attribute, profile_key)
def dbus_image_resize(self, image_path, width, height):
return self._callback("image_resize", image_path, width, height)
def dbus_getParamsCategories(self, ):
return self._callback("getParamsCategories", )
def dbus_is_connected(self, profile_key="@DEFAULT@"):
return self._callback("is_connected", profile_key)
def dbus_getParamsUI(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@"):
return self._callback("getParamsUI", security_limit, app, extra, profile_key)
def dbus_main_resource_get(self, contact_jid, profile_key="@DEFAULT@"):
return self._callback("main_resource_get", contact_jid, profile_key)
def dbus_getPresenceStatuses(self, profile_key="@DEFAULT@"):
return self._callback("getPresenceStatuses", profile_key)
def dbus_menu_help_get(self, menu_id, language):
return self._callback("menu_help_get", menu_id, language)
def dbus_getReady(self, ):
return self._callback("getReady", )
def dbus_menu_launch(self, menu_type, path, data, security_limit, profile_key):
return self._callback("menu_launch", menu_type, path, data, security_limit, profile_key)
def dbus_getVersion(self, ):
return self._callback("getVersion", )
def dbus_menus_get(self, language, security_limit):
return self._callback("menus_get", language, security_limit)
def dbus_getWaitingSub(self, profile_key="@DEFAULT@"):
return self._callback("getWaitingSub", profile_key)
def dbus_message_encryption_get(self, to_jid, profile_key):
return self._callback("message_encryption_get", to_jid, profile_key)
def dbus_historyGet(self, from_jid, to_jid, limit, between=True, filters='', profile="@NONE@"):
return self._callback("historyGet", from_jid, to_jid, limit, between, filters, profile)
def dbus_message_encryption_start(self, to_jid, namespace='', replace=False, profile_key="@NONE@"):
return self._callback("message_encryption_start", to_jid, namespace, replace, profile_key)
def dbus_imageCheck(self, arg_0):
return self._callback("imageCheck", arg_0)
def dbus_message_encryption_stop(self, to_jid, profile_key):
return self._callback("message_encryption_stop", to_jid, profile_key)
def dbus_imageConvert(self, source, dest, arg_2, extra):
return self._callback("imageConvert", source, dest, arg_2, extra)
def dbus_message_send(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@"):
return self._callback("message_send", to_jid, message, subject, mess_type, extra, profile_key)
def dbus_imageGeneratePreview(self, image_path, profile_key):
return self._callback("imageGeneratePreview", image_path, profile_key)
def dbus_namespaces_get(self, ):
return self._callback("namespaces_get", )
def dbus_imageResize(self, image_path, width, height):
return self._callback("imageResize", image_path, width, height)
def dbus_param_get_a(self, name, category, attribute="value", profile_key="@DEFAULT@"):
return self._callback("param_get_a", name, category, attribute, profile_key)
def dbus_isConnected(self, profile_key="@DEFAULT@"):
return self._callback("isConnected", profile_key)
def dbus_param_get_a_async(self, name, category, attribute="value", security_limit=-1, profile_key="@DEFAULT@"):
return self._callback("param_get_a_async", name, category, attribute, security_limit, profile_key)
def dbus_launchAction(self, callback_id, data, profile_key="@DEFAULT@"):
return self._callback("launchAction", callback_id, data, profile_key)
def dbus_param_set(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"):
return self._callback("param_set", name, value, category, security_limit, profile_key)
def dbus_loadParamsTemplate(self, filename):
return self._callback("loadParamsTemplate", filename)
def dbus_param_ui_get(self, security_limit=-1, app='', extra='', profile_key="@DEFAULT@"):
return self._callback("param_ui_get", security_limit, app, extra, profile_key)
def dbus_menuHelpGet(self, menu_id, language):
return self._callback("menuHelpGet", menu_id, language)
def dbus_params_categories_get(self, ):
return self._callback("params_categories_get", )
def dbus_menuLaunch(self, menu_type, path, data, security_limit, profile_key):
return self._callback("menuLaunch", menu_type, path, data, security_limit, profile_key)
def dbus_params_register_app(self, xml, security_limit=-1, app=''):
return self._callback("params_register_app", xml, security_limit, app)
def dbus_menusGet(self, language, security_limit):
return self._callback("menusGet", language, security_limit)
def dbus_params_template_load(self, filename):
return self._callback("params_template_load", filename)
def dbus_messageEncryptionGet(self, to_jid, profile_key):
return self._callback("messageEncryptionGet", to_jid, profile_key)
def dbus_params_template_save(self, filename):
return self._callback("params_template_save", filename)
def dbus_messageEncryptionStart(self, to_jid, namespace='', replace=False, profile_key="@NONE@"):
return self._callback("messageEncryptionStart", to_jid, namespace, replace, profile_key)
def dbus_params_values_from_category_get_async(self, category, security_limit=-1, app="", extra="", profile_key="@DEFAULT@"):
return self._callback("params_values_from_category_get_async", category, security_limit, app, extra, profile_key)
def dbus_messageEncryptionStop(self, to_jid, profile_key):
return self._callback("messageEncryptionStop", to_jid, profile_key)
def dbus_presence_set(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"):
return self._callback("presence_set", to_jid, show, statuses, profile_key)
def dbus_messageSend(self, to_jid, message, subject={}, mess_type="auto", extra={}, profile_key="@NONE@"):
return self._callback("messageSend", to_jid, message, subject, mess_type, extra, profile_key)
def dbus_presence_statuses_get(self, profile_key="@DEFAULT@"):
return self._callback("presence_statuses_get", profile_key)
def dbus_namespacesGet(self, ):
return self._callback("namespacesGet", )
def dbus_private_data_delete(self, namespace, key, arg_2):
return self._callback("private_data_delete", namespace, key, arg_2)
def dbus_paramsRegisterApp(self, xml, security_limit=-1, app=''):
return self._callback("paramsRegisterApp", xml, security_limit, app)
def dbus_private_data_get(self, namespace, key, profile_key):
return self._callback("private_data_get", namespace, key, profile_key)
def dbus_privateDataDelete(self, namespace, key, arg_2):
return self._callback("privateDataDelete", namespace, key, arg_2)
def dbus_private_data_set(self, namespace, key, data, profile_key):
return self._callback("private_data_set", namespace, key, data, profile_key)
def dbus_privateDataGet(self, namespace, key, profile_key):
return self._callback("privateDataGet", namespace, key, profile_key)
def dbus_profile_create(self, profile, password='', component=''):
return self._callback("profile_create", profile, password, component)
def dbus_privateDataSet(self, namespace, key, data, profile_key):
return self._callback("privateDataSet", namespace, key, data, profile_key)
def dbus_profile_delete_async(self, profile):
return self._callback("profile_delete_async", profile)
def dbus_profileCreate(self, profile, password='', component=''):
return self._callback("profileCreate", profile, password, component)
def dbus_profile_is_session_started(self, profile_key="@DEFAULT@"):
return self._callback("profile_is_session_started", profile_key)
def dbus_profileIsSessionStarted(self, profile_key="@DEFAULT@"):
return self._callback("profileIsSessionStarted", profile_key)
def dbus_profile_name_get(self, profile_key="@DEFAULT@"):
return self._callback("profile_name_get", profile_key)
def dbus_profileNameGet(self, profile_key="@DEFAULT@"):
return self._callback("profileNameGet", profile_key)
def dbus_profile_set_default(self, profile):
return self._callback("profile_set_default", profile)
def dbus_profileSetDefault(self, profile):
return self._callback("profileSetDefault", profile)
def dbus_profile_start_session(self, password='', profile_key="@DEFAULT@"):
return self._callback("profile_start_session", password, profile_key)
def dbus_profileStartSession(self, password='', profile_key="@DEFAULT@"):
return self._callback("profileStartSession", password, profile_key)
def dbus_profiles_list_get(self, clients=True, components=False):
return self._callback("profiles_list_get", clients, components)
def dbus_profilesListGet(self, clients=True, components=False):
return self._callback("profilesListGet", clients, components)
def dbus_progress_get(self, id, profile):
return self._callback("progress_get", id, profile)
def dbus_progressGet(self, id, profile):
return self._callback("progressGet", id, profile)
def dbus_progress_get_all(self, profile):
return self._callback("progress_get_all", profile)
def dbus_progressGetAll(self, profile):
return self._callback("progressGetAll", profile)
def dbus_progress_get_all_metadata(self, profile):
return self._callback("progress_get_all_metadata", profile)
def dbus_progressGetAllMetadata(self, profile):
return self._callback("progressGetAllMetadata", profile)
def dbus_ready_get(self, ):
return self._callback("ready_get", )
def dbus_rosterResync(self, profile_key="@DEFAULT@"):
return self._callback("rosterResync", profile_key)
def dbus_roster_resync(self, profile_key="@DEFAULT@"):
return self._callback("roster_resync", profile_key)
def dbus_saveParamsTemplate(self, filename):
return self._callback("saveParamsTemplate", filename)
def dbus_session_infos_get(self, profile_key):
return self._callback("session_infos_get", profile_key)
def dbus_sessionInfosGet(self, profile_key):
return self._callback("sessionInfosGet", profile_key)
def dbus_setParam(self, name, value, category, security_limit=-1, profile_key="@DEFAULT@"):
return self._callback("setParam", name, value, category, security_limit, profile_key)
def dbus_setPresence(self, to_jid='', show='', statuses={}, profile_key="@DEFAULT@"):
return self._callback("setPresence", to_jid, show, statuses, profile_key)
def dbus_sub_waiting_get(self, profile_key="@DEFAULT@"):
return self._callback("sub_waiting_get", profile_key)
def dbus_subscription(self, sub_type, entity, profile_key="@DEFAULT@"):
return self._callback("subscription", sub_type, entity, profile_key)
def dbus_updateContact(self, entity_jid, name, groups, profile_key="@DEFAULT@"):
return self._callback("updateContact", entity_jid, name, groups, profile_key)
def dbus_version_get(self, ):
return self._callback("version_get", )
class Bridge:
class bridge:
def __init__(self):
log.info("Init DBus...")
self._obj = DBusObject(const_OBJ_PATH)
async def postInit(self):
async def post_init(self):
try:
conn = await client.connect(reactor)
except error.DBusException as e:
@ -420,47 +420,47 @@ class Bridge:
def _debug(self, action, params, profile):
self._obj.emitSignal("_debug", action, params, profile)
def actionNew(self, action_data, id, security_limit, profile):
self._obj.emitSignal("actionNew", action_data, id, security_limit, profile)
def action_new(self, action_data, id, security_limit, profile):
self._obj.emitSignal("action_new", action_data, id, security_limit, profile)
def connected(self, jid_s, profile):
self._obj.emitSignal("connected", jid_s, profile)
def contactDeleted(self, entity_jid, profile):
self._obj.emitSignal("contactDeleted", entity_jid, profile)
def contact_deleted(self, entity_jid, profile):
self._obj.emitSignal("contact_deleted", entity_jid, profile)
def contact_new(self, contact_jid, attributes, groups, profile):
self._obj.emitSignal("contact_new", contact_jid, attributes, groups, profile)
def disconnected(self, profile):
self._obj.emitSignal("disconnected", profile)
def entityDataUpdated(self, jid, name, value, profile):
self._obj.emitSignal("entityDataUpdated", jid, name, value, profile)
def entity_data_updated(self, jid, name, value, profile):
self._obj.emitSignal("entity_data_updated", jid, name, value, profile)
def messageEncryptionStarted(self, to_jid, encryption_data, profile_key):
self._obj.emitSignal("messageEncryptionStarted", to_jid, encryption_data, profile_key)
def message_encryption_started(self, to_jid, encryption_data, profile_key):
self._obj.emitSignal("message_encryption_started", to_jid, encryption_data, profile_key)
def messageEncryptionStopped(self, to_jid, encryption_data, profile_key):
self._obj.emitSignal("messageEncryptionStopped", to_jid, encryption_data, profile_key)
def message_encryption_stopped(self, to_jid, encryption_data, profile_key):
self._obj.emitSignal("message_encryption_stopped", to_jid, encryption_data, profile_key)
def messageNew(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
self._obj.emitSignal("messageNew", uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile)
def message_new(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
self._obj.emitSignal("message_new", uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile)
def newContact(self, contact_jid, attributes, groups, profile):
self._obj.emitSignal("newContact", contact_jid, attributes, groups, profile)
def param_update(self, name, value, category, profile):
self._obj.emitSignal("param_update", name, value, category, profile)
def paramUpdate(self, name, value, category, profile):
self._obj.emitSignal("paramUpdate", name, value, category, profile)
def presence_update(self, entity_jid, show, priority, statuses, profile):
self._obj.emitSignal("presence_update", entity_jid, show, priority, statuses, profile)
def presenceUpdate(self, entity_jid, show, priority, statuses, profile):
self._obj.emitSignal("presenceUpdate", entity_jid, show, priority, statuses, profile)
def progress_error(self, id, error, profile):
self._obj.emitSignal("progress_error", id, error, profile)
def progressError(self, id, error, profile):
self._obj.emitSignal("progressError", id, error, profile)
def progress_finished(self, id, metadata, profile):
self._obj.emitSignal("progress_finished", id, metadata, profile)
def progressFinished(self, id, metadata, profile):
self._obj.emitSignal("progressFinished", id, metadata, profile)
def progressStarted(self, id, metadata, profile):
self._obj.emitSignal("progressStarted", id, metadata, profile)
def progress_started(self, id, metadata, profile):
self._obj.emitSignal("progress_started", id, metadata, profile)
def subscribe(self, sub_type, entity_jid, profile):
self._obj.emitSignal("subscribe", sub_type, entity_jid, profile)
@ -469,13 +469,13 @@ class Bridge:
log.debug(f"registering DBus bridge method [{name}]")
self._obj.register_method(name, callback)
def emitSignal(self, name, *args):
def emit_signal(self, name, *args):
self._obj.emitSignal(name, *args)
def addMethod(
def add_method(
self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
):
"""Dynamically add a method to D-Bus Bridge"""
"""Dynamically add a method to D-Bus bridge"""
# FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug(f"Adding method {name!r} to D-Bus bridge")
self._obj.plugin_iface.addMethod(
@ -488,8 +488,8 @@ class Bridge:
setattr(self._obj, f"dbus_{name}", MethodType(caller, self._obj))
self.register_method(name, method)
def addSignal(self, name, int_suffix, signature, doc={}):
"""Dynamically add a signal to D-Bus Bridge"""
def add_signal(self, name, int_suffix, signature, doc={}):
"""Dynamically add a signal to D-Bus bridge"""
log.debug(f"Adding signal {name!r} to D-Bus bridge")
self._obj.plugin_iface.addSignal(Signal(name, signature))
setattr(Bridge, name, partialmethod(Bridge.emitSignal, name))
setattr(bridge, name, partialmethod(bridge.emit_signal, name))

View file

@ -55,17 +55,17 @@ class PBRoot(pb.Root):
def __init__(self):
self.signals_handlers = []
def remote_initBridge(self, signals_handler):
def remote_init_bridge(self, signals_handler):
self.signals_handlers.append(HandlerWrapper(signals_handler))
log.info("registered signal handler")
def sendSignalEb(self, failure_, signal_name):
def send_signal_eb(self, failure_, signal_name):
if not failure_.check(pb.PBConnectionLost):
log.error(
f"Error while sending signal {signal_name}: {failure_}",
)
def sendSignal(self, name, args, kwargs):
def send_signal(self, name, args, kwargs):
to_remove = []
for wrapper in self.signals_handlers:
handler = wrapper.handler
@ -74,13 +74,13 @@ class PBRoot(pb.Root):
except pb.DeadReferenceError:
to_remove.append(wrapper)
else:
d.addErrback(self.sendSignalEb, name)
d.addErrback(self.send_signal_eb, name)
if to_remove:
for wrapper in to_remove:
log.debug("Removing signal handler for dead frontend")
self.signals_handlers.remove(wrapper)
def _bridgeDeactivateSignals(self):
def _bridge_deactivate_signals(self):
if hasattr(self, "signals_paused"):
log.warning("bridge signals already deactivated")
if self.signals_handler:
@ -90,7 +90,7 @@ class PBRoot(pb.Root):
self.signals_handlers = []
log.debug("bridge signals have been deactivated")
def _bridgeReactivateSignals(self):
def _bridge_reactivate_signals(self):
try:
self.signals_handlers = self.signals_paused
except AttributeError:
@ -102,31 +102,31 @@ class PBRoot(pb.Root):
##METHODS_PART##
class Bridge(object):
class bridge(object):
def __init__(self):
log.info("Init Perspective Broker...")
self.root = PBRoot()
conf = config.parseMainConf()
getConf = partial(config.getConf, conf, "bridge_pb", "")
conn_type = getConf("connection_type", "unix_socket")
conf = config.parse_main_conf()
get_conf = partial(config.get_conf, conf, "bridge_pb", "")
conn_type = get_conf("connection_type", "unix_socket")
if conn_type == "unix_socket":
local_dir = Path(config.getConfig(conf, "", "local_dir")).resolve()
local_dir = Path(config.config_get(conf, "", "local_dir")).resolve()
socket_path = local_dir / "bridge_pb"
log.info(f"using UNIX Socket at {socket_path}")
reactor.listenUNIX(
str(socket_path), pb.PBServerFactory(self.root), mode=0o600
)
elif conn_type == "socket":
port = int(getConf("port", 8789))
port = int(get_conf("port", 8789))
log.info(f"using TCP Socket at port {port}")
reactor.listenTCP(port, pb.PBServerFactory(self.root))
else:
raise ValueError(f"Unknown pb connection type: {conn_type!r}")
def sendSignal(self, name, *args, **kwargs):
self.root.sendSignal(name, args, kwargs)
def send_signal(self, name, *args, **kwargs):
self.root.send_signal(name, args, kwargs)
def remote_initBridge(self, signals_handler):
def remote_init_bridge(self, signals_handler):
self.signals_handlers.append(signals_handler)
log.info("registered signal handler")
@ -135,78 +135,78 @@ class Bridge(object):
setattr(self.root, "remote_" + name, callback)
#  self.root.register_method(name, callback)
def addMethod(
def add_method(
self, name, int_suffix, in_sign, out_sign, method, async_=False, doc={}
):
"""Dynamically add a method to PB Bridge"""
"""Dynamically add a method to PB bridge"""
# FIXME: doc parameter is kept only temporary, the time to remove it from calls
log.debug("Adding method {name} to PB bridge".format(name=name))
self.register_method(name, method)
def addSignal(self, name, int_suffix, signature, doc={}):
def add_signal(self, name, int_suffix, signature, doc={}):
log.debug("Adding signal {name} to PB bridge".format(name=name))
setattr(
self, name, lambda *args, **kwargs: self.sendSignal(name, *args, **kwargs)
self, name, lambda *args, **kwargs: self.send_signal(name, *args, **kwargs)
)
def bridgeDeactivateSignals(self):
def bridge_deactivate_signals(self):
"""Stop sending signals to bridge
Mainly used for mobile frontends, when the frontend is paused
"""
self.root._bridgeDeactivateSignals()
self.root._bridge_deactivate_signals()
def bridgeReactivateSignals(self):
def bridge_reactivate_signals(self):
"""Send again signals to bridge
Should only be used after bridgeDeactivateSignals has been called
Should only be used after bridge_deactivate_signals has been called
"""
self.root._bridgeReactivateSignals()
self.root._bridge_reactivate_signals()
def _debug(self, action, params, profile):
self.sendSignal("_debug", action, params, profile)
self.send_signal("_debug", action, params, profile)
def actionNew(self, action_data, id, security_limit, profile):
self.sendSignal("actionNew", action_data, id, security_limit, profile)
def action_new(self, action_data, id, security_limit, profile):
self.send_signal("action_new", action_data, id, security_limit, profile)
def connected(self, jid_s, profile):
self.sendSignal("connected", jid_s, profile)
self.send_signal("connected", jid_s, profile)
def contactDeleted(self, entity_jid, profile):
self.sendSignal("contactDeleted", entity_jid, profile)
def contact_deleted(self, entity_jid, profile):
self.send_signal("contact_deleted", entity_jid, profile)
def contact_new(self, contact_jid, attributes, groups, profile):
self.send_signal("contact_new", contact_jid, attributes, groups, profile)
def disconnected(self, profile):
self.sendSignal("disconnected", profile)
self.send_signal("disconnected", profile)
def entityDataUpdated(self, jid, name, value, profile):
self.sendSignal("entityDataUpdated", jid, name, value, profile)
def entity_data_updated(self, jid, name, value, profile):
self.send_signal("entity_data_updated", jid, name, value, profile)
def messageEncryptionStarted(self, to_jid, encryption_data, profile_key):
self.sendSignal("messageEncryptionStarted", to_jid, encryption_data, profile_key)
def message_encryption_started(self, to_jid, encryption_data, profile_key):
self.send_signal("message_encryption_started", to_jid, encryption_data, profile_key)
def messageEncryptionStopped(self, to_jid, encryption_data, profile_key):
self.sendSignal("messageEncryptionStopped", to_jid, encryption_data, profile_key)
def message_encryption_stopped(self, to_jid, encryption_data, profile_key):
self.send_signal("message_encryption_stopped", to_jid, encryption_data, profile_key)
def messageNew(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
self.sendSignal("messageNew", uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile)
def message_new(self, uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile):
self.send_signal("message_new", uid, timestamp, from_jid, to_jid, message, subject, mess_type, extra, profile)
def newContact(self, contact_jid, attributes, groups, profile):
self.sendSignal("newContact", contact_jid, attributes, groups, profile)
def param_update(self, name, value, category, profile):
self.send_signal("param_update", name, value, category, profile)
def paramUpdate(self, name, value, category, profile):
self.sendSignal("paramUpdate", name, value, category, profile)
def presence_update(self, entity_jid, show, priority, statuses, profile):
self.send_signal("presence_update", entity_jid, show, priority, statuses, profile)
def presenceUpdate(self, entity_jid, show, priority, statuses, profile):
self.sendSignal("presenceUpdate", entity_jid, show, priority, statuses, profile)
def progress_error(self, id, error, profile):
self.send_signal("progress_error", id, error, profile)
def progressError(self, id, error, profile):
self.sendSignal("progressError", id, error, profile)
def progress_finished(self, id, metadata, profile):
self.send_signal("progress_finished", id, metadata, profile)
def progressFinished(self, id, metadata, profile):
self.sendSignal("progressFinished", id, metadata, profile)
def progressStarted(self, id, metadata, profile):
self.sendSignal("progressStarted", id, metadata, profile)
def progress_started(self, id, metadata, profile):
self.send_signal("progress_started", id, metadata, profile)
def subscribe(self, sub_type, entity_jid, profile):
self.sendSignal("subscribe", sub_type, entity_jid, profile)
self.send_signal("subscribe", sub_type, entity_jid, profile)

View file

@ -435,7 +435,7 @@ class Const(object):
return value.lower() in (cls.BOOL_TRUE, "1", "yes", "on")
@classmethod
def boolConst(cls, value: bool) -> str:
def bool_const(cls, value: bool) -> str:
"""@return (str): constant associated to bool value"""
assert isinstance(value, bool)
return cls.BOOL_TRUE if value else cls.BOOL_FALSE

View file

@ -30,7 +30,7 @@ try:
_ = gettext.translation("sat", "i18n", fallback=True).gettext
_translators = {None: gettext.NullTranslations()}
def languageSwitch(lang=None):
def language_switch(lang=None):
if not lang in _translators:
_translators[lang] = gettext.translation(
"sat", languages=[lang], fallback=True
@ -43,7 +43,7 @@ except ImportError:
log.warning("gettext support disabled")
_ = cast(Callable[[str], str], lambda msg: msg) # Libervia doesn't support gettext
def languageSwitch(lang=None):
def language_switch(lang=None):
pass

View file

@ -121,7 +121,7 @@ class Logger:
'levelname': level,
}
try:
if not self.filter_name.dictFilter(record):
if not self.filter_name.dict_filter(record):
raise Filtered
except (AttributeError, TypeError): # XXX: TypeError is here because of a pyjamas bug which need to be fixed (TypeError is raised instead of AttributeError)
if self.filter_name is not None:
@ -133,7 +133,7 @@ class Logger:
except KeyError as e:
if e.args[0] == 'profile':
# XXX: %(profile)s use some magic with introspection, for debugging purpose only *DO NOT* use in production
record['profile'] = configure_cls[backend].getProfile()
record['profile'] = configure_cls[backend].get_profile()
return self.fmt % record
else:
raise e
@ -174,7 +174,7 @@ class FilterName(object):
return 1
return 0
def dictFilter(self, dict_record):
def dict_filter(self, dict_record):
"""Filter using a dictionary record
@param dict_record: dictionary with at list a key "name" with logger name
@ -208,26 +208,26 @@ class ConfigureBase:
@param force_colors: if True ANSI colors are used even if stdout is not a tty
"""
self.backend_data = backend_data
self.preTreatment()
self.configureLevel(level)
self.configureFormat(fmt)
self.configureOutput(output)
self.configureLogger(logger)
self.configureColors(colors, force_colors, levels_taints_dict)
self.postTreatment()
self.updateCurrentLogger()
self.pre_treatment()
self.configure_level(level)
self.configure_format(fmt)
self.configure_output(output)
self.configure_logger(logger)
self.configure_colors(colors, force_colors, levels_taints_dict)
self.post_treatment()
self.update_current_logger()
def updateCurrentLogger(self):
def update_current_logger(self):
"""update existing logger to the class needed for this backend"""
if self.LOGGER_CLASS is None:
return
for name, logger in list(_loggers.items()):
_loggers[name] = self.LOGGER_CLASS(logger)
def preTreatment(self):
def pre_treatment(self):
pass
def configureLevel(self, level):
def configure_level(self, level):
if level is not None:
# we deactivate methods below level
level_idx = C.LOG_LEVELS.index(level)
@ -236,7 +236,7 @@ class ConfigureBase:
for _level in C.LOG_LEVELS[:level_idx]:
setattr(Logger, _level.lower(), dev_null)
def configureFormat(self, fmt):
def configure_format(self, fmt):
if fmt is not None:
if fmt != '%(message)s': # %(message)s is the same as None
Logger.fmt = fmt
@ -246,17 +246,17 @@ class ConfigureBase:
# color_start not followed by an end, we add it
Logger.fmt += COLOR_END
def configureOutput(self, output):
def configure_output(self, output):
if output is not None:
if output != C.LOG_OPT_OUTPUT_SEP + C.LOG_OPT_OUTPUT_DEFAULT:
# TODO: manage other outputs
raise NotImplementedError("Basic backend only manage default output yet")
def configureLogger(self, logger):
def configure_logger(self, logger):
if logger:
Logger.filter_name = FilterName(logger)
def configureColors(self, colors, force_colors, levels_taints_dict):
def configure_colors(self, colors, force_colors, levels_taints_dict):
if colors:
# if color are used, we need to handle levels_taints_dict
for level in list(levels_taints_dict.keys()):
@ -280,10 +280,10 @@ class ConfigureBase:
ansi_list.append(ansi)
taints[level] = ''.join(ansi_list)
def postTreatment(self):
def post_treatment(self):
pass
def manageOutputs(self, outputs_raw):
def manage_outputs(self, outputs_raw):
""" Parse output option in a backend agnostic way, and fill handlers consequently
@param outputs_raw: output option as enterred in environment variable or in configuration
@ -330,7 +330,7 @@ class ConfigureBase:
raise ValueError("options [{options}] are not supported for {handler} output".format(options=options, handler=output))
@staticmethod
def memoryGet(size=None):
def memory_get(size=None):
"""Return buffered logs
@param size: number of logs to return
@ -338,7 +338,7 @@ class ConfigureBase:
raise NotImplementedError
@classmethod
def ansiColors(cls, level, message):
def ansi_colors(cls, level, message):
"""Colorise message depending on level for terminals
@param level: one of C.LOG_LEVELS
@ -358,7 +358,7 @@ class ConfigureBase:
return '%s%s%s' % (start, message, A.RESET)
@staticmethod
def getProfile():
def get_profile():
"""Try to find profile value using introspection"""
raise NotImplementedError
@ -396,10 +396,10 @@ def configure(backend_, **options):
else:
configure_class(**options)
def memoryGet(size=None):
def memory_get(size=None):
if not C.LOG_OPT_OUTPUT_MEMORY in handlers:
raise ValueError('memory output is not used')
return configure_cls[backend].memoryGet(size)
return configure_cls[backend].memory_get(size)
def getLogger(name=C.LOG_BASE_LOGGER) -> Logger:
try:

View file

@ -47,8 +47,8 @@ class TwistedLogger(log.Logger):
class ConfigureBasic(log.ConfigureBase):
def configureColors(self, colors, force_colors, levels_taints_dict):
super(ConfigureBasic, self).configureColors(
def configure_colors(self, colors, force_colors, levels_taints_dict):
super(ConfigureBasic, self).configure_colors(
colors, force_colors, levels_taints_dict
)
if colors:
@ -61,14 +61,14 @@ class ConfigureBasic(log.ConfigureBase):
# FIXME: isatty should be tested on each handler, not globaly
if (force_colors or isatty):
# we need colors
log.Logger.post_treat = lambda logger, level, message: self.ansiColors(
log.Logger.post_treat = lambda logger, level, message: self.ansi_colors(
level, message
)
elif force_colors:
raise ValueError("force_colors can't be used if colors is False")
@staticmethod
def getProfile():
def get_profile():
"""Try to find profile value using introspection"""
import inspect
@ -107,7 +107,7 @@ class ConfigureBasic(log.ConfigureBase):
class ConfigureTwisted(ConfigureBasic):
LOGGER_CLASS = TwistedLogger
def preTreatment(self):
def pre_treatment(self):
from twisted import logger
global logger
self.level_map = {
@ -119,17 +119,17 @@ class ConfigureTwisted(ConfigureBasic):
}
self.LOGGER_CLASS.level_map = self.level_map
def configureLevel(self, level):
def configure_level(self, level):
self.level = self.level_map[level]
def configureOutput(self, output):
def configure_output(self, output):
import sys
from twisted.python import logfile
self.log_publisher = logger.LogPublisher()
if output is None:
output = C.LOG_OPT_OUTPUT_SEP + C.LOG_OPT_OUTPUT_DEFAULT
self.manageOutputs(output)
self.manage_outputs(output)
if C.LOG_OPT_OUTPUT_DEFAULT in log.handlers:
if self.backend_data is None:
@ -139,11 +139,11 @@ class ConfigureTwisted(ConfigureBasic):
options = self.backend_data
log_file = logfile.LogFile.fromFullPath(options['logfile'])
self.log_publisher.addObserver(
logger.FileLogObserver(log_file, self.textFormatter))
logger.FileLogObserver(log_file, self.text_formatter))
# we also want output to stdout if we are in debug or nodaemon mode
if options.get("nodaemon", False) or options.get("debug", False):
self.log_publisher.addObserver(
logger.FileLogObserver(sys.stdout, self.textFormatter))
logger.FileLogObserver(sys.stdout, self.text_formatter))
if C.LOG_OPT_OUTPUT_FILE in log.handlers:
@ -152,15 +152,15 @@ class ConfigureTwisted(ConfigureBasic):
sys.stdout if path == "-" else logfile.LogFile.fromFullPath(path)
)
self.log_publisher.addObserver(
logger.FileLogObserver(log_file, self.textFormatter))
logger.FileLogObserver(log_file, self.text_formatter))
if C.LOG_OPT_OUTPUT_MEMORY in log.handlers:
raise NotImplementedError(
"Memory observer is not implemented in Twisted backend"
)
def configureColors(self, colors, force_colors, levels_taints_dict):
super(ConfigureTwisted, self).configureColors(
def configure_colors(self, colors, force_colors, levels_taints_dict):
super(ConfigureTwisted, self).configure_colors(
colors, force_colors, levels_taints_dict
)
self.LOGGER_CLASS.colors = colors
@ -168,7 +168,7 @@ class ConfigureTwisted(ConfigureBasic):
if force_colors and not colors:
raise ValueError("colors must be True if force_colors is True")
def postTreatment(self):
def post_treatment(self):
"""Install twistedObserver which manage non SàT logs"""
# from twisted import logger
import sys
@ -180,7 +180,7 @@ class ConfigureTwisted(ConfigureBasic):
)
logger.globalLogBeginner.beginLoggingTo([filtering_obs])
def textFormatter(self, event):
def text_formatter(self, event):
if event.get('sat_logged', False):
timestamp = ''.join([logger.formatTime(event.get("log_time", None)), " "])
return f"{timestamp}{event.get('log_format', '')}\n"
@ -219,7 +219,7 @@ class ConfigureStandard(ConfigureBasic):
backend_data,
)
def preTreatment(self):
def pre_treatment(self):
"""We use logging methods directly, instead of using Logger"""
import logging
@ -230,13 +230,13 @@ class ConfigureStandard(ConfigureBasic):
log.error = logging.error
log.critical = logging.critical
def configureLevel(self, level):
def configure_level(self, level):
if level is None:
level = C.LOG_LVL_DEBUG
self.level = level
def configureFormat(self, fmt):
super(ConfigureStandard, self).configureFormat(fmt)
def configure_format(self, fmt):
super(ConfigureStandard, self).configure_format(fmt)
import logging
class SatFormatter(logging.Formatter):
@ -250,11 +250,11 @@ class ConfigureStandard(ConfigureBasic):
def format(self, record):
if self._with_profile:
record.profile = ConfigureStandard.getProfile()
record.profile = ConfigureStandard.get_profile()
do_color = self.with_colors and (self.can_colors or self.force_colors)
if ConfigureStandard._color_location:
# we copy raw formatting strings for color_*
# as formatting is handled in ansiColors in this case
# as formatting is handled in ansi_colors in this case
if do_color:
record.color_start = log.COLOR_START
record.color_end = log.COLOR_END
@ -262,19 +262,19 @@ class ConfigureStandard(ConfigureBasic):
record.color_start = record.color_end = ""
s = super(SatFormatter, self).format(record)
if do_color:
s = ConfigureStandard.ansiColors(record.levelname, s)
s = ConfigureStandard.ansi_colors(record.levelname, s)
return s
self.formatterClass = SatFormatter
def configureOutput(self, output):
self.manageOutputs(output)
def configure_output(self, output):
self.manage_outputs(output)
def configureLogger(self, logger):
def configure_logger(self, logger):
self.name_filter = log.FilterName(logger) if logger else None
def configureColors(self, colors, force_colors, levels_taints_dict):
super(ConfigureStandard, self).configureColors(
def configure_colors(self, colors, force_colors, levels_taints_dict):
super(ConfigureStandard, self).configure_colors(
colors, force_colors, levels_taints_dict
)
self.formatterClass.with_colors = colors
@ -282,14 +282,14 @@ class ConfigureStandard(ConfigureBasic):
if not colors and force_colors:
raise ValueError("force_colors can't be used if colors is False")
def _addHandler(self, root_logger, hdlr, can_colors=False):
def _add_handler(self, root_logger, hdlr, can_colors=False):
hdlr.setFormatter(self.formatterClass(can_colors))
root_logger.addHandler(hdlr)
root_logger.setLevel(self.level)
if self.name_filter is not None:
hdlr.addFilter(self.name_filter)
def postTreatment(self):
def post_treatment(self):
import logging
root_logger = logging.getLogger()
@ -301,7 +301,7 @@ class ConfigureStandard(ConfigureBasic):
can_colors = hdlr.stream.isatty()
except AttributeError:
can_colors = False
self._addHandler(root_logger, hdlr, can_colors=can_colors)
self._add_handler(root_logger, hdlr, can_colors=can_colors)
elif handler == C.LOG_OPT_OUTPUT_MEMORY:
from logging.handlers import BufferingHandler
@ -315,20 +315,20 @@ class ConfigureStandard(ConfigureBasic):
] = (
hdlr
) # we keep a reference to the handler to read the buffer later
self._addHandler(root_logger, hdlr, can_colors=False)
self._add_handler(root_logger, hdlr, can_colors=False)
elif handler == C.LOG_OPT_OUTPUT_FILE:
import os.path
for path in options:
hdlr = logging.FileHandler(os.path.expanduser(path))
self._addHandler(root_logger, hdlr, can_colors=False)
self._add_handler(root_logger, hdlr, can_colors=False)
else:
raise ValueError("Unknown handler type")
else:
root_logger.warning("Handlers already set on root logger")
@staticmethod
def memoryGet(size=None):
def memory_get(size=None):
"""Return buffered logs
@param size: number of logs to return
@ -355,7 +355,7 @@ def configure(backend, **options):
return log.configure(backend, **options)
def _parseOptions(options):
def _parse_options(options):
"""Parse string options as given in conf or environment variable, and return expected python value
@param options (dict): options with (key: name, value: string value)
@ -378,7 +378,7 @@ def _parseOptions(options):
options[LEVEL] = level
def satConfigure(backend=C.LOG_BACKEND_STANDARD, const=None, backend_data=None):
def sat_configure(backend=C.LOG_BACKEND_STANDARD, const=None, backend_data=None):
"""Configure logging system for SàT, can be used by frontends
logs conf is read in SàT conf, then in environment variables. It must be done before Memory init
@ -396,16 +396,16 @@ def satConfigure(backend=C.LOG_BACKEND_STANDARD, const=None, backend_data=None):
import os
log_conf = {}
sat_conf = config.parseMainConf()
sat_conf = config.parse_main_conf()
for opt_name, opt_default in C.LOG_OPTIONS():
try:
log_conf[opt_name] = os.environ[
"".join((C.ENV_PREFIX, C.LOG_OPT_PREFIX.upper(), opt_name.upper()))
]
except KeyError:
log_conf[opt_name] = config.getConfig(
log_conf[opt_name] = config.config_get(
sat_conf, C.LOG_OPT_SECTION, C.LOG_OPT_PREFIX + opt_name, opt_default
)
_parseOptions(log_conf)
_parse_options(log_conf)
configure(backend, backend_data=backend_data, **log_conf)

Some files were not shown because too many files have changed in this diff Show more