Skip to content

Commit

Permalink
style: format code with Black and PHP CS Fixer
Browse files Browse the repository at this point in the history
This commit fixes the style issues introduced in 7abbf80 according to the output
from Black and PHP CS Fixer.

Details: None
  • Loading branch information
deepsource-autofix[bot] authored Dec 3, 2024
1 parent 7abbf80 commit 2deb1b2
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions pulse_xmpp_agent/connectionagent.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@

logger = logging.getLogger()


class MUCBot(ClientXMPP):
"""
MUCBot class inherits from ClientXMPP and handles XMPP connections and messages.
Expand Down Expand Up @@ -187,9 +188,9 @@ def __init__(self, conf):
# Planification d'un événement pour gérer le dépassement du délai
self.schedule(
"assessor_response_timeout_event", # Nom de l'événement
self.assessor_response_timeout, # Délai en secondes
self.assessor_response_timeout, # Délai en secondes
self.handle_assessor_timeout, # Fonction appelée en cas de timeout
repeat=False # L'événement ne se répète pas
repeat=False, # L'événement ne se répète pas
)

if self.config.syncthing_on:
Expand Down Expand Up @@ -281,7 +282,9 @@ def handle_assessor_timeout(self):
"""
Handle the timeout event for the assessor response.
"""
logger.error(f"Assessor timeout: No response within {self.assessor_response_timeout} seconds.")
logger.error(
f"Assessor timeout: No response within {self.assessor_response_timeout} seconds."
)
self.disconnect(wait=1)

def stream_error1(self, mesg):
Expand Down Expand Up @@ -904,15 +907,14 @@ async def register(self, iq):
iq: The IQ stanza.
"""
resp = self.Iq()
resp['type'] = 'set'
resp['register']['username'] = self.boundjid.user
resp['register']['password'] = self.password
resp["type"] = "set"
resp["register"]["username"] = self.boundjid.user
resp["register"]["password"] = self.password
try:
await resp.send()
logging.info("Account created for %s!" % self.boundjid)
except IqError as e:
logging.debug("Could not register account: %s" %
e.iq['error']['text'])
logging.debug("Could not register account: %s" % e.iq["error"]["text"])
except IqTimeout:
logging.error("Could not register account No response from server.")
self.disconnect()
Expand Down Expand Up @@ -1011,6 +1013,7 @@ def _errorhandlingstanza(self, msg, msgfrom, msgkey):
# ---------------------- END analyse strophe xmpp -----------------------
# -----------------------------------------------------------------------


def createDaemon(optstypemachine, optsconsoledebug, optsdeamon, tglevellog, tglogfile):
"""
Create a service/Daemon that will execute a det. task.
Expand Down Expand Up @@ -1052,6 +1055,7 @@ def createDaemon(optstypemachine, optsconsoledebug, optsdeamon, tglevellog, tglo
logger.error("\n%s" % (traceback.format_exc()))
os._exit(1)


def doTask(optstypemachine, optsconsoledebug, optsdeamon, tglevellog, tglogfile):
"""
Execute the task.
Expand Down Expand Up @@ -1172,8 +1176,9 @@ def doTask(optstypemachine, optsconsoledebug, optsdeamon, tglevellog, tglogfile)
logging.error("RuntimeError during connection")
finally:
logger.debug("bye bye connecteur")
namefilebool = os.path.join(os.path.dirname(os.path.realpath(__file__)),
"BOOLCONNECTOR")
namefilebool = os.path.join(
os.path.dirname(os.path.realpath(__file__)), "BOOLCONNECTOR"
)
fichier = open(namefilebool, "w")
fichier.close()
# xmpp.loop.close()
Expand All @@ -1187,6 +1192,7 @@ def doTask(optstypemachine, optsconsoledebug, optsdeamon, tglevellog, tglogfile)
)
sys.exit(1) # Quitte le programme avec un code d'erreur


if __name__ == "__main__":
if sys.platform.startswith("linux") and os.getuid() != 0:
logging.error("Agent must be running as root")
Expand Down

0 comments on commit 2deb1b2

Please sign in to comment.