Changes in list function
This commit is contained in:
parent
0e1a5d7314
commit
15e8f8ac90
18
malias.py
18
malias.py
@ -235,6 +235,7 @@ def checklist(alias):
|
||||
|
||||
def list_alias():
|
||||
apikey = get_api()
|
||||
cursor = conn.cursor()
|
||||
mail_server = get_settings('mail_server')
|
||||
req = urllib.request.Request('https://'+mail_server+'/api/v1/get/alias/all')
|
||||
req.add_header('Content-Type', 'application/json')
|
||||
@ -243,14 +244,21 @@ def list_alias():
|
||||
remote = current.read().decode('utf-8')
|
||||
remoteData = json.loads(remote)
|
||||
i = 0
|
||||
print('\n[b]malias[/b] - All aliases on %s' %(mail_server))
|
||||
print('===================================================')
|
||||
print('\n[b]malias[/b] - All aliases on %s ([b]*[/b] also in local db)' %(mail_server))
|
||||
print('==================================================================')
|
||||
for search in remoteData:
|
||||
the_alias = remoteData[i]['address'].ljust(20,' ')
|
||||
print(the_alias + '\tgoes to\t\t' + remoteData[i]['goto'])
|
||||
the_goto = remoteData[i]['goto'].ljust(20,' ')
|
||||
cursor.execute('SELECT count(*) FROM aliases where alias like ? or goto like ?', (remoteData[i]['address'],remoteData[i]['address'],))
|
||||
count = cursor.fetchone()[0]
|
||||
if count >= 1:
|
||||
print(the_alias + '\tgoes to\t\t' + the_goto + '\t[b]*[/b]')
|
||||
else:
|
||||
print(the_alias + '\tgoes to\t\t' + the_goto)
|
||||
i=i+1
|
||||
|
||||
|
||||
print('\n\nTotal number of aliases %s. Fetched from instance [b]%s[/b]' %(str(i),mail_server))
|
||||
|
||||
|
||||
|
||||
def alias_id(alias):
|
||||
apikey = get_api()
|
||||
|
Loading…
Reference in New Issue
Block a user