confirm/USG-Easy-DNS

update script to python 3

joth76 opened this issue · 1 comments

The 2to3 script does the heavy lifting, just needs checking in

--- ./usg-easy-dns.py   (original)
+++ ./usg-easy-dns.py   (refactored)
@@ -1,9 +1,9 @@
 #!/usr/bin/env python3

-from __future__ import unicode_literals, print_function
+

 import argparse
-import cookielib
+import http.cookiejar
 import hashlib
 import logging
 import json
@@ -11,8 +11,8 @@
 import re
 import ssl
 import subprocess
-import urllib
-import urllib2
+import urllib.request, urllib.parse, urllib.error
+import urllib.request, urllib.error, urllib.parse

 #: Name of the default site when nothing else is specified.
 DEFAULT_SITE = 'default'
@@ -49,8 +49,8 @@
         if skip_ssl_verification:
             ssl._create_default_https_context = ssl._create_unverified_context

-        cookie_jar  = cookielib.CookieJar()
-        self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cookie_jar))
+        cookie_jar  = http.cookiejar.CookieJar()
+        self.opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cookie_jar))

     def _request(self, endpoint, data=None):
         '''

oc this is intended to run on the USG which only has py2.7 installed, so nvmd