run pyupgrade
This commit is contained in:
parent
bf2514cb09
commit
04bd6b3ef0
29 changed files with 173 additions and 221 deletions
|
|
@ -183,7 +183,7 @@ async def shutdown():
|
|||
bumperlog.info("Coroutine canceled")
|
||||
|
||||
except Exception as e:
|
||||
bumperlog.info("Exception: {}".format(e))
|
||||
bumperlog.info(f"Exception: {e}")
|
||||
|
||||
finally:
|
||||
bumperlog.info("Shutdown complete")
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ class ConfServer:
|
|||
async def start_server(self):
|
||||
try:
|
||||
confserverlog.info(
|
||||
"Starting ConfServer at {}:{}".format(self.address[0], self.address[1])
|
||||
f"Starting ConfServer at {self.address[0]}:{self.address[1]}"
|
||||
)
|
||||
self.runner = web.AppRunner(self.app)
|
||||
await self.runner.setup()
|
||||
|
|
@ -157,7 +157,7 @@ class ConfServer:
|
|||
pass
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
asyncio.create_task(bumper.shutdown())
|
||||
|
||||
async def stop_server(self):
|
||||
|
|
@ -165,7 +165,7 @@ class ConfServer:
|
|||
await self.runner.shutdown()
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
async def handle_base(self, request):
|
||||
try:
|
||||
|
|
@ -205,7 +205,7 @@ class ConfServer:
|
|||
return resp
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
@web.middleware
|
||||
async def log_all_requests(self, request, handler):
|
||||
|
|
@ -231,7 +231,7 @@ class ConfServer:
|
|||
try:
|
||||
postbody = json.loads(await request.text())
|
||||
except Exception as e:
|
||||
confserverlog.error("Request body not json: {} - {}".format(e, e.doc))
|
||||
confserverlog.error(f"Request body not json: {e} - {e.doc}")
|
||||
postbody = e.doc
|
||||
|
||||
else:
|
||||
|
|
@ -256,12 +256,12 @@ class ConfServer:
|
|||
return response
|
||||
|
||||
except web.HTTPNotFound as notfound:
|
||||
confserverlog.debug("Request path {} not found".format(request.raw_path))
|
||||
confserverlog.debug(f"Request path {request.raw_path} not found")
|
||||
confserverlog.debug(json.dumps(to_log))
|
||||
return notfound
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
confserverlog.error(json.dumps(to_log))
|
||||
return e
|
||||
|
||||
|
|
@ -319,7 +319,7 @@ class ConfServer:
|
|||
return web.json_response({"status": "invalid service"})
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
pass
|
||||
|
||||
async def handle_RemoveBot(self, request):
|
||||
|
|
@ -332,7 +332,7 @@ class ConfServer:
|
|||
return web.json_response({"status": "successfully removed bot"})
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
pass
|
||||
|
||||
async def handle_RemoveClient(self, request):
|
||||
|
|
@ -345,7 +345,7 @@ class ConfServer:
|
|||
return web.json_response({"status": "successfully removed client"})
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
pass
|
||||
|
||||
async def handle_login(self, request):
|
||||
|
|
@ -354,7 +354,7 @@ class ConfServer:
|
|||
countrycode = request.match_info.get("country", "us")
|
||||
apptype = request.match_info.get("apptype", "")
|
||||
confserverlog.info(
|
||||
"client with devid {} attempting login".format(user_devid)
|
||||
f"client with devid {user_devid} attempting login"
|
||||
)
|
||||
if bumper.use_auth:
|
||||
if (
|
||||
|
|
@ -417,7 +417,7 @@ class ConfServer:
|
|||
)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
async def handle_lookup(self, request):
|
||||
try:
|
||||
|
|
@ -464,7 +464,7 @@ class ConfServer:
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
async def handle_newauth(self, request):
|
||||
# Bumper is only returning the submitted token. No reason yet to create another new token
|
||||
|
|
@ -485,7 +485,7 @@ class ConfServer:
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
async def disconnect(self):
|
||||
try:
|
||||
|
|
@ -493,7 +493,7 @@ class ConfServer:
|
|||
await self.app.shutdown()
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
class ConfServer_GeneralFunctions:
|
||||
def __init__(self):
|
||||
|
|
@ -514,16 +514,16 @@ class ConfServer:
|
|||
return tmpaccesstoken
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
def generate_authcode(self, user, countrycode, token):
|
||||
try:
|
||||
tmpauthcode = "{}_{}".format(countrycode, uuid.uuid4().hex)
|
||||
tmpauthcode = f"{countrycode}_{uuid.uuid4().hex}"
|
||||
bumper.user_add_authcode(user["userid"], token, tmpauthcode)
|
||||
return tmpauthcode
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
|
||||
async def login(self, request):
|
||||
|
|
@ -532,7 +532,7 @@ class ConfServer:
|
|||
countrycode = request.match_info.get("country", "us")
|
||||
apptype = request.match_info.get("apptype", "")
|
||||
confserverlog.info(
|
||||
"client with devid {} attempting login".format(user_devid)
|
||||
f"client with devid {user_devid} attempting login"
|
||||
)
|
||||
if bumper.use_auth:
|
||||
if (
|
||||
|
|
@ -595,7 +595,7 @@ class ConfServer:
|
|||
)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
|
||||
async def get_AuthCode(self, request):
|
||||
|
|
@ -660,7 +660,7 @@ class ConfServer:
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
def check_token(self, apptype, countrycode, user, token):
|
||||
try:
|
||||
|
|
@ -705,7 +705,7 @@ class ConfServer:
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
def _auth_any(self, devid, apptype, country, request):
|
||||
try:
|
||||
|
|
@ -752,7 +752,7 @@ class ConfServer:
|
|||
if "did" in bot:
|
||||
bumper.user_add_bot(tmpuser["userid"], bot["did"])
|
||||
else:
|
||||
confserverlog.error("No DID for bot: {}".format(bot))
|
||||
confserverlog.error(f"No DID for bot: {bot}")
|
||||
|
||||
if "checkLogin" in request.path: # If request was to check a token do so
|
||||
checkToken = self.check_token(
|
||||
|
|
@ -782,7 +782,7 @@ class ConfServer:
|
|||
return body
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
|
||||
def getUserAccountInfo(self, request):
|
||||
|
|
@ -851,7 +851,7 @@ class ConfServer:
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
|
||||
async def logout(self, request):
|
||||
try:
|
||||
|
|
@ -875,4 +875,4 @@ class ConfServer:
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
confserverlog.exception("{}".format(e))
|
||||
confserverlog.exception(f"{e}")
|
||||
30
bumper/db.py
30
bumper/db.py
|
|
@ -44,7 +44,7 @@ def user_add(userid):
|
|||
|
||||
user = user_get(userid)
|
||||
if not user:
|
||||
bumperlog.info("Adding new user with userid: {}".format(newuser.userid))
|
||||
bumperlog.info(f"Adding new user with userid: {newuser.userid}")
|
||||
user_full_upsert(newuser.asdict())
|
||||
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ def user_remove_bot(userid, did):
|
|||
|
||||
def user_get_tokens(userid):
|
||||
tokens = db_get().table("tokens")
|
||||
return tokens.search((Query().userid == userid))
|
||||
return tokens.search(Query().userid == userid)
|
||||
|
||||
|
||||
def user_get_token(userid, token):
|
||||
|
|
@ -136,7 +136,7 @@ def user_add_token(userid, token):
|
|||
tokens = opendb.table("tokens")
|
||||
tmptoken = tokens.get((Query().userid == userid) & (Query().token == token))
|
||||
if not tmptoken:
|
||||
bumperlog.debug("Adding token {} for userid {}".format(token, userid))
|
||||
bumperlog.debug(f"Adding token {token} for userid {userid}")
|
||||
tokens.insert(
|
||||
{
|
||||
"userid": userid,
|
||||
|
|
@ -214,7 +214,7 @@ def revoke_expired_oauths():
|
|||
oauth = OAuth(**i)
|
||||
if datetime.now() >= datetime.fromisoformat(oauth.expire_at):
|
||||
bumperlog.debug(
|
||||
"Removing oauth {} due to expiration".format(oauth.access_token)
|
||||
f"Removing oauth {oauth.access_token} due to expiration"
|
||||
)
|
||||
table.remove(doc_ids=[i.doc_id])
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ def user_revoke_expired_oauths(userid):
|
|||
oauth = OAuth(**i)
|
||||
if datetime.now() >= datetime.fromisoformat(oauth.expire_at):
|
||||
bumperlog.debug(
|
||||
"Removing oauth {} due to expiration".format(oauth.access_token)
|
||||
f"Removing oauth {oauth.access_token} due to expiration"
|
||||
)
|
||||
table.remove(doc_ids=[i.doc_id])
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ def user_add_oauth(userid) -> OAuth:
|
|||
return OAuth(**entry)
|
||||
else:
|
||||
oauth = OAuth.create_new(userid)
|
||||
bumperlog.debug("Adding oauth {} for userid {}".format(oauth.access_token, userid))
|
||||
bumperlog.debug(f"Adding oauth {oauth.access_token} for userid {userid}")
|
||||
table.insert(oauth.toDB())
|
||||
return oauth
|
||||
|
||||
|
|
@ -260,13 +260,13 @@ def get_disconnected_xmpp_clients():
|
|||
|
||||
|
||||
def check_authcode(uid, authcode):
|
||||
bumperlog.debug("Checking for authcode: {}".format(authcode))
|
||||
bumperlog.debug(f"Checking for authcode: {authcode}")
|
||||
tokens = db_get().table("tokens")
|
||||
tmpauth = tokens.get(
|
||||
(Query().authcode == authcode)
|
||||
& ( # Match authcode
|
||||
(Query().userid == uid.replace("fuid_", ""))
|
||||
| (Query().userid == "fuid_{}".format(uid))
|
||||
| (Query().userid == f"fuid_{uid}")
|
||||
) # Userid with or without fuid_
|
||||
)
|
||||
if tmpauth:
|
||||
|
|
@ -276,10 +276,10 @@ def check_authcode(uid, authcode):
|
|||
|
||||
|
||||
def loginByItToken(authcode):
|
||||
bumperlog.debug("Checking for authcode: {}".format(authcode))
|
||||
bumperlog.debug(f"Checking for authcode: {authcode}")
|
||||
tokens = db_get().table("tokens")
|
||||
tmpauth = tokens.get(
|
||||
(Query().authcode == authcode)
|
||||
Query().authcode == authcode
|
||||
# & ( # Match authcode
|
||||
# (Query().userid == uid.replace("fuid_", ""))
|
||||
# | (Query().userid == "fuid_{}".format(uid))
|
||||
|
|
@ -292,13 +292,13 @@ def loginByItToken(authcode):
|
|||
|
||||
|
||||
def check_token(uid, token):
|
||||
bumperlog.debug("Checking for token: {}".format(token))
|
||||
bumperlog.debug(f"Checking for token: {token}")
|
||||
tokens = db_get().table("tokens")
|
||||
tmpauth = tokens.get(
|
||||
(Query().token == token)
|
||||
& ( # Match token
|
||||
(Query().userid == uid.replace("fuid_", ""))
|
||||
| (Query().userid == "fuid_{}".format(uid))
|
||||
| (Query().userid == f"fuid_{uid}")
|
||||
) # Userid with or without fuid_
|
||||
)
|
||||
if tmpauth:
|
||||
|
|
@ -329,7 +329,7 @@ def bot_add(sn, did, devclass, resource, company):
|
|||
not devclass == "" or "@" not in sn or "tmp" not in sn
|
||||
): # try to prevent bad additions to the bot list
|
||||
bumperlog.info(
|
||||
"Adding new bot with SN: {} DID: {}".format(newbot.name, newbot.did)
|
||||
f"Adding new bot with SN: {newbot.name} DID: {newbot.did}"
|
||||
)
|
||||
bot_full_upsert(newbot.asdict())
|
||||
|
||||
|
|
@ -379,7 +379,7 @@ def bot_full_upsert(vacbot):
|
|||
if "did" in vacbot:
|
||||
bots.upsert(vacbot, Bot.did == vacbot["did"])
|
||||
else:
|
||||
bumperlog.error("No DID in vacbot: {}".format(vacbot))
|
||||
bumperlog.error(f"No DID in vacbot: {vacbot}")
|
||||
|
||||
|
||||
def bot_set_nick(did, nick):
|
||||
|
|
@ -408,7 +408,7 @@ def client_add(userid, realm, resource):
|
|||
|
||||
client = client_get(resource)
|
||||
if not client:
|
||||
bumperlog.info("Adding new client with resource {}".format(newclient.resource))
|
||||
bumperlog.info(f"Adding new client with resource {newclient.resource}")
|
||||
client_full_upsert(newclient.asdict())
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ from datetime import datetime, timedelta
|
|||
import bumper
|
||||
|
||||
|
||||
class VacBotDevice(object):
|
||||
class VacBotDevice:
|
||||
def __init__(
|
||||
self, did="", vac_bot_device_class="", resource="", name="", nick="", company=""
|
||||
):
|
||||
|
|
@ -32,7 +32,7 @@ class VacBotDevice(object):
|
|||
}
|
||||
|
||||
|
||||
class BumperUser(object):
|
||||
class BumperUser:
|
||||
def __init__(self, userid=""):
|
||||
self.userid = userid
|
||||
self.devices = []
|
||||
|
|
@ -50,7 +50,7 @@ class GlobalVacBotDevice(VacBotDevice): # EcoVacs Home
|
|||
deviceName = ""
|
||||
|
||||
|
||||
class VacBotClient(object):
|
||||
class VacBotClient:
|
||||
def __init__(self, userid="", realm="", token=""):
|
||||
self.userid = userid
|
||||
self.realm = realm
|
||||
|
|
@ -101,7 +101,7 @@ class OAuth:
|
|||
oauth = OAuth()
|
||||
oauth.userId = userId
|
||||
oauth.access_token = uuid.uuid4().hex
|
||||
oauth.expire_at = "{}".format(datetime.utcnow() + timedelta(days=bumper.oauth_validity_days))
|
||||
oauth.expire_at = f"{datetime.utcnow() + timedelta(days=bumper.oauth_validity_days)}"
|
||||
oauth.refresh_token = uuid.uuid4().hex
|
||||
return oauth
|
||||
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ class MQTTHelperBot:
|
|||
]
|
||||
)
|
||||
except Exception as e:
|
||||
helperbotlog.exception("{}".format(e))
|
||||
helperbotlog.exception(f"{e}")
|
||||
|
||||
async def _wait_for_resp(self, command_dto: CommandDto, request_id: str):
|
||||
try:
|
||||
|
|
@ -85,7 +85,7 @@ class MQTTHelperBot:
|
|||
except asyncio.CancelledError as e:
|
||||
helperbotlog.debug("wait_for_resp cancelled by asyncio", e, exc_info=True)
|
||||
except Exception as e:
|
||||
helperbotlog.exception("{}".format(e))
|
||||
helperbotlog.exception(f"{e}")
|
||||
|
||||
return {
|
||||
"id": request_id,
|
||||
|
|
@ -118,7 +118,7 @@ class MQTTHelperBot:
|
|||
resp = await self._wait_for_resp(command_dto, requestid)
|
||||
return resp
|
||||
except Exception as e:
|
||||
helperbotlog.exception("{}".format(e))
|
||||
helperbotlog.exception(f"{e}")
|
||||
return {
|
||||
"id": requestid,
|
||||
"errno": 500,
|
||||
|
|
@ -185,7 +185,7 @@ class MQTTServer:
|
|||
self.broker = hbmqtt.broker.Broker(config=self.default_config)
|
||||
|
||||
except Exception as e:
|
||||
mqttserverlog.exception("{}".format(e))
|
||||
mqttserverlog.exception(f"{e}")
|
||||
|
||||
async def broker_coro(self):
|
||||
mqttserverlog.info(f"Starting MQTT Server at {self._host}:{self._port}")
|
||||
|
|
@ -199,7 +199,7 @@ class MQTTServer:
|
|||
pass
|
||||
|
||||
except Exception as e:
|
||||
mqttserverlog.exception("{}".format(e))
|
||||
mqttserverlog.exception(f"{e}")
|
||||
# asyncio.create_task(bumper.shutdown())
|
||||
pass
|
||||
|
||||
|
|
@ -217,7 +217,7 @@ class BumperMQTTServer_Plugin:
|
|||
"'bumper' section not found in context configuration"
|
||||
)
|
||||
except Exception as e:
|
||||
mqttserverlog.exception("{}".format(e))
|
||||
mqttserverlog.exception(f"{e}")
|
||||
|
||||
async def authenticate(self, *args, **kwargs):
|
||||
authenticated = False
|
||||
|
|
|
|||
|
|
@ -149,7 +149,7 @@ class portal_api_appsvr(plugins.ConfServerApp):
|
|||
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
# Return fail for GET
|
||||
body = {"result": "fail", "todo": "result"}
|
||||
|
|
@ -189,7 +189,7 @@ class portal_api_appsvr(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_appsvr_oauth_callback(self, request):
|
||||
try:
|
||||
|
|
@ -205,7 +205,7 @@ class portal_api_appsvr(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
plugin = portal_api_appsvr()
|
||||
|
|
|
|||
|
|
@ -42,8 +42,8 @@ class portal_api_dim(plugins.ConfServerApp):
|
|||
json_body, randomid
|
||||
)
|
||||
body = retcmd
|
||||
logging.debug("Send Bot - {}".format(json_body))
|
||||
logging.debug("Bot Response - {}".format(body))
|
||||
logging.debug(f"Send Bot - {json_body}")
|
||||
logging.debug(f"Bot Response - {body}")
|
||||
return web.json_response(body)
|
||||
else:
|
||||
# No response, send error back
|
||||
|
|
@ -70,7 +70,7 @@ class portal_api_dim(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = portal_api_dim()
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ class portal_api_ecms(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
plugin = portal_api_ecms()
|
||||
|
|
|
|||
|
|
@ -41,8 +41,8 @@ class portal_api_iot(plugins.ConfServerApp):
|
|||
json_body, randomid
|
||||
)
|
||||
body = retcmd
|
||||
logging.debug("Send Bot - {}".format(json_body))
|
||||
logging.debug("Bot Response - {}".format(body))
|
||||
logging.debug(f"Send Bot - {json_body}")
|
||||
logging.debug(f"Bot Response - {body}")
|
||||
return web.json_response(body)
|
||||
else:
|
||||
# No response, send error back
|
||||
|
|
@ -75,7 +75,7 @@ class portal_api_iot(plugins.ConfServerApp):
|
|||
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = portal_api_iot()
|
||||
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ class portal_api_lg(plugins.ConfServerApp):
|
|||
json_body, randomid
|
||||
)
|
||||
body = retcmd
|
||||
logging.debug("Send Bot - {}".format(json_body))
|
||||
logging.debug("Bot Response - {}".format(body))
|
||||
logging.debug(f"Send Bot - {json_body}")
|
||||
logging.debug(f"Bot Response - {body}")
|
||||
logs = []
|
||||
logsroot = ET.fromstring(retcmd["resp"])
|
||||
if logsroot.attrib["ret"] == "ok":
|
||||
|
|
@ -88,7 +88,7 @@ class portal_api_lg(plugins.ConfServerApp):
|
|||
else:
|
||||
body = {"ret": "ok", "logs": []}
|
||||
|
||||
logging.debug("lg logs return: {}".format(json.dumps(body)))
|
||||
logging.debug(f"lg logs return: {json.dumps(body)}")
|
||||
return web.json_response(body)
|
||||
else:
|
||||
# No response, send error back
|
||||
|
|
@ -99,7 +99,7 @@ class portal_api_lg(plugins.ConfServerApp):
|
|||
)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
body = {"id": randomid, "errno": bumper.ERR_COMMON, "ret": "fail"}
|
||||
return web.json_response(body)
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class portal_api_neng(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_neng_getShareMsgs(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -65,7 +65,7 @@ class portal_api_neng(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_neng_getlist(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -91,7 +91,7 @@ class portal_api_neng(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = portal_api_neng()
|
||||
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ class portal_api_pim(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_pimFile(self, request):
|
||||
try:
|
||||
|
|
@ -44,7 +44,7 @@ class portal_api_pim(plugins.ConfServerApp):
|
|||
return web.FileResponse(os.path.join(bumper.bumper_dir, "bumper", "web", "images", "robotvac_image.jpg"))
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getConfignetAll(self, request):
|
||||
try:
|
||||
|
|
@ -52,7 +52,7 @@ class portal_api_pim(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getConfigGroups(self, request):
|
||||
try:
|
||||
|
|
@ -60,7 +60,7 @@ class portal_api_pim(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getErrDetail(self, request):
|
||||
try:
|
||||
|
|
@ -72,7 +72,7 @@ class portal_api_pim(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_product_config_batch(self, request):
|
||||
try:
|
||||
|
|
@ -99,7 +99,7 @@ class portal_api_pim(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
plugin = portal_api_pim()
|
||||
|
|
|
|||
|
|
@ -34,6 +34,6 @@ class api_rapp(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = api_rapp()
|
||||
|
|
|
|||
|
|
@ -110,7 +110,7 @@ class portal_api_users(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
# Return fail for GET
|
||||
body = {"result": "fail", "todo": "result"}
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ class upload_global(plugins.ConfServerApp):
|
|||
return web.FileResponse(os.path.join(bumper.bumper_dir,"bumper","web","images","robotvac_image.jpg"))
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ class v1_private_ad(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getBootScreen(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -52,7 +52,7 @@ class v1_private_ad(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = v1_private_ad()
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class v1_private_campaign(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
plugin = v1_private_campaign()
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_checkAPPVersion(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -73,7 +73,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_uploadDeviceInfo(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -88,7 +88,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getSystemReminder(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -110,7 +110,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getConfig(self, request):
|
||||
try:
|
||||
|
|
@ -132,7 +132,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getAreas(self, request):
|
||||
try:
|
||||
|
|
@ -147,7 +147,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getAgreementURLBatch(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -179,7 +179,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getTimestamp(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -197,7 +197,7 @@ class v1_private_common(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
plugin = v1_private_common()
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class v1_private_message(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getMsgList(self, request): # EcoVacs Home
|
||||
try:
|
||||
|
|
@ -53,7 +53,7 @@ class v1_private_message(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = v1_private_message()
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class v1_private_shop(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = v1_private_shop()
|
||||
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class v1_private_user(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_getUserMenuInfo(self, request):
|
||||
try:
|
||||
|
|
@ -145,7 +145,7 @@ class v1_private_user(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_changeArea(self, request):
|
||||
try:
|
||||
|
|
@ -162,7 +162,7 @@ class v1_private_user(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
async def handle_acceptAgreementBatch(self, request):
|
||||
try:
|
||||
|
|
@ -177,7 +177,7 @@ class v1_private_user(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
plugin = v1_private_user()
|
||||
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class v1_private_userSetting(plugins.ConfServerApp):
|
|||
return web.json_response(body)
|
||||
|
||||
except Exception as e:
|
||||
logging.exception("{}".format(e))
|
||||
logging.exception(f"{e}")
|
||||
|
||||
|
||||
plugin = v1_private_userSetting()
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class XMPPServer:
|
|||
async def start_async_server(self):
|
||||
try:
|
||||
xmppserverlog.info(
|
||||
"Starting XMPP Server at {}:{}".format(self.address[0], self.address[1])
|
||||
f"Starting XMPP Server at {self.address[0]}:{self.address[1]}"
|
||||
)
|
||||
|
||||
loop = asyncio.get_running_loop()
|
||||
|
|
@ -49,7 +49,7 @@ class XMPPServer:
|
|||
pass
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
asyncio.create_task(bumper.shutdown())
|
||||
|
||||
def disconnect(self):
|
||||
|
|
@ -71,7 +71,7 @@ class XMPPServer_Protocol(asyncio.Protocol):
|
|||
def connection_made(self, transport):
|
||||
if self.aclient: # Existing client... upgrading to TLS
|
||||
xmppserverlog.debug(
|
||||
"Upgraded connection for {}".format(self.aclient.address)
|
||||
f"Upgraded connection for {self.aclient.address}"
|
||||
)
|
||||
self.aclient.transport = transport
|
||||
else:
|
||||
|
|
@ -79,7 +79,7 @@ class XMPPServer_Protocol(asyncio.Protocol):
|
|||
self.aclient = aclient
|
||||
XMPPServer.clients.append(aclient)
|
||||
self.aclient.state = getattr(aclient, "CONNECT")
|
||||
xmppserverlog.debug("New Connection from {}".format(aclient.address))
|
||||
xmppserverlog.debug(f"New Connection from {aclient.address}")
|
||||
|
||||
def connection_lost(self, error):
|
||||
XMPPServer.clients.remove(self.aclient)
|
||||
|
|
@ -119,7 +119,7 @@ class XMPPAsyncClient:
|
|||
self.uid = ""
|
||||
self.log_sent_message = True # Set to true to log sends
|
||||
self.log_incoming_data = True # Set to true to log sends
|
||||
xmppserverlog.debug("new client with ip {}".format(self.address))
|
||||
xmppserverlog.debug(f"new client with ip {self.address}")
|
||||
|
||||
def send(self, command):
|
||||
try:
|
||||
|
|
@ -133,7 +133,7 @@ class XMPPAsyncClient:
|
|||
self.transport.write(command.encode())
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
def _disconnect(self):
|
||||
try:
|
||||
|
|
@ -149,7 +149,7 @@ class XMPPAsyncClient:
|
|||
self.transport.close()
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.error("{}".format(e))
|
||||
xmppserverlog.error(f"{e}")
|
||||
|
||||
def _tag_strip_uri(self, tag):
|
||||
try:
|
||||
|
|
@ -158,7 +158,7 @@ class XMPPAsyncClient:
|
|||
return tag
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.error("{}".format(e))
|
||||
xmppserverlog.error(f"{e}")
|
||||
|
||||
def _set_state(self, state):
|
||||
try:
|
||||
|
|
@ -182,7 +182,7 @@ class XMPPAsyncClient:
|
|||
self._disconnect()
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.error("{}".format(e))
|
||||
xmppserverlog.error(f"{e}")
|
||||
|
||||
def _handle_ctl(self, xml, data):
|
||||
try:
|
||||
|
|
@ -244,7 +244,7 @@ class XMPPAsyncClient:
|
|||
):
|
||||
ctl_to = xml.get("to")
|
||||
if not "from" in xml.attrib:
|
||||
xml.attrib["from"] = "{}".format(self.bumper_jid)
|
||||
xml.attrib["from"] = f"{self.bumper_jid}"
|
||||
rxmlstring = ET.tostring(xml).decode("utf-8")
|
||||
# clean up string to remove namespaces added by ET
|
||||
rxmlstring = rxmlstring.replace("xmlns:ns0=", "xmlns=")
|
||||
|
|
@ -255,12 +255,12 @@ class XMPPAsyncClient:
|
|||
if client.type == self.BOT:
|
||||
if client.uid.lower() in ctl_to.lower():
|
||||
xmppserverlog.debug(
|
||||
"Sending ctl to bot: {}".format(rxmlstring)
|
||||
f"Sending ctl to bot: {rxmlstring}"
|
||||
)
|
||||
client.send(rxmlstring)
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.error("{}".format(e))
|
||||
xmppserverlog.error(f"{e}")
|
||||
|
||||
def _handle_ping(self, xml, data):
|
||||
try:
|
||||
|
|
@ -276,7 +276,7 @@ class XMPPAsyncClient:
|
|||
pingto = xml.get("to")
|
||||
pingfrom = self.bumper_jid
|
||||
if not "from" in xml.attrib:
|
||||
xml.attrib["from"] = "{}".format(pingfrom)
|
||||
xml.attrib["from"] = f"{pingfrom}"
|
||||
pingstring = ET.tostring(xml).decode("utf-8")
|
||||
# clean up string to remove namespaces added by ET
|
||||
pingstring = pingstring.replace("xmlns:ns0=", "xmlns=")
|
||||
|
|
@ -293,7 +293,7 @@ class XMPPAsyncClient:
|
|||
client.send(pingstring)
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
async def schedule_ping(self, time):
|
||||
if not self.state == 5: # disconnected
|
||||
|
|
@ -308,7 +308,7 @@ class XMPPAsyncClient:
|
|||
try:
|
||||
ctl_to = xml.get("to")
|
||||
if not "from" in xml.attrib:
|
||||
xml.attrib["from"] = "{}".format(self.bumper_jid)
|
||||
xml.attrib["from"] = f"{self.bumper_jid}"
|
||||
if "errno" in data:
|
||||
xmppserverlog.error(f"Error from bot - {data}")
|
||||
if (
|
||||
|
|
@ -336,14 +336,14 @@ class XMPPAsyncClient:
|
|||
adduser = '<iq type="set" id="{}" from="{}" to="{}"><query xmlns="com:ctl"><ctl td="AddUser" id="0000" jid="{}" /></query></iq>'.format(
|
||||
uuid.uuid4(), adminuser, self.bumper_jid, newuser
|
||||
)
|
||||
xmppserverlog.debug("Adding User to bot - {}".format(adduser))
|
||||
xmppserverlog.debug(f"Adding User to bot - {adduser}")
|
||||
self.send(adduser)
|
||||
|
||||
# Add user ACs - Manage users, settings, and clean (full access)
|
||||
adduseracs = '<iq type="set" id="{}" from="{}" to="{}"><query xmlns="com:ctl"><ctl td="SetAC" id="1111" jid="{}"><acs><ac name="userman" allow="1"/><ac name="setting" allow="1"/><ac name="clean" allow="1"/></acs></ctl></query></iq>'.format(
|
||||
uuid.uuid4(), adminuser, self.bumper_jid, newuser
|
||||
)
|
||||
xmppserverlog.debug("Add User ACs to bot - {}".format(adduseracs))
|
||||
xmppserverlog.debug(f"Add User ACs to bot - {adduseracs}")
|
||||
self.send(adduseracs)
|
||||
|
||||
# GetUserInfo - Just to confirm it set correctly
|
||||
|
|
@ -395,7 +395,7 @@ class XMPPAsyncClient:
|
|||
client.send(rxmlstring)
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
def _handle_connect(self, data, xml=None):
|
||||
try:
|
||||
|
|
@ -438,7 +438,7 @@ class XMPPAsyncClient:
|
|||
): # Handle SASL Auth
|
||||
self._handle_sasl_auth(xml)
|
||||
else:
|
||||
xmppserverlog.error("Couldn't handle: {}".format(xml))
|
||||
xmppserverlog.error(f"Couldn't handle: {xml}")
|
||||
|
||||
elif self.state == self.INIT:
|
||||
if xml == None:
|
||||
|
|
@ -465,10 +465,10 @@ class XMPPAsyncClient:
|
|||
if child == "bind":
|
||||
self._handle_bind(xml)
|
||||
else:
|
||||
xmppserverlog.error("Couldn't handle: {}".format(xml))
|
||||
xmppserverlog.error(f"Couldn't handle: {xml}")
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
async def _handle_starttls(self, data):
|
||||
try:
|
||||
|
|
@ -500,7 +500,7 @@ class XMPPAsyncClient:
|
|||
protocol.connection_made(new_transport)
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
def _handle_sasl_auth(self, xml):
|
||||
try:
|
||||
|
|
@ -523,7 +523,7 @@ class XMPPAsyncClient:
|
|||
if self.devclass: # if there is a devclass it is a bot
|
||||
bumper.bot_add(self.uid, self.uid, self.devclass, "atom", "eco-legacy")
|
||||
self.type = self.BOT
|
||||
xmppserverlog.info("bot authenticated SN: {}".format(self.uid))
|
||||
xmppserverlog.info(f"bot authenticated SN: {self.uid}")
|
||||
# Send response
|
||||
self.send(
|
||||
'<success xmlns="urn:ietf:params:xml:ns:xmpp-sasl"/>'
|
||||
|
|
@ -542,7 +542,7 @@ class XMPPAsyncClient:
|
|||
if auth:
|
||||
self.type = self.CONTROLLER
|
||||
bumper.client_add(self.uid, "bumper", self.clientresource)
|
||||
xmppserverlog.info("client authenticated {}".format(self.uid))
|
||||
xmppserverlog.info(f"client authenticated {self.uid}")
|
||||
|
||||
# Client authenticated, move to next state
|
||||
self._set_state("INIT")
|
||||
|
|
@ -559,7 +559,7 @@ class XMPPAsyncClient:
|
|||
) # Fail
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
def _handle_bind(self, xml):
|
||||
try:
|
||||
|
|
@ -575,7 +575,7 @@ class XMPPAsyncClient:
|
|||
clientbindxml = xml.getchildren()
|
||||
clientresourcexml = clientbindxml[0].getchildren()
|
||||
if self.devclass: # its a bot
|
||||
self.name = "XMPP_Client_{}_{}".format(self.uid, self.devclass)
|
||||
self.name = f"XMPP_Client_{self.uid}_{self.devclass}"
|
||||
self.bumper_jid = "{}@{}.ecorobot.net/atom".format(
|
||||
self.uid, self.devclass
|
||||
)
|
||||
|
|
@ -589,7 +589,7 @@ class XMPPAsyncClient:
|
|||
)
|
||||
elif len(clientresourcexml) > 0:
|
||||
self.clientresource = clientresourcexml[0].text
|
||||
self.name = "XMPP_Client_{}".format(self.clientresource)
|
||||
self.name = f"XMPP_Client_{self.clientresource}"
|
||||
self.bumper_jid = "{}@{}/{}".format(
|
||||
self.uid, XMPPServer.server_id, self.clientresource
|
||||
)
|
||||
|
|
@ -602,8 +602,8 @@ class XMPPAsyncClient:
|
|||
xml.get("id"), self.bumper_jid
|
||||
)
|
||||
else:
|
||||
self.name = "XMPP_Client_{}_{}".format(self.uid, self.address)
|
||||
self.bumper_jid = "{}@{}".format(self.uid, XMPPServer.server_id)
|
||||
self.name = f"XMPP_Client_{self.uid}_{self.address}"
|
||||
self.bumper_jid = f"{self.uid}@{XMPPServer.server_id}"
|
||||
xmppserverlog.debug(
|
||||
"new client ({}:{} | {})".format(
|
||||
self.address[0], self.address[1], self.bumper_jid
|
||||
|
|
@ -617,7 +617,7 @@ class XMPPAsyncClient:
|
|||
self.send(res)
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
def _handle_session(self, xml):
|
||||
res = '<iq type="result" id="{}" />'.format(xml.get("id"))
|
||||
|
|
@ -636,7 +636,7 @@ class XMPPAsyncClient:
|
|||
# Most likely a bot, possibly hello world in text
|
||||
|
||||
# Send dummy return
|
||||
self.send('<presence to="{}"> dummy </presence>'.format(self.bumper_jid))
|
||||
self.send(f'<presence to="{self.bumper_jid}"> dummy </presence>')
|
||||
|
||||
# If it is a BOT, send extras
|
||||
if self.type == self.BOT:
|
||||
|
|
@ -663,7 +663,7 @@ class XMPPAsyncClient:
|
|||
|
||||
# Send dummy return
|
||||
self.send(
|
||||
'<presence to="{}"> dummy </presence>'.format(self.bumper_jid)
|
||||
f'<presence to="{self.bumper_jid}"> dummy </presence>'
|
||||
)
|
||||
elif xml.get("type") == "unavailable":
|
||||
xmppserverlog.debug(
|
||||
|
|
@ -682,7 +682,7 @@ class XMPPAsyncClient:
|
|||
)
|
||||
# Send dummy return
|
||||
self.send(
|
||||
'<presence to="{}"> dummy </presence>'.format(self.bumper_jid)
|
||||
f'<presence to="{self.bumper_jid}"> dummy </presence>'
|
||||
)
|
||||
|
||||
def _parse_data(self, data):
|
||||
|
|
@ -769,13 +769,13 @@ class XMPPAsyncClient:
|
|||
else:
|
||||
if not (newdata == "" or newdata == " "):
|
||||
xmppserverlog.error(
|
||||
"xml parse error - {} - {}".format(newdata, e)
|
||||
f"xml parse error - {newdata} - {e}"
|
||||
)
|
||||
|
||||
elif "not well-formed (invalid token)" in e.msg:
|
||||
# If a lone </stream:stream> - client is signalling end of session/disconnect
|
||||
if not "</stream:stream>" in newdata:
|
||||
xmppserverlog.error("xml parse error - {} - {}".format(newdata, e))
|
||||
xmppserverlog.error(f"xml parse error - {newdata} - {e}")
|
||||
else:
|
||||
self.send("</stream:stream>") # Close stream
|
||||
|
||||
|
|
@ -783,20 +783,20 @@ class XMPPAsyncClient:
|
|||
if "<stream:stream" in newdata: # Handle start stream and connect
|
||||
if self.state == self.CONNECT or self.state == self.INIT:
|
||||
xmppserverlog.debug(
|
||||
"Handling connect data - {}".format(newdata)
|
||||
f"Handling connect data - {newdata}"
|
||||
)
|
||||
self._handle_connect(newdata.encode("utf-8"))
|
||||
else:
|
||||
if not "</stream:stream>" in newdata:
|
||||
xmppserverlog.error(
|
||||
"xml parse error - {} - {}".format(newdata, e)
|
||||
f"xml parse error - {newdata} - {e}"
|
||||
)
|
||||
else:
|
||||
self.send("</stream:stream>") # Close stream
|
||||
self._set_state("DISCONNECT")
|
||||
|
||||
except Exception as e:
|
||||
xmppserverlog.exception("{}".format(e))
|
||||
xmppserverlog.exception(f"{e}")
|
||||
|
||||
def _handle_iq(self, xml, data):
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import mock
|
||||
from unittest import mock
|
||||
import bumper
|
||||
import asyncio
|
||||
import pytest
|
||||
|
|
|
|||
|
|
@ -79,7 +79,7 @@ def test_user_db():
|
|||
{
|
||||
"userid": "testuser",
|
||||
"token": "token_1234",
|
||||
"expiration": "{}".format(datetime.now() + timedelta(seconds=-10)),
|
||||
"expiration": f"{datetime.now() + timedelta(seconds=-10)}",
|
||||
}
|
||||
) # Add expired token
|
||||
db.close()
|
||||
|
|
@ -93,7 +93,7 @@ def test_user_db():
|
|||
{
|
||||
"userid": "testuser",
|
||||
"token": "token_1234",
|
||||
"expiration": "{}".format(datetime.now() + timedelta(seconds=-10)),
|
||||
"expiration": f"{datetime.now() + timedelta(seconds=-10)}",
|
||||
}
|
||||
) # Add expired token
|
||||
db.close()
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
import mock
|
||||
from mock import patch
|
||||
from unittest import mock
|
||||
from unittest.mock import patch
|
||||
import pytest
|
||||
from tinydb.storages import MemoryStorage
|
||||
from tinydb import TinyDB, Query
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import mock
|
||||
from unittest import mock
|
||||
import bumper
|
||||
import asyncio
|
||||
import pytest
|
||||
|
|
@ -398,7 +398,7 @@ async def test_mqttserver():
|
|||
)
|
||||
|
||||
await test_client.Client.connect(
|
||||
"mqtts://{}:{}/".format(test_client.address[0], test_client.address[1]),
|
||||
f"mqtts://{test_client.address[0]}:{test_client.address[1]}/",
|
||||
cafile=bumper.ca_cert,
|
||||
)
|
||||
assert (
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
import mock
|
||||
from unittest import mock
|
||||
import bumper
|
||||
import asyncio
|
||||
import pytest
|
||||
|
|
@ -66,9 +66,7 @@ async def test_client_connect_no_starttls(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Send connect stream from "client"
|
||||
test_data = "<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -88,9 +86,7 @@ async def test_client_connect_no_starttls(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Client sendss auth - Ignoring the starttls, we don't force this with bumper
|
||||
test_data = '<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AGZ1aWRfdG1wdXNlcgAwL0lPU0Y1M0QwN0JBL3VzXzg5ODgwMmZkYmM0NDQxYjBiYzgxNWIxZDFjNjgzMDJl</auth>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AGZ1aWRfdG1wdXNlcgAwL0lPU0Y1M0QwN0JBL3VzXzg5ODgwMmZkYmM0NDQxYjBiYzgxNWIxZDFjNjgzMDJl</auth>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -109,7 +105,7 @@ async def test_client_end_stream(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Send end stream from "client"
|
||||
test_data = "</stream:stream>".encode("utf-8")
|
||||
test_data = b"</stream:stream>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -121,14 +117,14 @@ async def test_client_end_stream(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send abnormal stream from "client"
|
||||
test_data = "<badstr />".encode("utf-8")
|
||||
test_data = b"<badstr />"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Reset mock calls
|
||||
mock_send.reset_mock()
|
||||
|
||||
# Send blank from "client"
|
||||
test_data = "".encode("utf-8")
|
||||
test_data = b""
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
|
||||
|
|
@ -141,9 +137,7 @@ async def test_client_connect_starttls_called(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Send connect stream from "client"
|
||||
test_data = "<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -165,7 +159,7 @@ async def test_client_connect_starttls_called(*args, **kwargs):
|
|||
mock_tls = xmppclient._handle_starttls = mock.Mock()
|
||||
|
||||
# Send start tls from "client"
|
||||
test_data = "<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>".encode("utf-8")
|
||||
test_data = b"<starttls xmlns='urn:ietf:params:xml:ns:xmpp-tls'/>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# After upgrading connection, server tells client to proceed with auth again
|
||||
|
|
@ -174,9 +168,7 @@ async def test_client_connect_starttls_called(*args, **kwargs):
|
|||
|
||||
# After TLS is upgraded, Client establishes session again and will auth this time
|
||||
# Send connect stream from "client"
|
||||
test_data = "<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -195,9 +187,7 @@ async def test_client_connect_starttls_called(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Client sends auth
|
||||
test_data = '<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AGZ1aWRfdG1wdXNlcgAwL0lPU0Y1M0QwN0JBL3VzXzg5ODgwMmZkYmM0NDQxYjBiYzgxNWIxZDFjNjgzMDJl</auth>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<auth xmlns="urn:ietf:params:xml:ns:xmpp-sasl" mechanism="PLAIN">AGZ1aWRfdG1wdXNlcgAwL0lPU0Y1M0QwN0JBL3VzXzg5ODgwMmZkYmM0NDQxYjBiYzgxNWIxZDFjNjgzMDJl</auth>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -277,9 +267,7 @@ async def test_client_init(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Send connect stream from "client"
|
||||
test_data = "<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<stream:stream xmlns='jabber:client' xmlns:stream='http://etherx.jabber.org/streams' version='1.0' to='ecouser.net'>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -299,9 +287,7 @@ async def test_client_init(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send bind from "client"
|
||||
test_data = '<iq type="set" id="5E9872D5-547E-49AF-AE51-9EFAA282F952"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>IOSF53D07BA</resource></bind></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq type="set" id="5E9872D5-547E-49AF-AE51-9EFAA282F952"><bind xmlns="urn:ietf:params:xml:ns:xmpp-bind"><resource>IOSF53D07BA</resource></bind></iq>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -314,9 +300,7 @@ async def test_client_init(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send set session from client
|
||||
test_data = '<iq type="set" id="FA1041E7-AA27-43DD-BAA3-64DE2DE56AA3"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq type="set" id="FA1041E7-AA27-43DD-BAA3-64DE2DE56AA3"><session xmlns="urn:ietf:params:xml:ns:xmpp-session"/></iq>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert xmppclient.state == xmppclient.READY # client moved to READY state
|
||||
|
|
@ -329,7 +313,7 @@ async def test_client_init(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send presense from client
|
||||
test_data = '<presence type="available"/>'.encode("utf-8")
|
||||
test_data = b'<presence type="available"/>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -347,9 +331,7 @@ async def test_bot_connect(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Send connect stream from "bot"
|
||||
test_data = "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='159.ecorobot.net' version='1.0'>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='159.ecorobot.net' version='1.0'>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -369,9 +351,7 @@ async def test_bot_connect(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send auth from "bot"
|
||||
test_data = "<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AEUwMDAwMDAwMDAwMDAwMDAxMjM0AGVuY3J5cHRlZF9wYXNz</auth>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<auth xmlns='urn:ietf:params:xml:ns:xmpp-sasl' mechanism='PLAIN'>AEUwMDAwMDAwMDAwMDAwMDAxMjM0AGVuY3J5cHRlZF9wYXNz</auth>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -394,9 +374,7 @@ async def test_bot_init(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Send connect stream from "bot"
|
||||
test_data = "<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='159.ecorobot.net' version='1.0'>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<stream:stream xmlns:stream='http://etherx.jabber.org/streams' xmlns='jabber:client' to='159.ecorobot.net' version='1.0'>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
# Expect 2 calls to send
|
||||
|
|
@ -416,9 +394,7 @@ async def test_bot_init(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send bind from "bot"
|
||||
test_data = "<iq type='set' id='2521'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>atom</resource></bind></iq>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq type='set' id='2521'><bind xmlns='urn:ietf:params:xml:ns:xmpp-bind'><resource>atom</resource></bind></iq>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -431,9 +407,7 @@ async def test_bot_init(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send set session from bot
|
||||
test_data = "<iq type='set' id='2522'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq type='set' id='2522'><session xmlns='urn:ietf:params:xml:ns:xmpp-session'/></iq>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert xmppclient.state == xmppclient.READY # Bot moved to READY state
|
||||
|
|
@ -445,9 +419,7 @@ async def test_bot_init(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Send presense from bot
|
||||
test_data = "<presence><status>hello world</status></presence><iq type='result' from='E0000000000000001234@159.ecorobot.net/atom' to='ecouser.net' id='s2c1'/>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<presence><status>hello world</status></presence><iq type='result' from='E0000000000000001234@159.ecorobot.net/atom' to='ecouser.net' id='s2c1'/>"
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -467,9 +439,7 @@ async def test_ping_server(*args, **kwargs):
|
|||
mock_send = xmppclient.send = mock.Mock(side_effect=return_send_data)
|
||||
|
||||
# Ping from bot
|
||||
test_data = '<iq xmlns:ns0="urn:xmpp:ping" from="E000BVTNX18700260382@159.ecorobot.net/atom" id="2542" to="159.ecorobot.net" type="get"><ping /></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq xmlns:ns0="urn:xmpp:ping" from="E000BVTNX18700260382@159.ecorobot.net/atom" id="2542" to="159.ecorobot.net" type="get"><ping /></iq>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -501,9 +471,7 @@ async def test_ping_client_to_client(*args, **kwargs):
|
|||
bumper.xmppserver.XMPPServer.clients.append(xmppclient2)
|
||||
|
||||
# Ping from user to bot
|
||||
test_data = '<iq id="104934615" to="fuid_tmpuser@ecouser.net/IOSF53D07BA" type="get"><ping xmlns="urn:xmpp:ping" /></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq id="104934615" to="fuid_tmpuser@ecouser.net/IOSF53D07BA" type="get"><ping xmlns="urn:xmpp:ping" /></iq>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -512,9 +480,7 @@ async def test_ping_client_to_client(*args, **kwargs):
|
|||
) # ping response
|
||||
|
||||
# Ping response from bot to user
|
||||
test_data = "<iq type='result' to='E0000000000000001234@159.ecorobot.net/atom' id='104934615'/>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq type='result' to='E0000000000000001234@159.ecorobot.net/atom' id='104934615'/>"
|
||||
xmppclient2._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -547,9 +513,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
bumper.xmppserver.XMPPServer.clients.append(xmppclient2)
|
||||
|
||||
# Roster IQ - Only seen from Android app so far
|
||||
test_data = '<iq id="EE0XQ-2" type="get"><query xmlns="jabber:iq:roster" ></query></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq id="EE0XQ-2" type="get"><query xmlns="jabber:iq:roster" ></query></iq>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -561,9 +525,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Bot Command
|
||||
test_data = '<iq id="7" to="E0000000000000001234@159.ecorobot.net/atom" type="set"><query xmlns="com:ctl"><ctl id="72107787" td="GetCleanState" /></query></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq id="7" to="E0000000000000001234@159.ecorobot.net/atom" type="set"><query xmlns="com:ctl"><ctl id="72107787" td="GetCleanState" /></query></iq>'
|
||||
xmppclient._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -575,9 +537,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Bot response to query
|
||||
test_data = '<iq xmlns:ns0="com:ctl" id="2679" to="fuid_tmpuser@ecouser.net/IOSF53D07BA" type="set"><query><ctl td="ChargeState"><charge h="0" r="a" type="Going" /></ctl></query></iq>'.encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b'<iq xmlns:ns0="com:ctl" id="2679" to="fuid_tmpuser@ecouser.net/IOSF53D07BA" type="set"><query><ctl td="ChargeState"><charge h="0" r="a" type="Going" /></ctl></query></iq>'
|
||||
xmppclient2._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -589,9 +549,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Bot result
|
||||
test_data = "<iq type='result' from='E0000000000000001234@159.ecorobot.net/atom' to='ecouser.net' id='s2c1'/>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq type='result' from='E0000000000000001234@159.ecorobot.net/atom' to='ecouser.net' id='s2c1'/>"
|
||||
xmppclient2._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -603,9 +561,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Bot iq set
|
||||
test_data = "<iq to='fuid_tmpuser@ecouser.net/IOSF53D07BA' type='set' id='2700'><query xmlns='com:ctl'><ctl td='BatteryInfo'><battery power='100'/></ctl></query></iq>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq to='fuid_tmpuser@ecouser.net/IOSF53D07BA' type='set' id='2700'><query xmlns='com:ctl'><ctl td='BatteryInfo'><battery power='100'/></ctl></query></iq>"
|
||||
xmppclient2._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -617,9 +573,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Bot error report
|
||||
test_data = "<iq to='fuid_tmpuser@ecouser.net/IOSF53D07BA' type='set' id='631'><query xmlns='com:ctl'><ctl td='error' errs='102'/></query></iq>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq to='fuid_tmpuser@ecouser.net/IOSF53D07BA' type='set' id='631'><query xmlns='com:ctl'><ctl td='error' errs='102'/></query></iq>"
|
||||
xmppclient2._parse_data(test_data)
|
||||
|
||||
assert (
|
||||
|
|
@ -631,9 +585,7 @@ async def test_client_send_iq(*args, **kwargs):
|
|||
mock_send.reset_mock()
|
||||
|
||||
# Bot "DorpError" to all
|
||||
test_data = "<iq to='rl.ecorobot.net' type='set' id='1234'><query xmlns='com:sf'><sf td='pub' t='log' ts='1559893796000' tp='p' k='DeviceAlert' v='DorpError' f='E0000000000000001234@159.ecorobot.net' g='fuid_tmpuser@ecouser.net'/></query></iq>".encode(
|
||||
"utf-8"
|
||||
)
|
||||
test_data = b"<iq to='rl.ecorobot.net' type='set' id='1234'><query xmlns='com:sf'><sf td='pub' t='log' ts='1559893796000' tp='p' k='DeviceAlert' v='DorpError' f='E0000000000000001234@159.ecorobot.net' g='fuid_tmpuser@ecouser.net'/></query></iq>"
|
||||
xmppclient2._parse_data(test_data)
|
||||
assert (
|
||||
mock_send.mock_calls[0].args[0]
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
from mock import patch
|
||||
from unittest.mock import patch
|
||||
|
||||
import bumper
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue