Moved helper functions out of the main function.

This commit is contained in:
Homer S. 2021-07-06 17:14:00 +02:00
parent 9e6e294491
commit 25aeeb5c9b
1 changed files with 22 additions and 19 deletions

View File

@ -26,22 +26,6 @@ if env_voicebox is None:
if env_tmp is None:
env_tmp = "/tmp"
def fritzab2matrix():
### CHECK AND GET MESSAGES FROM FRITZBOX ###
############################################
## Connect to the FritzBox in the LAN
# We don't use tls because the self-signed cert of the box leads to a malfunction in urllib later on.
fc = FritzConnection(address=env_ip, user=env_user, password=env_pass, use_tls=False)
## Get info about messages from the main answering machine
message_list = fc.call_action("X_AVM-DE_TAM1", "GetMessageList", NewIndex=0)
message_list_url = message_list['NewURL']
# Build the url to download the message via smb
def build_download_url(mid, tam=0):
@ -63,6 +47,25 @@ def fritzab2matrix():
messages = xmltodict.parse(doc)
return messages
def fritzab2matrix():
### CHECK AND GET MESSAGES FROM FRITZBOX ###
############################################
## Connect to the FritzBox in the LAN
# We don't use tls because the self-signed cert of the box leads to a malfunction in urllib later on.
fc = FritzConnection(address=env_ip, user=env_user, password=env_pass, use_tls=False)
## Get info about messages from the main answering machine
message_list = fc.call_action("X_AVM-DE_TAM1", "GetMessageList", NewIndex=0)
message_list_url = message_list['NewURL']
l = get_message_list(message_list_url)
if l['Root'] == None or l['Root']['Message'] == None:
return False