Changeset 3da9ea in indico


Ignore:
Timestamp:
06/29/11 15:34:07 (23 months ago)
Author:
Pedro Ferreira <jose.pedro.ferreira@…>
Branches:
master, hello-world-walkthrough, ipv6, v0.98-series, v0.98.2, v0.98.3, v0.98b2, v0.99, 051b2622c51afb171a1dedb46a0df4fbb0cbd02e, d9941f8582b36b24821a11ea5ba16fda6a457fb1
Children:
91cb2e
Parents:
bcee0f
Message:

[FIX] Surviving HTTPWithTimeout

  • Also added logging;
File:
1 edited

Legend:

Unmodified
Added
Removed
  • indico/MaKaC/export/fileConverter.py

    ra370da r3da9ea  
    2121import tempfile, os, base64, socket 
    2222import mimetypes, urlparse, simplejson 
     23import httplib 
     24 
     25from MaKaC.common.logger import Logger 
    2326from MaKaC.common.Configuration import Config 
    2427from MaKaC import conference 
    25 from MaKaC.common.httpTimeout import HTTPWithTimeout 
    2628 
    2729#URL_RESPONSE = "http://pcdh20.cern.ch/indico/getConvertedFile.py" 
     
    7981            #writeLog("Local file to upload invalid") 
    8082            return False 
    81         fic=open(localFile, "rb") 
    82         segnum=0 
     83        fic = open(localFile, "rb") 
     84        segnum = 0 
    8385        segsize = SEGMENT_SIZE 
    8486        filekey = 'segfile' 
    85         try : 
    86             h = HTTPWithTimeout(host, timeout = 5) 
    87         except Exception, e: 
    88             #writeLog("Error : Can't connect to host:%s"%host) 
    89             return False 
    9087 
    9188        while 1: 
     
    148145 
    149146            try: 
    150                 h.putrequest('POST', selector) 
    151                 h.putheader('content-type', content_type) 
    152                 h.putheader('content-length', str(len(body))) 
    153                 h.endheaders() 
    154                 h.send(body) 
    155             except: 
    156                 #writeLog("Exception while sending file to the CDSconv server") 
    157                 pass 
    158             try: 
    159                 h.getreply() 
     147                Logger.get('cdsconv').info("Uploading %s to %s" % (localFile, host)) 
     148                h = httplib.HTTPConnection(host, timeout=5) 
     149                h.request('POST', selector, body, {'content-type': content_type}) 
     150                h.getresponse() 
    160151            except socket.timeout: 
     152                Logger.get('cdsconv').exception("Timeout connecting to %s" % host) 
    161153                break 
    162154            except Exception: 
    163                 #writeLog(e) 
    164                 pass 
     155                Logger.get('cdsconv').exception("Error connecting to %s" % host) 
    165156            if lastseg == 1 : 
    166157                #print "\n%s\n"%(h.getfile().read()) 
Note: See TracChangeset for help on using the changeset viewer.