from time import sleep from gandi_tool import gandi_tool from get_list_by_sql import individual_member_list, board_member_list, fsij_member_list def string_repr(l): return u'\n'.join(sorted(l)) if __name__ == "__main__": url='https://rpc.gandi.net/xmlrpc/' encrypted_key_file='api-key-info.json.gpg' domain='fsij.org' encrypted_list_file='fsij_list.json.gpg' import subprocess, json command=['gpg', '--decrypt', '-o', '-', encrypted_list_file] p = subprocess.Popen(command, stdout=subprocess.PIPE) listdata_string = p.communicate()[0] fsij_aliases = json.loads(listdata_string) g=gandi_tool(url, encrypted_key_file, domain) print("API Version: %s" % g.api_version()['api_version']) info=g.info() print("Domain owner handle: %s" % info['contacts']['owner']['handle']) print("Current number of forwards %d" % g.forward_count()) for i in fsij_aliases.items(): l = g.forward_list({ 'source' : i[0]}) dest = i[1] if l: if string_repr(l[0]['destinations']) == string_repr(dest): print("Skip: %s" % i[0]) else: print("Update: %s" % i[0]) g.forward_update(i[0], {'destinations': dest}) else: print("Create: %s" % i[0]) g.forward_create(i[0], {'destinations': dest}) for i in individual_member_list: l = g.forward_list({ 'source' : i[0]}) dest = i[1] if l: if string_repr(l[0]['destinations']) == string_repr(dest): print("Skip: %s" % i[0]) else: print("Update: %s" % i[0]) g.forward_update(i[0], {'destinations': dest}) else: print("Create: %s" % i[0]) g.forward_create(i[0], {'destinations': dest}) l = g.forward_list({ 'source' : 'board' }) dest = board_member_list if l: if string_repr(l[0]['destinations']) == string_repr(dest): print("Skip: %s" % 'board') else: print("Update: %s" % 'board') # g.forward_update('board', {'destinations': dest}) else: print("Create: %s" % 'board') g.forward_create('board', {'destinations': dest}) l = g.forward_list({ 'source' : 'members' }) dest = fsij_member_list if l: if string_repr(l[0]['destinations']) == string_repr(dest): print("Skip: %s" % 'members') else: print("Update: %s" % 'members') g.forward_update('members', {'destinations': dest}) else: print("Create: %s" % 'members') g.forward_create('members', {'destinations': dest}) print("Current number of forwards %d" % g.forward_count()) for entry in g.forward_list(): print("%s -> %s" % (entry['source'], entry['destinations']))

AltStyle によって変換されたページ (->オリジナル) /