Changeset 2689

Show
Ignore:
Timestamp:
03/28/17 05:14:30 (4 weeks ago)
Author:
jwoithe
Message:

ffado-mixer: the registration code utilises urlopen() and urlencode() which have moved from urllib to urllib.request and urllib.parse respectively. urlencode() also requires additional treatment in python3. Allow for all this in a python2 compatible way. The original suggestion for the python3 code was from Xavier Forestier.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/libffado/support/mixer-qt4/ffado/registration.py

    r2688 r2689  
    3131except: 
    3232    from ConfigParser import SafeConfigParser 
     33 
     34# The urlopen()/urlencode() functions from urllib in python2 are in  
     35# urllib.request and urllib.parse respectively under python2. 
     36try: 
     37    import urllib.request, urllib.parse 
     38    url_newapi = 1 
     39except ImportError: 
     40    import urllib 
     41    url_newapi = 0 
    3342 
    3443from ffado.config import REGISTER_URL, INI_FILE_PATH, FFADO_CONFIG_DIR 
     
    8392 
    8493        try: 
    85             response = urllib.urlopen(REGISTER_URL, 
    86                                       urllib.urlencode(post_vals)) 
     94            if url_newapi == 1: 
     95                response = urllib.request.urlopen(REGISTER_URL, 
     96                                                  urllib.parse.urlencode(post_vals).encode('ascii')) 
     97            else: 
     98                response = urllib.urlopen(REGISTER_URL, 
     99                                          urllib.urlencode(post_vals)) 
    87100        except: 
    88101            log.error("failed, network error")