server/sources/datafeed.py
changeset 10758 a34edc1057c0
parent 10757 f73a9a884534
child 10805 de4403644b1c
equal deleted inserted replaced
10757:f73a9a884534 10758:a34edc1057c0
    21 
    21 
    22 from io import BytesIO
    22 from io import BytesIO
    23 from os.path import exists
    23 from os.path import exists
    24 from datetime import datetime, timedelta
    24 from datetime import datetime, timedelta
    25 
    25 
       
    26 from six import text_type
    26 from six.moves.urllib.parse import urlparse
    27 from six.moves.urllib.parse import urlparse
    27 from six.moves.urllib.request import Request, build_opener, HTTPCookieProcessor
    28 from six.moves.urllib.request import Request, build_opener, HTTPCookieProcessor
    28 from six.moves.urllib.error import HTTPError
    29 from six.moves.urllib.error import HTTPError
    29 from six.moves.http_cookiejar import CookieJar
    30 from six.moves.http_cookiejar import CookieJar
    30 
    31 
   388         if source_uri is not None and source_uri != 'system':
   389         if source_uri is not None and source_uri != 'system':
   389             source = cnx.repo.sources_by_uri.get(source_uri, self.source)
   390             source = cnx.repo.sources_by_uri.get(source_uri, self.source)
   390         else:
   391         else:
   391             source = self.source
   392             source = self.source
   392         sourceparams['parser'] = self
   393         sourceparams['parser'] = self
   393         if isinstance(uri, unicode):
   394         if isinstance(uri, text_type):
   394             uri = uri.encode('utf-8')
   395             uri = uri.encode('utf-8')
   395         try:
   396         try:
   396             eid = cnx.repo.extid2eid(source, str(uri), etype, cnx,
   397             eid = cnx.repo.extid2eid(source, uri, etype, cnx,
   397                                          sourceparams=sourceparams)
   398                                      sourceparams=sourceparams)
   398         except ValidationError as ex:
   399         except ValidationError as ex:
   399             if raise_on_error:
   400             if raise_on_error:
   400                 raise
   401                 raise
   401             self.source.critical('error while creating %s: %s', etype, ex)
   402             self.source.critical('error while creating %s: %s', etype, ex)
   402             self.import_log.record_error('error while creating %s: %s'
   403             self.import_log.record_error('error while creating %s: %s'